GP32 Alternative To The Sdk Soundmixing ?


ConsoleTom

Member
Joined
Dec 4, 2003
Messages
106
Age
47
Location
Germany
Website
Visit site
Hi !

Can anyone help me how i can get an own soundmixing routine ?

I need the possibility to play sounds in different volume levels and more than 4 channels (8 would be best).

Or is someone working on something like that or has a library i could use ?

Greetings

Tobias
 
You can use CHN's modlib

28 channels maxi for sound effect with volum control possibility for all sample or channel (depend of your code)

One limitation is 8bit sample
 
Hey, jycet, do you have some example code to show me how to use the sound channels on chn's modlib ???
 
Mixing is easy.

Work across buffers; a+b+c/numchannels

ie: If you have 7 channels mixing now, add 'em up and divide by 7. (Theres other averaging methods, but thats a basic workable one.)

Thats it; thats all a basic mixer does.

Ie: Its more complex if youhave to mix 8bit and 165bit samples together, and if some are signed and others usngiend, since you ave to convert; but if aqll your samples are the same shape/size then its just that easy; if they're different, then you can convert them all to 16bit at load time, or at mix time; ie; 8bit to 16bit is just shift-8 to get them into thre same size..

So really not too hard.

I keep a struct of sample playback and progress, and a list of samples; so adding to my mixer just creates a struct which points to which sample it represents, and how far along it is, and options (fade, etc.)

Then the mixer runs throgh the list of all currently playing samples, mixing their current step, and incrementing the step count. (At load time I convert all samples to the same bits-per-second, 16bit, so that I needn't woryr about stretching 11khz to 22khz live, etc.)

So mine has no limit channels.. it cna mix 100 samples if it wants, though in practice I cap it off around 4 or 5, and most of my little games just don't have that much going on.

Then I mix with background audio afterwards.

Not so hard :)

jeff
 
Hey Jeff, I have been looking into mixing a lot recently, though I also need to transpose the sounds to make notes, and found it quite difficult. But from your description it looks as easy as eating an ice-cream, I wish I knew coding like you ;)
 
@mATkEUpON
Yes you can download my source of my last Flipit here:
http://anthologie.emu-france.com/projets.htm
There're some little comment in french ... but I think you understand the french ;)
Chn's lib is a mod lib but with the very good quality of mixer you can use it only for sound effect, example in Aka Noid I use only sound effect for the game, no mod :)
 
Mixing is easy.

Work across buffers; a+b+c/numchannels

ie: If you have 7 channels mixing now, add 'em up and divide by 7. (Theres other averaging methods, but thats a basic workable one.)

Thats it; thats all a basic mixer does.

I would suggest clamping instead of dividing for a much better sound quality.
 
Last edited by a moderator:
Clamping?

You mean take the max of the current moments samples?

I've not bothered to try the various approaches.. I just average; maybe I should experiment :) (some people average the samples beside the current one, or do other heuristics..)

jeff
 
Yes, dividing the added channel "values" by the actual number of channels isn't a good idea for one reason: you'll get a reduced volume in the end mix. Clamping (at least the understanding that I have of clamping, which would equal an compressor in the real audio world) adds those volumes up and keeps the result from distorting by using some clever calculations (never done this actually, so I can't give details, maybe spivvy got something for you).
 
Back
Top