background sound/music || streaming audio

I want to add some background musics to my program but I don't know the best way to do this. As my program has disc access according to what does the user (loading files most of the time), I think CDDA music is not a good choice. I thought about streaming music.

Rockin'B talked about "stream playback from CD" on his Game Tutorial but I didn't see any sample code.

I also tried his Sound Player but I was not able to play any sound with it (I tested it with some uncompressed WAV files, didn't work, and one compressed AIF from Enemy Zero but I got "abnormal stop" when trying to play it). So I probably make something wrong.

So, how to implement streaming audio ?

Thanks.

(next, I will check how to run DUCK Truemotion videos :biglaugh:)
 
Ah Madroms,

that sounds like you're going to try some real fine stuff, I appreciate that!

I should add TrueMotion playback to the extra points list, if I haven't done it already!

To access multiple files at once, you'll have to use streams (as far as I know).

The PCM (*.AIF) playback library (from SBL) features memory playback, file playback and stream playback. The latter one enables concurrent use of File reading (using streams, too). The SND library allows stuff like that, too. This one might be too low level for easy use with SGL. With Sequences (midi-like), you can access files while playing sound, too.

Beware when using the SBL example code in you SGL game: setting functions for vblank in and out is done different, a more high level. Don't use the SBL function vblInit(), look at the Saturn SoundPlayer source (slIntFunction(my_vblank);).

PCM Library:

Stream playback mode

C:\SaturnOrbit\SBL_601\SEGASMP\PCM\SMPPCM2

Stream playback mode (Sample use of each function, CD-ROM XA audio playback)

C:\SaturnOrbit\SBL_601\SEGASMP\PCM\SMPPCM5

SND Library:

PCM stream playback (using interruption) sample

C:\SaturnOrbit\SBL_601\SEGASMP\SND\SMPSND4

Demo of simultaneous playback of CD-DA and PCM stream playback

(using interrupts).

C:\SaturnOrbit\SBL_601\SEGASMP\SND\SMPSND5
 
Thanks rockin'b, I will look at these sample. One problem is they can't be compiled with the saturnorbit, unless you make change on some files (something vbt did for me for 1 sample, but I can't do by myself due to my poor knowledge of c/config files).

Another question: what is the max size/length of wav/pcm file if read from memory ? 1MB (or 512kB ?) and less than 1 min in low quality ?
 
Max size of a PCM file played back from memory should be 1MByte, if you put it in low work RAM.

I recommend mono 8bit 22500 Hz, this gives 46 seconds of playback time. If sampled with 11250 Hz (which might be sufficient for certain use cases), it's twice as much. When playing AIF files from CD, you can have up to an hour.
 
Ok, PCM playback from memory works, but I am limited to about 250-300k for the file, as I need the memory for the rest of the program (also it could be limited because bget is used, and it is something I don't understand... yet? ;) )

So, how to have good listening music, with low sample, and good length ?? How could I get all of this ?? :D I will see, else => no sound.

Last question, how to have infinite loop for the audio (with PCM playback from memory) ? Loop that can be stopped when I need to load another audio file.
 
Madroms said:
So, how to have good listening music, with low sample, and good length ?? How could I get all of this ??


A MOD player, perhaps? Just a thought. Don't get aggressive, Amon.
 
Madroms said:
Ok, PCM playback from memory works, but I am limited to about 250-300k for the file, as I need the memory for the rest of the program (also it could be limited because bget is used, and it is something I don't understand... yet? ;) )

Looks like the file is put into high work RAM. Either put the file into low work RAM manually, it starts at address 0x200000 and is 1MByte long. Or, if the file buffer is allocated with bget, make low work RAM visible to bget by bpool(0x200000, 1024*1024);

This both assumes that you load the file from CD, before playing it back.

Madroms said:
So, how to have good listening music, with low sample, and good length ?? How could I get all of this ?? :D I will see, else => no sound.

For this, use file(or stream) playback of AIF files. I used Audacity for creating AIF files. How to use file playback can be seen in my Saturn SoundPlayer and in Atlas, too.

Madroms said:
Last question, how to have infinite loop for the audio (with PCM playback from memory) ? Loop that can be stopped when I need to load another audio file.

About setting the loop function for AIF files, look here:

File playback mode (Loop playback):

C:\SaturnOrbit\SBL_601\SEGASMP\PCM\SMPPCM4

Memory playback mode (multi-playback, loop playback):

C:\SaturnOrbit\SBL_601\SEGASMP\PCM\SMPPCM13
 
Ok, I played a lilbit with sound, and it seems to work. Too bad the sound library (sl... functions) is really poor compared to the SBL library.

About the PCM structure, does anyone know if the effects are documented somewhere ? I read a lot of dev manuals but didn't find this info.

=> this part of the structure:

Uint8 eflevelR; / * Effect Level (right and mono) * /

Uint8 efselectR; / * Number Effects (right and mono) * /

I just find that "Effect Level is 0-7, effects are numbered from 0 to 15".

Also, about the slPCMParmChange function, I saw your comment, Rockin'b, on your soundplayer, and I also had the same "issue": sound is stopped when calling it. Any updates or more documentation about how to really use this function, and why it has been made ?

At least, can I use SBL functions like PCM_SetLoop if I use sl functions to load/play PCM or it is exclusive: PCM_... functions or sl... functions, not both ?

Thanks ;)
 
Madroms said:
About the PCM structure, does anyone know if the effects are documented somewhere ? I read a lot of dev manuals but didn't find this info.

=> this part of the structure:

Uint8 eflevelR; / * Effect Level (right and mono) * /

Uint8 efselectR; / * Number Effects (right and mono) * /

The manual is very unclear on this, but AIUI these correspond to the sound slot EFSEL and EFPAN registers. Bizarrely they control the DSP output slot mixer settings, which not connected to the sound slots they are set in. So the settings in the structure do not seem to be very useful at all, and its a mystery why they're included at all.
 
Thanks antime, so I must test these to see if they do something, not that I need them, but just that I am curious :D
 
You could possibly use ADPCM reduce the filesize by 1/4. Although I'm not sure if those would be playable without loading an extra library required for decoding the data. Also the only two adpcm formats I've seen the Saturn handle are DUCK and ADX.
 
I didn't play with DUCK for now but it could be a great way to look at. For ADX, I didn't remember if we have some sources about it.

I just got a HDD failure this week-end, the one with the OS and all my sources code, db and such. Luckily, I was able to recover all the data (ouf!), I just spent all my week-end to reinstall XP on a new HD, reinstall all the soft and recover all my data. So it is 2 days lost for coding, so I will probably not have time to implement DUCK playback on my project. I have too much things to do before (like taking a shitloads of screenshots and more than 200 PCM samples...)
 
We have ADX encoders and tools on some Dreamcast devkits but I'm not sure those are useable for the Saturn.
 
Back
Top