Which Sound API to use?


ZXDunny

Deep avatar
Joined
Oct 12, 2010
Messages
2,556
Hi all -


I've been spending the time waiting for my pandora developing a BASIC interpreter. It's based on Sinclair BASIC, and has gained quite a following on the PC amongst Speccy enthusiasts. It's very fast and has lots of lovely commands for working with graphics and memory, but now I'd like to add sound. I was told that FMOD would be a good idea, but I'm not sure that it will be suitable (no pandora port of the library, AFAICS). My interpreter has been ported to linux, so I know it should be relatively simple to port to the Pandora.


What I need is:


1. An open-source sound API that is compatible with my development environment and portable between win32 and linux


2. Able to play sound samples from a buffer that I create at the rate and bitdepth I specify. The data will probably be raw PCM.


3. I'd like to expose the samples played to the user via a "memory bank" structure in the BASIC interpreter, so they can modify the samples


4. Be able to play music from MP3/MOD/S3M/XM/IT etc either from memory or streaming from disk.


I can write my own PCM extraction routines for WAV and other simple sample formats, but I'd like the API to handle loading MP3/OGG samples if possible. Under windows, I'd use a looping directsound buffer and inject my samples into that - and the most important thing is being able to edit the memory that holds the sample while the sample is playing if at all possible.


Can anyone suggest an API that would be suitable for use on the Pandora?


D.
 

sebt3

homebrew player (P. & C.)
Joined
Sep 9, 2008
Messages
4,805
Age
39
Location
France
Website
sebt3.openpandora.org
Excellent, I'll have a look at that then. Is there a Pandora-friendly ARM version of the mikmod library at all?
SDL_Mixer have mikmod integrated (that's how it support MOD/S3M/XM/IT).


But if you need mikmod outside of SDL, it's easy to build (I think I've built it for audacious, not sure though). Angstrom only list a few modification to the built process but nothing major.
 

ZXDunny

Deep avatar
Joined
Oct 12, 2010
Messages
2,556
SDL_Mixer have mikmod integrated (that's how it support MOD/S3M/XM/IT).


But if you need mikmod outside of SDL, it's easy to build (I think I've built it for audacious, not sure though). Angstrom only list a few modification to the built process but nothing major.
Interesting, I was led to believe by the documentation that you needed the external libraries (such as FLAC, MikMod etc) present if you want to use those formats - SDL_Mixer appears to be a "wrapper" library.


Good news that all I'll need is the SDL_Mixer lib then!


D.
 

sebt3

homebrew player (P. & C.)
Joined
Sep 9, 2008
Messages
4,805
Age
39
Location
France
Website
sebt3.openpandora.org
Interesting, I was led to believe by the documentation that you needed the external libraries (such as FLAC, MikMod etc) present if you want to use those formats - SDL_Mixer appears to be a "wrapper" library.


Good news that all I'll need is the SDL_Mixer lib then!
Your belief is right (Mine was wrong, I just had a look to sdl sources), SDL_Mixer is just a wrapper around the external libraries. But then Mikmod have to be installed on pandora anyway 'cause, I've already used SDL to play mikmod (*it) files on pandora.


