Jump to content


Photo

Which Sound API to use?


  • Please log in to reply
16 replies to this topic

#1 OFFLINE   ZXDunny

ZXDunny

    Advanced Member

  • Members
  • PipPipPip
  • 1744 posts
  • Local time: 03:28 PM

Posted 15 November 2010 - 12:05 PM

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.
10 PRINT "SCUNTHORPE!"(2 TO 5): GOTO 10

#2 OFFLINE   sebt3

sebt3

    PowerFreak Troll, leave him alone

  • Members
  • PipPipPip
  • 2045 posts
  • Local time: 09:28 AM

Donator

Posted 15 November 2010 - 01:15 PM

SDL_Mixer can also be used without the rendering engine if needed and provide everything you asked.

- [ PNDS ] - [ Yactfeau ] -

Spoiler

#3 OFFLINE   ZXDunny

ZXDunny

    Advanced Member

  • Members
  • PipPipPip
  • 1744 posts
  • Local time: 03:28 PM

Posted 15 November 2010 - 03:44 PM

SDL_Mixer can also be used without the rendering engine if needed and provide everything you asked.


Excellent, I'll have a look at that then. Is there a Pandora-friendly ARM version of the mikmod library at all?

D.
10 PRINT "SCUNTHORPE!"(2 TO 5): GOTO 10

#4 OFFLINE   sebt3

sebt3

    PowerFreak Troll, leave him alone

  • Members
  • PipPipPip
  • 2045 posts
  • Local time: 09:28 AM

Donator

Posted 15 November 2010 - 05:00 PM

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.

- [ PNDS ] - [ Yactfeau ] -

Spoiler

#5 OFFLINE   ZXDunny

ZXDunny

    Advanced Member

  • Members
  • PipPipPip
  • 1744 posts
  • Local time: 03:28 PM

Posted 15 November 2010 - 05:17 PM

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.
10 PRINT "SCUNTHORPE!"(2 TO 5): GOTO 10

#6 OFFLINE   sebt3

sebt3

    PowerFreak Troll, leave him alone

  • Members
  • PipPipPip
  • 2045 posts
  • Local time: 09:28 AM

Donator

Posted 15 November 2010 - 05:30 PM

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)

- [ PNDS ] - [ Yactfeau ] -

Spoiler

#7 OFFLINE   ZXDunny

ZXDunny

    Advanced Member

  • Members
  • PipPipPip
  • 1744 posts
  • Local time: 03:28 PM

Posted 22 November 2010 - 12:34 AM

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.
10 PRINT "SCUNTHORPE!"(2 TO 5): GOTO 10

#8 OFFLINE   sebt3

sebt3

    PowerFreak Troll, leave him alone

  • Members
  • PipPipPip
  • 2045 posts
  • Local time: 09:28 AM

Donator

Posted 22 November 2010 - 01:06 AM

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.

- [ PNDS ] - [ Yactfeau ] -

Spoiler

#9 OFFLINE   ZXDunny

ZXDunny

    Advanced Member

  • Members
  • PipPipPip
  • 1744 posts
  • Local time: 03:28 PM

Posted 22 November 2010 - 01:28 AM

I've only seen mac and windows download on their web site.


http://www.un4seen.c...g59533#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.
10 PRINT "SCUNTHORPE!"(2 TO 5): GOTO 10

#10 OFFLINE   sebt3

sebt3

    PowerFreak Troll, leave him alone

  • Members
  • PipPipPip
  • 2045 posts
  • Local time: 09:28 AM

Donator

Posted 22 November 2010 - 01:36 AM

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.

- [ PNDS ] - [ Yactfeau ] -

Spoiler

#11 OFFLINE   j0n

j0n

    Advanced Member

  • Members
  • PipPipPip
  • 103 posts
  • Local time: 02:28 PM

Posted 13 April 2011 - 07:35 PM

OpenAL?

#12 OFFLINE   ZXDunny

ZXDunny

    Advanced Member

  • Members
  • PipPipPip
  • 1744 posts
  • Local time: 03:28 PM

Posted 13 April 2011 - 09:59 PM

OpenAL?


No need - I'm running BASS on the Pandora now, and it seems to work just fine :)

D.
10 PRINT "SCUNTHORPE!"(2 TO 5): GOTO 10

#13 OFFLINE   smcameron

smcameron

    Member

  • Members
  • PipPip
  • 14 posts
  • Local time: 08:28 AM

Posted 02 June 2011 - 02:25 AM

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.o.../wwviaudio.html

depends on ogg_to_pcm, which is here:
http://ccan.ozlabs.o...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

#14 OFFLINE   klapse

klapse

    Advanced Member

  • Members
  • PipPipPip
  • 986 posts
  • Local time: 03:28 PM

Posted 16 September 2012 - 12:26 PM

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.





#15 OFFLINE   torpor

torpor

    Advanced Member

  • Members
  • PipPipPip
  • 1036 posts
  • Local time: 03:28 PM

Posted 17 September 2012 - 11:34 AM

wwviaudio is a hoot! ;)

#16 OFFLINE   Pickle

Pickle

    Advanced Member

  • Members
  • PipPipPip
  • 1056 posts
  • Local time: 09:28 AM

Posted 17 September 2012 - 01:45 PM

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.


You can allocate more channels in SDL_mixer with Mix_AllocateChannels

http://sdl.beuc.net/...llocateChannels

#17 OFFLINE   Steven Craft

Steven Craft

    Advanced Member

  • Members
  • PipPipPip
  • 566 posts
  • Local time: 03:28 PM
  • LocationChester, Cheshire, UK

Posted 24 September 2012 - 03:58 PM

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
KAMI RETRO for Pandora: now available on the repository || Aliens vs Predator Pandora port: now available on the repository


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users