"news.palmos.com" wrote:
> Has anyone managed to play sampled sound on the Palm tungsten using the
> Sound manager?
> I'm testing the Stream Manager by outputting random samples:
>
> SndStreamCreate(&stream, sndOutput, 44100, sndInt16, sndStereo, getbuf, 0,
> 8192, false);
>
> The callback function getbuf gets called properly and is defined as follows:
>
> UInt&6 getbuf(void *userData, SndStreamRef stream, void *buffer, UInt32
> frameCount) {
> Int32 buf_size=frameCount*4 // stereo and Int16 frames
> char *buf_ptr=buffer;
> Int32 i;
> for (i=0; i<buf_size; i++) {
> buf_ptr[i]=SysRandom(0)%256;
> }
> }
>
> As you can see, getbuf, simply fills the buffer with random data.
>
> The problem I encounter is that the first filled buffer gets played, but
> after that nothing gets played anymore, I simply hear some kind of ticking
> (although getbuf is called properly each time).
>
> Can someone please tell me how to play random samples using the Sound
> Manager?
>
> Thanks,
> David
For me the soundstuff works fine. I just do it like you do.. although I use
8-bit samples and I do it in assembly... ;)
Calling SysRandom (or OS-routine in general) in a time-critical code-area might
not be the best solution.
Just try to play a simple square-wave to test your soundroutine.
(f.e.: buf_ptr[i] = (fract>>8)&0x8000; fract+=frequency; this should
work. (8bit fractional freq. precision) )
(Or use a simple feedback algorithm.)
(Or just use a short sample from a database)
...
Something I encountered: some frequency are rejected by SndStreamCreate.
Btw, why is *buff_ptr a char* ? Shouldn't it be a u16 * ? (because of
SndInt16)
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/