Okay, making progress here... I've gotten synchronous sounds working now by loading the whole buffer with the data from the wave file, and it sounds great. No popping at all.
Unfortunately, it is synchronous. When the sound plays, the game stops, and only one sound plays at a time. Clearly, this isn't going to work for a game. So, because my samples are 8 bit unsigned, I tried loading only frameCount (the parameter given to the callback) bytes into the buffer when my callback is called, and step through the data of the wave file frameCount bytes at a time. I'm tantalizingly close now...the sounds work okay (with some glitching) for just a little while, but then the simulator crashes. Is there a header that I need to wrap around the raw WAV data that I'm putting into buffer, or can I just put the next raw byte as found in the WAV file? Anyone have any other ideas what might be going wrong here? (Or code examples that split multiple simultaneous, asynchronouns sounds across this sound stream interface?) -Ken On Tue, 2003-01-14 at 13:46, kcorey wrote: > Hi All, > > For PalmOS5.0, I tried using SndPlayResource in my game, but when sounds > overlapped there was a god-awful snapping and popping, and after 30 > seconds or so, the device just locked solid. > > My suspicion is that when many sounds are happening all at nearly the > same time, the buffers SndPlayResource uses are overwhelmed. > > So, I've been investigating using SndCreateStream, and the callbacks, > but there are a few things I'm not sure about. > > For example, what's a "frame"? How big is it (1 bit?, 1 byte?)? I know > the callback and call SndStreamStop on itself, but can code tell its > current status? Can it delete itself? > > My current plan is to have an array of 16 SndStreamRef's, and when I > need to play a game sound, either: > 1) the first NULL stream ref is grabbed from the array, the stream is > started, the sound is played, and when done, the stream is stopped and > deleted. > 2) the first stopped stream is started, and loads the first sound to be > played. When that's done the stream is stopped again. > > The first sounds like its making the Palm do a lot of work each time a > sound is called. The second may not be possible, because I can't see > how to tell whether a given stream is started or not. > > Anyone have example code that they can publish that explores this a bit? > Even the example code waves.c in the PalmOS5 SDK only uses > SndPlayResource. > > -Ken > > > -- > For information on using the Palm Developer Forums, or to unsubscribe, please see >http://www.palmos.com/dev/support/forums/ -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
