Need some help with Game Music Emu

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

Post Reply
User avatar
Ikki666
Posts: 5
Joined: Thu May 16, 2013 8:25 am

Need some help with Game Music Emu

Post by Ikki666 »

Hello everyone!
I'm working on a project, built in AS3, that will look and sound like a very early NES game. I'm using palette and sprite limitations, trying to stay as close as possible to something from that era and that hardware. At first I used prerecorded sound and music, but since I'm trying to get a small final swf, I decided to check if it was possible to play nsf files on as3 and found a port of Game Music Emu by Blargg compiled as a swc library via adobe Alchemy. Then I created a nsf file that contains music and sfx. When using this nsf, I cannot get music and sfx to play at the same time; whenever I play some sound, music stops. I've tried different approaches (separating music and sfx on different nsf files, creating multiple instances of the gme library, and a combination of both) but nothing works. The moment the sound starts playing, the music stops. If anyone is familiar with Game Music Emu (on flash or otherwise), I'd really appreciate the help.
Last edited by Ikki666 on Thu May 16, 2013 2:23 pm, edited 1 time in total.
User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Re: Need some help with Game Music Emu

Post by blargg »

GME plays NSF files, which only support one track playing at a time. You'd need to run two instances of GME if you want sound effects at the same time. Though, I didn't do the swf porting, so maybe the author did something to help with sound effects (I vaguely remember an email about this issue, but can't find it offhand in my mailbox).
Shiru
Posts: 1161
Joined: Sat Jan 23, 2010 11:41 pm

Re: Need some help with Game Music Emu

Post by Shiru »

Is there something that prevents playing music as NSFs using GME, but playing prerecorded sound effects as MP3? Prerecorded sound effects shouldn't take much room, and storing the music in NSF would save a lot of room alone.
User avatar
Ikki666
Posts: 5
Joined: Thu May 16, 2013 8:25 am

Re: Need some help with Game Music Emu

Post by Ikki666 »

First of all: Blargg, your libraries are absolutely awesome! Thanks for sharing such a really great work!

Now, about the nsf playing issue: I've tried using two instances of gme, playing each a copy of the nsf file, or playing each a different nsf file (one with music, and one with sfx). Neither approach is working. When loading two copies of the same file, I get the same original error (that is, music stops after the first sfx plays). When I use two different nsf on two different instances of gme, only the audio of the last loaded file plays. I'll recheck all my code to see if I've done something wrong, cause I understand some games (Super Mario Crossover comes to mind) managed to do all of the audio with nsf files. Anyway, if I can't make it work, I'll probably try using nsf for music and prerecorded for sfx, like Shiru suggests. Thx a lot for your answers, I'll post my results if I can make this thing work.

(Please, excuse if my english is not very good, it's not my native language)
Grapeshot
Posts: 85
Joined: Thu Apr 14, 2011 9:27 pm
Contact:

Re: Need some help with Game Music Emu

Post by Grapeshot »

In order to make this sound completely authentic, you would have to modify the NSF driver you are using (I assume Famitracker's) to store both the music and sound effect that is playing and support channel stealing to only drop certain channels out of the music while the sound effect plays.

Using WAV files for sound effects and muting the corresponding sound channel in Game Music Emu would be much easier.
User avatar
Ikki666
Posts: 5
Joined: Thu May 16, 2013 8:25 am

Re: Need some help with Game Music Emu

Post by Ikki666 »

I am using Famitracker, but I've just started using it. In fact, I've never composed any music or sound, this is a first. I'm using three channels for music (pulse1, triangle and noise), leaving one channel for sfx (the sfx tracks are all composed on pulse2). When you say 'modify the driver' are you refering to source code, or can it be done on the software as an option before exporting nsf?
User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Re: Need some help with Game Music Emu

Post by blargg »

Grapeshot wrote:In order to make this sound completely authentic, you would have to modify the NSF driver you are using (I assume Famitracker's) to store both the music and sound effect that is playing and support channel stealing to only drop certain channels out of the music while the sound effect plays.
...and write a custom emulator for it, since NSF doesn't allow any communication with the player, and clears memory when starting a new track.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Need some help with Game Music Emu

Post by tepples »

blargg wrote:...and write a custom emulator for it, since NSF doesn't allow any communication with the player
The custom emulator need not be written from scratch. It should be possible to extend NSF to establish a page of shared memory ($0700-$07FF?) between the NSF player and the program using it, so long as the code in the NSF is aware of the shared memory.
User avatar
Ikki666
Posts: 5
Joined: Thu May 16, 2013 8:25 am

Re: Need some help with Game Music Emu

Post by Ikki666 »

Since I don't think I'm skillful enough to mess with emulator code, I settled for checking all the as3/alchemy compilation mess. I'm not really sure, but I believe that all instances of the gme library create static emulators (in flash at least). Anyway, I solved my problem in a very simple way: linking two different swc of gme to my project. Now it works wonderfully. Is not a good solution, since it requires recompiling gme with alchemy into two different swc libraries that work in exactly the same way, but are in different packages, and it takes more space on the final swf than it should (but can be reduced by using just the nsf part of gme). I'll keep trying to find a better solution. Thx for all your answers.
steveswl
Posts: 4
Joined: Sun Aug 25, 2013 3:38 pm

Re: Need some help with Game Music Emu

Post by steveswl »

I know this post is old, but there's a version of GME that now uses FlasCC / CrossBridge. You can find it at https://github.com/mcannizz/gme-flascc

It uses SWIG and is much faster than the GME Alchemy SWC from https://code.google.com/p/game-music-emu-flash/ assuming that's where you got the SWC from.
User avatar
Ikki666
Posts: 5
Joined: Thu May 16, 2013 8:25 am

Re: Need some help with Game Music Emu

Post by Ikki666 »

Great news! Thx for the reply. I'll check this version of gme as soon as possible.
Post Reply