gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Audio > Suggestions for replacement sound engine for OpenPok

#146805 - Kyoufu Kawa - Sun Dec 09, 2007 2:31 pm

So yeah, I just came back from the search page and decided to post this.

OpenPok? started development on a pirated copy of the official Nintendo devkit. I admit this now because we've switched to devkitpro several months ago. The only thing left, besides some glue, is the music engine.

This engine, colloqually known as Sappy, M4A for short, uses converted MIDI files as source data. MIDI file goes in, gets the shit optimized out of it where possible (hello drumloop!), delta timing is replaced with wait commands etc. Instrument banks, here called voice groups, are linked to the song data allowing small sets that can be shared among songs.

It also plays sound effects by mixing in a second "song" which can have its own voice group.

OpenPok? plays monster cries like Pok?mon does: generate a short song in RAM and assign a small voice group with only one item to it, that item being the cry.

Problem is, aside from being illegal, that it's not very friendly to the average hobbyist.

My question is, what sound playback system can you guys suggest OpenPok? to use? It must be free and allow sound effects, preferably as described above.

Your assistance is appreciated.


[Subject Fairy was here]

#149218 - Kyoufu Kawa - Wed Jan 16, 2008 9:35 pm

I'm serious, you guys...

#149222 - DiscoStew - Wed Jan 16, 2008 10:22 pm

Kyoufu Kawa wrote:
...aside from being illegal...


Wouldn't this be enough to not discuss it? We're glad you made the switch from illegally obtained software to what we all use, but since that sound engine is still part of the Nintendo devkit, discussing it (let alone even having it without permission) could bring about severe consequences to the community if we get involved.

Just like talking about commercial roms, it would be a very bad idea.
_________________
DS - It's all about DiscoStew

#149280 - Kyoufu Kawa - Thu Jan 17, 2008 8:19 pm

Yeah, I think you misread (part of) my story: I'm looking for something to replace that last illegal part with something legal. There's just certain criteria to it.

#149282 - gauauu - Thu Jan 17, 2008 9:46 pm

I find it slightly confusing which parts of your description are just description of how you do it now, and which parts are your criteria for evaluating new engines.

It seems like most of the audio engines we see for gba (OpenPoke is gba, not DS, right?) are basically mod players. Does your question imply that a basic mod player with the ability to include sound effects doesn't meet your needs?

#149285 - Kyoufu Kawa - Thu Jan 17, 2008 10:14 pm

You're right. Let me restate this.

I need a music player for the GBA.

Most of all, it should be user-friendly.
MIDI or MOD doesn't matter much.
Sound effect capability is a must.
The possibility to fade out the main track and overlay a short jingle would also be cool.*

Having a central instrument pool like MIDI does is a good thing as opposed to MOD files having their own pools.

It shouldn't require GBFS or whatever. Just binaries linked into the ROM and called by labelled pointer. What I intend to have is a big list of pointers to all the tracks so you can call them by number and/or #define'd ID.

* if you ever got an item or monster in the original games, you'll know what I'm going at here.

Edit: so yeah, it doesn't imply such.

#149287 - gauauu - Thu Jan 17, 2008 10:33 pm

I found that Kusma's Pimpmobile works well. I had to get a couple of tweaks to his standard code from him to make it do sound effects, and it doesn't do any fancy stuff (not sure if it could do your fadeout jingle thing).

It's smart enough to not include samples from your mod files (XM files, technically) twice if they are the same sample included in multiple files. So that's good.

But I'm sure there's a lot else out there that works as well (or better).

Edit: I was going to include a link, but I can't seem to find a working one...

#149291 - dantheman - Thu Jan 17, 2008 11:42 pm

The "MOD Players" section of http://members.iinet.net.au/~freeaxs/gbacomp/ may help out. All the code is for DevKitAdv, not DevKitARM, but at least it's a starting point.

#149298 - kusma - Fri Jan 18, 2008 12:49 am

gauauu wrote:
Edit: I was going to include a link, but I can't seem to find a working one...

Yeah, I'm sorry about that. The site is still http://pimpmobile.kjip.no/, but there's some problems with the host's ISP. I'm a bit tempted to move the project to sourceforge.net just for stability's sake.

#149345 - Kyoufu Kawa - Fri Jan 18, 2008 8:14 pm

Well, Pimpmobile sounds good enough. If you (Kusma?) can get the missing features in, which I doubt I could do myself, that'd be great.

Until then, I'm gonna take a look at that page dantheman linked.

#149351 - kusma - Fri Jan 18, 2008 9:08 pm

Kyoufu Kawa wrote:
Well, Pimpmobile sounds good enough. If you (Kusma?) can get the missing features in, which I doubt I could do myself, that'd be great.

