Questions about the Echo sound engine

Talk about development tools here

Moderator: BigEvilCorporation

Post Reply
djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Questions about the Echo sound engine

Post by djcouchycouch » Tue Jul 03, 2012 3:50 pm

Hi,

Something for Oerg! :)

I've finally started to look at playing music and sound effects for Goplanes. From what I can find around the community, Echo seems to fit my current needs enough to merit more in-depth investigation. Being a total n00b about sound stuff, I had some basic questions:

- does it support whatever TFM and VGM trackers output?
- do sound effects play on the genesis sound chip or the mastersystem sound chip? both?
- how do I create sound effects for playback? (ie how do I make explosions, cannon fires, riccochets, etc. etc)? Which tools are available to do that?
- does the system run independently in parallel to the 68000 or does it need to be update every frame ?
- to clarify, does the code license permit me to use Echo without having to release my own source code?

Thanks!
DJCC

Oerg866
Very interested
Posts: 211
Joined: Sat Apr 19, 2008 10:58 am
Location: Frankfurt, Germany
Contact:

Post by Oerg866 » Tue Jul 03, 2012 5:36 pm

- does it support whatever TFM and VGM trackers output?

Not at this time, because the two formats are so different. My tool "xm2esf" takes any XM tracker output though, and converts it quite accurately.


- do sound effects play on the genesis sound chip or the mastersystem sound chip? both?

Both! All channels can be used by both BGMs and SFX :)


- how do I create sound effects for playback? (ie how do I make explosions, cannon fires, riccochets, etc. etc)? Which tools are available to do that?

Effectively the same as you make regular songs. Xm2esf's GUI allows to set the mode to SFX. You don't have any additional work this way.


- does the system run independently in parallel to the 68000 or does it need to be update every frame ?

The sound system runs only on the Z80, the 68k is completely independent on it, so no CPU time is lost. It runs completely on its own.

- to clarify, does the code license permit me to use Echo without having to release my own source code?

Yes.


Cheers!
Eric

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Tue Jul 03, 2012 5:49 pm

What would be your recommended/favorite tracker program?

Oerg866
Very interested
Posts: 211
Joined: Sat Apr 19, 2008 10:58 am
Location: Frankfurt, Germany
Contact:

Post by Oerg866 » Tue Jul 03, 2012 6:03 pm

djcouchycouch wrote:What would be your recommended/favorite tracker program?
OpenMPT ;)

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Tue Jul 03, 2012 6:51 pm

Oerg866 wrote:
djcouchycouch wrote:What would be your recommended/favorite tracker program?
OpenMPT ;)
What's your typical workflow for creating and bringing sounds into your project? Can you describe it? Straightforward? Complex?

Oerg866
Very interested
Posts: 211
Joined: Sat Apr 19, 2008 10:58 am
Location: Frankfurt, Germany
Contact:

Post by Oerg866 » Wed Jul 04, 2012 12:24 pm

I make an XM file with fixed channel layout and try to make something that sounds good. if it does sound to my liking, i start making the MD version of it with xm2esf. It's quite simple.

http://projectmd.mdscene.net

I made the entire game's soundtrack like that.

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Wed Jul 04, 2012 12:53 pm

After converting the song with xm2esf, how would it be imported/compiled into my SGDK-based project? How do I refer to the data so I can pass it to Echo's functions?

Oerg866
Very interested
Posts: 211
Joined: Sat Apr 19, 2008 10:58 am
Location: Frankfurt, Germany
Contact:

Post by Oerg866 » Wed Jul 04, 2012 4:28 pm

djcouchycouch wrote:After converting the song with xm2esf, how would it be imported/compiled into my SGDK-based project? How do I refer to the data so I can pass it to Echo's functions?
Before using xm2esf, you must gather all samples, psg envelopes and FM instruments you intend to use, and build an instrument pointer list. the code will show you that.

After that, make all the channel and instrument assignments.

Make sure you got the loading code in and everything like the sgdk example shows you,a nd just call the play functions with the pointer to the included songdata as argument. It's not complicated once you really grasp what's going on ;)

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Wed Jul 04, 2012 8:18 pm

Oerg866 wrote: Make sure you got the loading code in and everything like the sgdk example shows you,
Which loading code and sgdk example would those be?

