Hi Mangus ,

Thanks for your proper comments ...

Its working ...

But what i observed is that if i play a wave file by using sndPlayResource then the sound quality is good ...
but if i use sndStreamCreate , then sound quality is bad .. so much noise it is introducing while playing ...why it is so ???


and one more thing no need to format the wave file .. because it is already in little endian format ...

Thanks once again ...

Regards ,
Geeta M.

Magnus Berg wrote:


Comments in the code.

void call_snd_create()
{
Err err;
int ret = 0;
unsigned long len_to_read = 500,ret_len=0,len =0;
Byte *buf[300] = {0};
err = SndStreamCreate(&stream, sndOutput, 48000, sndInt16Big, sndStereo, snd_callback,file_h,250,false);

Use sndInt16Little, all other formats are unimplemented or flawed. on a T|T.

   switch (err)
   {
       // generate error value;
   }
     if(SndStreamStop(stream)== errNone)

There's no need to stop the stream before you started it.

{
//FrmCustomAlert(ErrorAlert,"Success","In stopping the stream","**");
}
else FrmCustomAlert(ErrorAlert,"Failuer","In stopping the stream","**");
if(stream)
{
err = SndStreamStart (stream) ;
switch (err)
{
// generate error value }
}
else
{
FrmCustomAlert (ErrorAlert, "Stream not created", "**", "**") ; return ;
}
}

Err snd_callback (void *userData, SndStreamRef stream, void *buffer, UInt32 frameCount)
{
int read_len = 250;
frameCount = 2 ;

Don't change frameCount!!

The value you sent into sndStreamCreate is only a suggestion. The real buffer size is determined by the OS and must be obeyed. Since you use 16 bit samples ans stereo, each frame is 4 bytes.

ret = ReadFile ((FileHand) userData, buffer, (DWORD) read_len, (unsigned long*)&ret_len, NULL) ;

Since you're reading from the file without any conversion, make sure that the format of the file is exactly what PalmOS expects, i.e. little endian 16 bit samples in stereo.

if (ret == 0)
{
//FrmCustomAlert (ErrorAlert, "ReadFile error", NULL, NULL) ;

I don't think it's a good idea to open an alert in the sound callback. You should communicate errors to your app in some other fashion.

//WinDrawChars("read Err", StrLen("read Err"),10,50); return;
}
return errNone ;


Good luck.

    Magnus




--
For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to