The callback must complete more quickly than the time it takes the to play the samples. I suggest a lower sample rate (to increase the time available), and a callback function that does not have a divide for every sample. I also use shorter buffers (1024) to make sure the callback function completes promptly.
The m550 currently seems to have a low pass filter that makes using sample rates any higher than 11025 academic. I've used a sample rate of 8000 to play over 1 hour of continuous sampled sound without any apparent clicks or pops, so I know it's possible. IMHO. YMMV. Ron Nicholson HotPaw Productions <http://www.hotpaw.com/rhn/hotpaw> ------ Original Message ------ David Janssens writes: > >As you suggested, I tried to play a long 440Hz tone: >Using 16bit samples at a 44100 rate, I used this code: > >SndStreamCreate(&playstream, sndOutput, 44100, sndInt16Little, sndMono, >getbuf, &pctx, 16384, false); > >UInt16 getbuf(void *userData, SndStreamRef stream, void *buffer, UInt32 >frameCount) { > Int32 buf_size; > Int16 *buf_ptr=buffer; > buf_size=frameCount; > { > Int32 i; > UInt32 rate, fract, freq, freq2; > freq=440; // 440Hz > rate=44100; > freq2=(freq<<16)/rate; > fract=0; > //eprintf("freq2=%ld", freq2); > for (i=0; i<buf_size; i++) { > buf_ptr[i]=fract&0x8000?0xff7f:0x0080; > fract+=freq2; > } > return errNone; > } >} > >When I run this, I hear a 440Hz tone, the problem is it isn't continuous. I >think each buffer gets played properly, but in between, I hear some >artefacts. (the sound is "chopped" into pieces). >When I run the same code using UInt8 samples, I have exactly the same >problem. >Do you have the sample problem when running the same code? >What should I do to get a continous 440Hz tone? -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