Oerg866
Very interested
Posts: 211
Joined: Sat Apr 19, 2008 10:58 am
Location: Frankfurt, Germany
Contact:

Post by Oerg866 » Thu Jul 05, 2012 10:46 am

djcouchycouch wrote:
Oerg866 wrote: Make sure you got the loading code in and everything like the sgdk example shows you,
Which loading code and sgdk example would those be?
The SGDK kit should have some explanations in it (as comments in the source files, iirc)

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Sat Jul 07, 2012 4:33 pm

Spent a little bit of time on this. I did not know how to import random data files into my rom, which was the problem I was trying to explain. But I clued in once I saw how SGDK's makefile.gen does it for .tfc files. It uses the bintos.exe tool to generate a .h and a .s file. So I'll just do the same for the Echo files.

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Sun Jul 08, 2012 2:28 am

Looking at the sample music and instruments in the echo package, how do I figure out which instruments a music track uses? I have no original songs yet, so I'd like to try out those samples.


Also, a small thing, the header file doesn't declare the echo_init() function. From the version I have, anyway. It wasn't clear how to use the instrument list until I found that function in the .c file.

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Sun Jul 08, 2012 6:55 pm

Managed to get some sound. Here's how I got there.

Assets:

I assumed the test-piano.esf song was using the piano.eif instrument. Not much of a stretch, I know. I hoped that it only used one instrument. I have no idea what happens if you specify the wrong number of instruments (too many or too few) when attempting to play a song.

SGDK:

- To add those files to the project compilation, I added these parts to SGDK's makefile.gen. Should be obvious where to add them in the file.

Code: Select all

RES_EIF= $(wildcard *.eif)
RES_EIF+= $(wildcard $(RES)/*.eif)
RES_ESF= $(wildcard *.esf)
RES_ESF+= $(wildcard $(RES)/*.esf)

...

OBJ+= $(RES_EIF:.eif=.o)
OBJ+= $(RES_ESF:.esf=.o)

... 

%.s: %.esf
	$(BINTOS) -align 32768 $<
	
%.s: %.eif
	$(BINTOS) -align 256 $<	

As for the alignments, they're guesses based on the other types of resources in the makefile. If they require other/better values, let me know.

- SGDK's bintoc/bintos blindly take the filename and create type names with it. I had to rename the test-piano.esf to testpiano.esf because "test-piano" isn't a valid variable name.

Code:

- SGDK's makefile.gen only looks for a few spots for code. I wanted to keep Echo's code separate, but I had to bring it into the same folder as my project. No biggie.

- SGDK does not support <stdint.h> and uses its own types. Had to typedef the types that Echo required. If the SGDK had a define to identify itself (#define SGDK ?), Echo could simply check for it and adjust its types accordingly.

- The ECHO_LIST_* macros don't work, giving errors like:
main.c:67: warning: initializer element is not computable at load time
main.c:67: error: initializer element is not computable at load time

From what I could find, some versions of C support it while some don't. The version specified by default in SGDK does not.

So I had to build the array manually.

Code: Select all

    unsigned char instrumentList[4];
    instrumentList[0] = (((u32)piano >> 8) & 0x7F) | 0x80;
    instrumentList[1] = (u32)piano & 0xFF;
    instrumentList[2] = (((u32)piano >> 15) & 0x7F) | (((u32)piano >> 16) & 0x80);
    instrumentList[3] = 0x00;
- echo_init has an infinite loop when it tries to copy the echo_blob. The "count" variable never gets decremented.

- Just to repeat, the echo_init function decleration isn't in the header file.


Running:

- The music plays in Gens and on hardware. Quite happy about that.

- The music plays even during scene transitions where I reload a fair bit of data. Also quite happy about that. SGDK's TFM playback required calling a function every frame and scene transitions were too slow to keep the music from stuttering.

- The initialization of Echo creates a short burst of static noise on both emulator and hardware. Unsure if that's normal. I'd say not.

Next Steps:

To create original music.

- If I understood correctly, Echo can play music on both the genesis and master system sound hardware at the same time. How do I setup tracks in OpenMPT to do that? Are there any example files I can look at? I've tried searching for mod/xm/whatever files that would be specific to the genesis, and formatted so that they can be used for Echo, but I have not found any.

Post Reply