In-Game Music Playing

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
mICrO
Posts: 25
Joined: Mon Oct 17, 2005 2:48 am
Location: Madrid (Spain)

In-Game Music Playing

Post by mICrO »

Hello,

I still working in my cross platform gane engine, MGE; and things going quite well.

I finally end the wav mixer, and thins gooing well, at that point I must explain how I done it.

I look after how things are done in other psp sources, like the port of mikmod lib, and I don really like it. Mainly all librarys use just one PSP real audio channel and they done the mixing by they self, output buffer its allways stereo channel. I supose that if I use several psp channel to mix my samples will be faster.

I look about pspsdk pspaudio pre-ready audio code, those about callbacks, and I din't like either, becouse the channels must be allways stereo, and the use a buffer that must be filled each time, just coping from the original sample, I don't wan to copy the data twice, since I could ouput just a pointer, withouth copy.

So I made my mixer from scratch.

I made several threads that take care about output sample data, and sleep if the dont need to output nothing, on those 8 channels they will be asing samples, and a pointer cycle through originall sample data, until the last chunk that use a temp buff to fille with no-sound until output size ( I choose 1024 samples). Those channels also change mode (stereo / mono) if they samples arte stereo or mono. Becouse all mixing are in 44100, I resample the sound in memory to that frequency, then I just output blockin sound, quite fast, and not need to resample at output time.

So I have just outogoig block pointer and few memset, some times.

All works fine, I ported as well to windows using Direct Sound, and things gone, sound perfect, low cpu usage, only one bad thing I could only have 8 sounds playing, but that its enough for most games, I use a algorithm to recycle old channels.

So , now it's time to music, so I decided tu used OGG and try libTremor.

I code everything, and the realize that sound with gligtches, I figured why, mainly it's no acurrente, soo I check how I build libTremor, and my source, I use several optimization like fast_math, O3, etc, soo y return to libTremor normal things, -O2 -signed-char, etc, and then I realize that It's take more time to uncompress a chun, that the psp playing it, when I have all my graphics stuff behind, I try to pre-buffering, but don't help much.

So, I Wonder if anyone has test libtremor with a game, becouse its seens to be good enough to make a player, but to much cpu for a game.

Finally : ¿Wich its the best alternative?
¿Does anyone use music in they games?

Maybe I could use mikmod, then put all my mixing code to the recycle bin, and then use .xm files, but my actual musician it's very good but don't know about mod-tracking :-(, maybe try to find other musician, maybe call mod-tracking friends. I hope that mikmod music rendering its has a low cpu usage.

Maybe mp3 decoding its faster, any one try?

Maybe its posible tu use some prx to uncompress mpeg audio, some how, our psp could do that by hardware?, any clue?

Does anyone have any sugestions?

To much coding a few advance

Note : I dont have my code here, I'm at work rigth now, so I coulnd't post anything.
Last edited by mICrO on Mon Nov 14, 2005 9:57 pm, edited 1 time in total.
mICrO^NewOlds
ja_medina at hotmail dot com

There is no such thing as a moral or an immoral book.

Books are well written or badly written.
(Oscar Wilde)
User avatar
ReKleSS
Posts: 73
Joined: Sat Jun 18, 2005 12:57 pm
Location: Melbourne, Australia

Post by ReKleSS »

Tremor was set to low accuracy because it was being used to port noiz2sa to psp - otherwise it was even slower and more unusable. As it is, it's still not that good. One solution will be to move audio decoding to the second cpu, but I don't think any progress has been made on that just yet. For now, your only options seem to be to use mikmod or just to wait. Hardware decoding hasn't been figured out, but that should be capable of mp3 and atrac3 decoding.
-ReK
User avatar
outtony
Posts: 26
Joined: Thu Oct 13, 2005 2:46 am
Location: Slovakia
Contact:

Post by outtony »

mp3 decoding is slow, as far i read on this forum
-----------------------------
Tony

www.n3.sk
mICrO
Posts: 25
Joined: Mon Oct 17, 2005 2:48 am
Location: Madrid (Spain)

Post by mICrO »

I reply myself.

Finally I finded that I was doing wrong, I optimize a bit the code, using cache reading of the file in memory, and something related to threads, and Its work.

Now I got a music / wavs system with nice cpu usage.

Chears alls.

Thanks to Jare^Iguana, he give me the clue, and Bakterry^Chanke for support!.

Note : Scene coders allways the bests
mICrO^NewOlds
ja_medina at hotmail dot com

There is no such thing as a moral or an immoral book.

Books are well written or badly written.
(Oscar Wilde)
patpsp
Posts: 31
Joined: Tue Oct 25, 2005 5:24 pm

Post by patpsp »

Can you share your work to play ogg and wave files ?
dbeyer3069
Posts: 81
Joined: Mon Dec 19, 2005 4:09 pm

wavloader

Post by dbeyer3069 »

patpsp,

I downloaded an app "wavloader.zip" which I did get to compile (I had to change one line of code dealing with a callback that had different params than the latest pspsdk libraries...) but it works. I am going to reuse that logic in my app. It played the wav files fine. I don't like the wav as much though as they are bigger. The MP3s appear to have a drawback of performance. There appear to be tradeoffs everywhere.

The MIDI has a nice small footprint but I haven't heard of any support for that.

If you need it and can't find it, feel free to email me and i'll send the zip file to you. I know it works.

David Beyer
mICrO
Posts: 25
Joined: Mon Oct 17, 2005 2:48 am
Location: Madrid (Spain)

Re: wavloader

Post by mICrO »

Playing MIDI its easy in a sound card that have some MIDI synthesizers bultin, like those with an wide common MPU-401 interface and OPL2 (FM) support, but, as far as I now, PSP don't have any chipset to generate synth music, just to uncompress ADPCM , AC3 and so on.

So if you want MIDI you mast make your on synth, using samples to make a wave table, and program all MIDI commands. In fact,Timidity, a good software MIDI synth, has been ported to PSP and you could use to play MIDI, but with some CPU % usage as well.

dbeyer3069 wrote:patpsp,

I downloaded an app "wavloader.zip" which I did get to compile (I had to change one line of code dealing with a callback that had different params than the latest pspsdk libraries...) but it works. I am going to reuse that logic in my app. It played the wav files fine. I don't like the wav as much though as they are bigger. The MP3s appear to have a drawback of performance. There appear to be tradeoffs everywhere.

The MIDI has a nice small footprint but I haven't heard of any support for that.

If you need it and can't find it, feel free to email me and i'll send the zip file to you. I know it works.

David Beyer
mICrO^NewOlds
ja_medina at hotmail dot com

There is no such thing as a moral or an immoral book.

Books are well written or badly written.
(Oscar Wilde)
mICrO
Posts: 25
Joined: Mon Oct 17, 2005 2:48 am
Location: Madrid (Spain)

Post by mICrO »

I'll do in some point, but not now, and even then, Its quite complicate extract only that part from the hall engine, because I used my own channel mixer, with separte thread, and use of all hardware audio channels, so quite complicated.

Maybe you could check at the svn (web version) the PSPMediaCenter, play a wide kind of formats, include wav and ogg.

PSPMediaCenter
patpsp wrote:Can you share your work to play ogg and wave files ?
mICrO^NewOlds
ja_medina at hotmail dot com

There is no such thing as a moral or an immoral book.

Books are well written or badly written.
(Oscar Wilde)
Post Reply