I can load and request the duration of a a WAV (ADPCM 4Bits 8Khz) but
while trying to play I get a BadParam error... Why ?
Did you know a web site where we can upload and download CW codes to share.
void CMStick::MSPlayWave(char *fileName,char *message) {
Err err;
UInt16 refNum;
UInt32 size;
MemPtr pcmp;
FileRef file;
SndPcmFormatType frmt;
SndPcmOptionsType optn;
refNum=(CHSLibr::get()).getSoundRefNum();
if (refNum!=sysInvalidRefNum) {
size=MSFileSize(fileName);
if (size>0) {
err=VFSFileOpen(refCMS, fileName, vfsModeRead, &file);
if (err==errNone) {
FtrPtrNew(appCtr, 0, size, &pcmp);
if (pcmp) {
err=VFSFileReadData(file, size, pcmp, 0, &size);
}
VFSFileClose(file);
if (err==errNone) {
frmt.formatTag=0x0020;
frmt.numOfChan=1;
frmt.samplePerSec=8000;
frmt.bitPerSample=4;
frmt.dataSize=size;
err=SndPlayPcm(refNum,
(void*)NULL,
sndPcmCmdDuration,
(UInt8 *)pcmp,
&frmt,
&optn,
(SndPcmCallbacksType*)NULL,
false);
StrPrintF(message,"TIME : %ld ms\n",optn.dwEndMilliSec);
err=SndPlayPcm(refNum,
(void*)NULL,
sndPcmCmdPlay,
(UInt8 *)pcmp,
&frmt,
&optn,
(SndPcmCallbacksType*)NULL,
false);
switch (err)
{
case sndErrBadParam :
StrCat(message,"BadParam\n");
break;
case sndErrFormat :
StrPrintF(message,"Format\n");
break;
case sndErrInterrupted :
StrPrintF(message,"Interrupted\n");
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/