Sure, what exactly do you want? Will volume-control (which is already kind of there) and pause (which shouldn't be too hard), plus the ability to swap the modules that use the mixer do for the jingle-support? The idea was to just set the volume a step down each frame, and when it reaches zero, you pause, play another module, and resume...
Sound effect support is also "kind of" there (you can program the mixer directly), but I haven't decided yet if I want a "public" interface to that or not. There's already a shared sample-bank (or sample pool) to save space if all modules are converted in one go (you would usually make this a step in your makefile anyway), and there's no requirement for anything special when loading, apart from 32bit alignment of the data in the GBA ROM.

Oh, and a lot of improvements has happened to the library, but it's not released yet. I never told anyone where to find the SVN before now, but here you go. As said before, the server is quite unstable at the moment, so you'll probably give it a few attempts to manage to check it out.

#149406 - Kyoufu Kawa - Sat Jan 19, 2008 8:19 pm

Yeah, in the original the main track just continued to play on mute so if you whistled along you'd stay aligned when the jingle finished. This is not a problem though. Too minor to care.

Sound effects used to be short pieces of song data, but I guess... prerendering them (by lack of better term) wouldn't cause things to sound very different, and monster cries should be a cakewalk from there.

What I do somewhat care about is what Pimpmobile is written in. ASM? C? C++?

#149435 - gauauu - Sun Jan 20, 2008 1:08 am

kusma wrote:

Sound effect support is also "kind of" there (you can program the mixer directly), but I haven't decided yet if I want a "public" interface to that or not.


Just out of curiosity, why wouldn't you make it public? It seems to be a pretty standard feature for a sound engine....

#149436 - kusma - Sun Jan 20, 2008 1:26 am

gauauu wrote:
Just out of curiosity, why wouldn't you make it public? It seems to be a pretty standard feature for a sound engine....

Because a public interface is a bigger support-burden, and before I'd like to tie the interface, I'd prefer having a proper channel-allocator or something. Perhaps I'm just over-thinking things, though...

#149479 - Kyoufu Kawa - Sun Jan 20, 2008 9:53 pm

But what is it written in? ASM, C or C++?

#149480 - thoduv - Sun Jan 20, 2008 10:04 pm

Kyoufu Kawa wrote:
But what is it written in? ASM, C or C++?

Sources are available.
It's pure C, plus an optimized ARM mixer.

#149528 - Kyoufu Kawa - Mon Jan 21, 2008 7:32 pm

Well, thanks and excuse me. That's the answer I was hoping for, and the SVN was unreachable when I tried so I couldn't see.

Let's try again... nope, nothing but a white screen. I'm willing to blame proxies beyond my control, though. I'll try again when I'm home.

#149545 - DiscoStew - Mon Jan 21, 2008 10:06 pm

Kyoufu Kawa wrote:
Yeah, I think you misread (part of) my story: I'm looking for something to replace that last illegal part with something legal. There's just certain criteria to it.


Sorry, my mistake. I think I got more focused on that you told us what that audio engine did, and therefore my "illegal" light came on.
_________________
DS - It's all about DiscoStew

#149614 - Kyoufu Kawa - Tue Jan 22, 2008 8:35 pm

My mistake as well. No harm done?

#149621 - tepples - Tue Jan 22, 2008 9:05 pm

I'll call the Subject Fairy to make things clearer.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#149632 - kusma - Tue Jan 22, 2008 10:40 pm

allright, now the pimpmobile project have been moved to sourceforge. Go here to find it.

#149636 - Lord Graga - Wed Jan 23, 2008 3:14 am

How come that I see several / and % operators in the code? The compiler started handling them well?
What's with all the floating point? :P (1.0 / (SAMPLERATE))

Oh, and how can this compile into one instruction?

/* BEHOLD: the expression of the devil 2.0 (this compiles to one arm-instruction) */
const unsigned int scale = (unsigned int)(((1.0 / (SAMPLERATE)) * (1 << 6)) * (1LL << 32));
delta = ((long long)delta * scale + (1ULL << 31)) >> 32;


*looks around confused and slightly amazed*

And another one:

Code:

00000018 <__pimp_get_linear_delta>:
.....
  54:   e3a07102    mov   r7, #-2147483648   ; 0x80000000
  58:   e3a08000    mov   r8, #0   ; 0x0
  5c:   e0955007    adds   r5, r5, r7
  60:   e0a66008    adc   r6, r6, r8
  64:   e3a04000    mov   r4, #0   ; 0x0
  68:   e1a00006    mov   r0, r6
  6c:   e8bd01f0    ldmia   sp!, {r4, r5, r6, r7, r8}
.....

Is there something that I am misunderstanding, or couldn't the compiler just skip out setting r7 to 0x80000000 and do adds r5,r5,#0x8000000 instead of offset 5C?


Last edited by Lord Graga on Wed Jan 23, 2008 3:26 am; edited 1 time in total

#149639 - eKid - Wed Jan 23, 2008 3:26 am

Lorg Graga wrote:
What's with all the floating point? :P (1.0 / (SAMPLERATE))

It's a constant expression casted to unsigned int...

Lorg Graga wrote:
/* BEHOLD: the expression of the devil 2.0 (this compiles to one arm-instruction) */
const unsigned int scale = (unsigned int)(((1.0 / (SAMPLERATE)) * (1 << 6)) * (1LL << 32));
delta = ((long long)delta * scale + (1ULL << 31)) >> 32;

It can probably be done with ARM's multiply long instructions. But I would think there would be at least another instruction to load the 'scale' constant into a register?


Last edited by eKid on Thu Jan 24, 2008 3:28 pm; edited 1 time in total

#149647 - kusma - Wed Jan 23, 2008 10:46 am

Lorg Graga wrote:
What's with all the floating point? :P (1.0 / (SAMPLERATE))

As eKid points out, it's all a constant expression that the compiler is allowed to (and does - we've checked the generated assembly) constant-fold.

eKid wrote:
It can probably be done with ARM's multiply long instructions. But I would think there would be at least another instruction to load the 'scale' constant into a register?

Correct. This isn't a THAT critical function anyway, it's only called maximum once per channel per tick. We just wanted to make sure we didn't do something massively stupid / required to link to the floating-point library. By the way, this code has been scheduled to be refactored a bit, so the mixing-rate can be changed at run-time. Once that's done, it might require a run-time evaluation of that expression each time the sampling-rate is changed. Shouldn't be that big of a deal, IMO.

#149680 - Kyoufu Kawa - Wed Jan 23, 2008 8:37 pm

Downloading...

Well, this seems interesting. In a good way.

#150240 - Kyoufu Kawa - Thu Jan 31, 2008 10:06 pm

Would you guys attack me if I said "imitation M4A"?