(It is also highly probable that I didn't built it for audacious :p )
 

ZXDunny

Deep avatar
Joined
Oct 12, 2010
Messages
2,556
Your belief is right (Mine was wrong, I just had a look to sdl sources), SDL_Mixer is just a wrapper around the external libraries. But then Mikmod have to be installed on pandora anyway 'cause, I've already used SDL to play mikmod (*it) files on pandora.


(It is also highly probable that I didn't built it for audacious :p )
Went with BASS in the end - it builds for linux and PC, which is currently my target platform, and does everything I want - SDL_Mixer just turned out to be a pile of crap, at least for what I wanted it for. I really don't have the inclination write my own mixer to sit on top of the SDL mixer itself, but it turns out I'd have to :(


BASS rocks. There's no pandora/ARM port that I'm aware of and I have no idea if one is possible - but that's kind of moot as it's unlikely I'll ever get my Pandora before OPT file for bankruptcy, so I'll stick with the PC version of my code for now. Realistically, I don't have much choice :)


D.
 

sebt3

homebrew player (P. & C.)
Joined
Sep 9, 2008
Messages
4,805
Age
39
Location
France
Website
sebt3.openpandora.org
Went with BASS in the end - it builds for linux and PC,
I've only seen mac and windows download on their web site.

BASS rocks. There's no pandora/ARM port that I'm aware of and I have no idea if one is possible
Unfree, close-source so very very very unlikely :(

but that's kind of moot as it's unlikely I'll ever get my Pandora before OPT file for bankruptcy, so I'll stick with the PC version of my code for now. Realistically, I don't have much choice :)

You're wrong... But then, you'll hopefully change your mind.
 

ZXDunny

Deep avatar
Joined
Oct 12, 2010
Messages
2,556
I've only seen mac and windows download on their web site.
http://www.un4seen.com/forum/?topic=8682.msg59533#msg59533

Unfree, close-source so very very very unlikely :(


You're wrong... But then, you'll hopefully change your mind.
I know, I know... But I'm really really not liking the idea of having to write shitloads of code that BASS can do for nothing. This afternoon I've got my interpreter playing up to 128 samples from the same memory bank (yes, the same sample many times) with virtually no CPU slowdown. This API really does rock.


Not holding out much hope for an ARM port, but if I do ever get a Pandora, I'll look at doing the port myself - the interpreter uses callbacks to minimise the amount of platform-specific code I have to write. There's a few devs in my little community that want to write games (they've mostly written amiga-style demos in it so far) and this is really shaping up well. Hopefully OpenGL support will go across with no rewriting necessary!


D.
 

sebt3

homebrew player (P. & C.)
Joined
Sep 9, 2008
Messages
4,805
Age
39
Location
France
Website
sebt3.openpandora.org
Sure the 9 channels of SDL_mixer is limiting when you want to handle that much streams.


Maybe Jack could help you, but i'm no audio nor coding expert.
 

smcameron

Still Fresh
Joined
May 6, 2011
Messages
14
For the C programmers, portaudio isn't too bad (it is what audacity uses), if you don't mind writing your own mixer, and if you do mind, then you can use portaudio + wwviaudio. Wwviaudio provides a very simple interface for audio. It is here:


http://ccan.ozlabs.org/info/wwviaudio.html


depends on ogg_to_pcm, which is here:


http://ccan.ozlabs.org/info/ogg_to_pcm.html


Full disclosure, I wrote both wwviaudio and ogg_to_pcm (though the latter is heavily derived from code from xiph.org). I wrote them while developing the game Word War vi, you can check that game out and see how you like the sound. It mixes something like 25 channels of sound in real time.


Also, wwviaudio only does 16-bit 44Khz mono sounds (doing stereo wouldn't be very hard though.)


-- steve
 
Last edited by a moderator:

klapse

Central Scrutinizer
Joined
Aug 30, 2012
Messages
1,932
Location
Germany
I don't know if SDL mixer is really a pile of crap, but it resets volume of looped .it tracks to 100%. I have a workaround posted to the xu4 thread where your code manually restarts a track at correct volume based on a finished-playing callback function.
 

Rockthesmurf

Advanced Member
Joined
Jul 18, 2003
Messages
1,113
Age
36
Location
Manchester, UK
Website
Visit site
Sounds like you have a solution, but just for reference, in KAMI RETRO, I use a combination of: OpenAL, libvorbis, libogg, libmikmod to handle audio on most platforms (one one or two I use SDL, for example WebOS, and for Android I currently use Java side code over JNI). Relatively straight forwards to set up a solution that allows for steaming audio and position SFX.


One thing about SDL, certainly the way I use it (for audio), I had to make sure a couple of things were thread safe, as the mixing callback runs on another thread. This may add complications (hopefully not) but it does mean you get a performance win of having the audio on another thread (so if nothing else in the game/engine is threaded, at least the audio can be processing whilst the draw is going).


Steve
 
Top