Matthew,
I haven't done exactly what you're trying to do, but I might be able to help a bit.
I am just playing back (short, pre-recorded) sampled sound data for a game, not trying to generate sound data on the fly (or play entire songs).
What I discovered is:
1. the only playback format I could get to work reliably, correctly, on a variety of hardware, was 22.050 kHz sndInt16Little (pretty sure 44.1 kHz would also work). By "reliably, correctly" I mean with reasonably low latency, without a large negative impact on my animation performance, without hanging if playing two or three sounds simultaneously. Other formats will play somewhat, sometimes, maybe with poor performance or bad latency, or sometimes hanging.
1.b. To save space, I have succeeded in actually storing my data in 11.025 kHz sndInt16Little, and repeating each sample once in my callback (68K code, not ARMlet).
2. I only had success when specifying 0 for the requested buffer size (which allows the sound manager to choose the buffer size).
3. There is some intermittent problem with calling SoundStreamDelete() shortly after SoundStreamStop() or if the stream is not already stopped; I create my sound streams once and re-use them for the lifetime of my application, and only delete them when the user exits (with a delay after stopping them).
4. When I run out of data for a particular sound (want it to end), my callback fills the remainder of the current buffer with zeros and sets a flag, then the next time it is called it fills another entire buffer with zeros and calls SoundStreamStop(). Any other way of ending a sound caused problems: the sound would be cut off, we would hear garbage, short sounds would not play at all, or the system would hang.
5. Stored sounds had to be larger than 2K bytes, which would result in more than 4K bytes being returned by the callback, or they would not be heard on some devices.
The sound APIs are under-documented and I couldn't find any sample code that was generally useful for what I was trying to do. Searching the palm-dev-forum archives turned up a lot of information, some of which was useful, but very little of which was explicit and/or completely correct. There is a lot of guesswork and word-of-mouth in this area, unfortunately.
If any of my information above is wrong, or anyone has more detailed info to share, please jump in!
Hope this helps,
Ted Peters
On Sep 2, 2004, at 3:15 AM, Matthew Bevan wrote:
Howdy!
I currently have an application which successfully streams raw PCM data in
signed 16-bit, Wintel-endian, 22kHz or 44kHz formats. Now on to the
difficult part.
...
A little help would go an awful long way in my 6 hour search for an answer.
Thanks in advance,
Matthew Bevan
-- Matthew Bevan, Margin Software - Re-inventing the wheel, every time.
FYI - Finagle's fourth Law:
Once a job is fouled up, anything done to improve it only makes it worse.
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
