This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Music engines?

Music engines?
by on (#61448)
What music/sound effect engines are out there?

by on (#61450)
Drag's is the best.

by on (#61451)
Link?

by on (#61483)
No link because the public version isn't finished yet. D:

I'm hoping to get it finished over this summer, since I have 80% less college to worry about. :P

In the meantime, I'm pretty sure there are alternatives coming up if I don't finish mine timely enough.

by on (#61484)
Do you have any details, or even tentative information for us? Memory usage, features, limitations? I'm curious now. :)

by on (#61491)
Here are some statistics for the code as it is this exact moment:

Features:
* Running Note Lengths
* Rests / Do Nothing
* Note Precut
* Volume Envelopes
* Jumps
* Repeats
* JSR/RTS
* Prioritized Sound Effects
* DMC Support
* "Sound Effect Mode" for Music Tracks
* Track Volume Scaling
* Detune
* Pitch Bend
* Pitch Envelopes

Memory usage:
- 18 bytes per channel
--- 8 channels (4 being for music, 4 being for sound effects)
- 8 more bytes for the engine itself
--- 5 of those bytes being in zeropage.
= 152 (0x98) bytes of ram necessary for the engine.

Limitations:
- Code is written for DASM, so to use another compiler, you need to resyntax the code.
- No editor; you write the music data by hand. (Not too unruly in my opinion)

Here's what it sounds like. (These songs aren't supposed to be particularly good or catchy, they're literally just me testing features)

Right now, the code is in alpha stage, so once I finish up a documentation, it'll be ready for a public beta.

by on (#61493)
Wow it looks/sounds really good ! You have all my congratulations.

I have my own sound engine but it's private (and anyway it's kind of optimized for my game). I plan to do a more general purpose sound engine tough.

by on (#61495)
How can I make the Famitracker to Dragnsf converter when everything is private?

by on (#61502)
Digging the Treasure Master triangle wave drums

by on (#61560)
Thanks for the comments, everyone. :D

Dwedit wrote:
How can I make the Famitracker to Dragnsf converter when everything is private?

Honestly, I'd prefer if people didn't rely on [favorite tracker]-to-DNSF converters. In reality, they should be using their favorite tracker (or midi composing program, or whatever) to prototype the songs, and then based off of the sheet music, that's where they create the data for DNSF to use.

The main reason I'm pointing this out is because I don't want people to be disappointed when DNSF doesn't perfectly replicate (or even support) some of the features in Famitracker, because that was never the intention in the first place.

DNSF is DNSF, not "Diet Famitracker", right? :P

and don't worry, DNSF will be public once I move it to public beta. Right now, it's still a private alpha, because I need tidy it up still, which includes writing some form of manual for it. :P

by on (#61562)
Dwedit wrote:
What music/sound effect engines are out there?

Roth wrote:
Drag's is the best.


I'm one of those stuck-on-famitracker guys so my knowledge is certainly limited here, but I'd like to bring up Nijuu-
http://dutycyclegenerator.com/nijuu/nijuu.html

To my understanding it's a resource hog, so you probably don't want it for a game or demo with lots of other stuff going on. I'm lead to believe though that it's a complete beast when you try and focus more solely on the sound capabilities of the NES. From a chiptune perspective, this is a non-famitracker engine that really catches my interest. :) Of course "best" depends on your needs though.

by on (#61578)
Drag wrote:
Honestly, I'd prefer if people didn't rely on [favorite tracker]-to-DNSF converters. In reality, they should be using their favorite tracker (or midi composing program, or whatever) to prototype the songs, and then based off of the sheet music, that's where they create the data for DNSF to use.

That would require 1. a way to export Famitracker modules to LilyPond format (to generate the sheet music) and 2. somebody creating a specialized editor for the data for DNSF to use. People who adopt DNSF for their game projects will have a hard time attracting talented composers without computer programming experience if the only editor for DNSF music is Notepad.

by on (#61580)
tepples wrote:
Drag wrote:
Honestly, I'd prefer if people didn't rely on [favorite tracker]-to-DNSF converters. In reality, they should be using their favorite tracker (or midi composing program, or whatever) to prototype the songs, and then based off of the sheet music, that's where they create the data for DNSF to use.

That would require 1. a way to export Famitracker modules to LilyPond format (to generate the sheet music) and 2. somebody creating a specialized editor for the data for DNSF to use. People who adopt DNSF for their game projects will have a hard time attracting talented composers without computer programming experience if the only editor for DNSF music is Notepad.


I imagine the musician would prototype a song in FamiTracker/whatever and send the file to the programmer. The programmer would open the file and type the song up in DNSF format in a text editor.

by on (#61583)
MetalSlime wrote:
tepples wrote:
Drag wrote:
Honestly, I'd prefer if people didn't rely on [favorite tracker]-to-DNSF converters. In reality, they should be using their favorite tracker (or midi composing program, or whatever) to prototype the songs, and then based off of the sheet music, that's where they create the data for DNSF to use.

That would require 1. a way to export Famitracker modules to LilyPond format (to generate the sheet music) and 2. somebody creating a specialized editor for the data for DNSF to use. People who adopt DNSF for their game projects will have a hard time attracting talented composers without computer programming experience if the only editor for DNSF music is Notepad.


I imagine the musician would prototype a song in FamiTracker/whatever and send the file to the programmer. The programmer would open the file and type the song up in DNSF format in a text editor.


Not necessarily *actual* sheet music, I'm just simply talking about the notes and such. All trackers give you a display which shows you what and where the notes are. Based on that information, you can ready some DNSF music.

In due time, I may get an editor thrown together, since DNSF's general music format isn't solely for NSFs, but also for a couple of other music-related softwares that I've been working on over the years. However, that's not one of my top priorities. Either way, the music format should be easy enough for *anybody* understand, since it's like this:

Code:
E4 01 C5 32 52 72 82 A2 03 23 FF

E4 01 = Use volume envelope 01.
C5 = Set the note length to 6 'ticks'. (C0 being 1 tick, C1 being 2 ticks, etc.)
32 52 72 82 A2 03 23 = Notes; [Semitone][Octave]. Semitone starts with A and ends on G.
This particular string of notes is C2 D2 E2 F2 G2 A3 B3, which is just a regular scale.
FF = End of track (stop playing).


The only tricky thing is the fact that "Semitone 0" is an A, rather than a C. I know that goes against every musical teaching in the world (octaves now increment on As instead of Cs), but it was in the interests of efficiency which lead to this decision.

In the end, if you're comfortable with hexadecimal, you should be fine. :P

by on (#61586)
That looks like coding in machine language. I'm guessing the "assembly language" for this would look a lot like MML. Oh, and I should work on the assembler for my own music engine when I get time; currently, it's just a bunch of constants in ca65 .byt directives.

by on (#61592)
Drag, why not create a series of equates? I did something similar with a music engine like you (before I wrote a script compiler for it).

equates:
http://pastebin.com/raw.php?i=Lpt3QSB4

example of equates:
http://pastebin.com/raw.php?i=Vw108ZdT (the label names are from an automated converter, but they aren't restricted to addresses like that)

by on (#61593)
tomaitheous wrote:
Drag, why not create a series of equates?


This is a good idea to make the data more readable. I used equates to make symbols for all notes, note lengths and opcodes in my NES sound engine tutorials. Some assemblers like ca65 make it really easy with .enum

Instead of random hex values, you get symbols. Sample data from my engine:

Code:
    .byte eighth                            ;eighth notes
    .byte set_loop1_counter, 14             ;repeat 14 times
@loop:
    .byte A2, A2, A2, A3, A2, A3, A2, A3    ;series of eighth notes
    .byte loop1                             ;finite loop (14 times)
    .word @loop                             ;address to jump back to



Hand-entering code will always be tedious, but this makes it a lot easier on the brain.

by on (#61612)
It's totally up to the user whether they want to set that up or not, but I could include a sample one.

by on (#61685)
bucky o'hare wrote:
Dwedit wrote:
What music/sound effect engines are out there?

Roth wrote:
Drag's is the best.


I'm one of those stuck-on-famitracker guys so my knowledge is certainly limited here, but I'd like to bring up Nijuu-
http://dutycyclegenerator.com/nijuu/nijuu.html

To my understanding it's a resource hog, so you probably don't want it for a game or demo with lots of other stuff going on. I'm lead to believe though that it's a complete beast when you try and focus more solely on the sound capabilities of the NES. From a chiptune perspective, this is a non-famitracker engine that really catches my interest. :) Of course "best" depends on your needs though.


Heh, thanks for the vote Bucky :)

Nijuu certainly won't win any awards for it's efficiency but then it does sound like this;

http://dutycyclegenerator.com/sound/Cleptoplank.mp3

That's a straight recording of an NSF outputted by Nijuu and no samples/DPCM.

by on (#61686)
Wow, is this updating more than once per frame?

by on (#61697)
Dwedit wrote:
Wow, is this updating more than once per frame?

I believe so; there was a thread about it.

This so sounds like psychadelic techno. :D

by on (#61700)
Dwedit wrote:
Wow, is this updating more than once per frame?


Yep, about 3 times per frame I think. It was an interesting exercise after I found out that NSF supports multiple speeds :)

by on (#61701)
Man Niju is without a doubt the best NES sound engine so far in therm of possibilities.

by on (#61708)
neilbaldwin wrote:
Dwedit wrote:
Wow, is this updating more than once per frame?


Yep, about 3 times per frame I think. It was an interesting exercise after I found out that NSF supports multiple speeds :)


Is there enough CPU time on a real NES to play back that song?

by on (#61711)
The NTSC NES CPU has almost three myriad cycles per frame. If each iteration takes fewer than 2,500 cycles or 22 scanlines of CPU time per channel, you can run four channels three times per frame. If you really want to hear it on an NES, port the playback engine to MMC3 and set scanline counter IRQs on lines 60 and 150.

But I'll admit that Nijuu is probably overkill for a game, at least until someone writes a CPLD mapper with a timer.

by on (#61729)
I don't think there is enough CPU time to call the refresh routine in Nijuu 3 times per frame - probably get away with it most of the time but when it peaks, it peaks big :)

I just took advantage of the fact that (some) NSF players can play songs at practically any speed.

I'll see if I still have the NSF for anyone who's interested.

by on (#61906)
neilbaldwin wrote:
I don't think there is enough CPU time to call the refresh routine in Nijuu 3 times per frame - probably get away with it most of the time but when it peaks, it peaks big :)

I just took advantage of the fact that (some) NSF players can play songs at practically any speed.

I'll see if I still have the NSF for anyone who's interested.


Please do post the NSF if you find it! I'd love to test it out on the Powerpak just see how well a real NES could play the file...at the risk of blowing it up of course. :P

by on (#61913)
I found the NSF file. It's actually running at 4x normal speed, not 3x!

Just to pick up a point that Tepples made: Nijuu doesn't normally run at these speeds I just modified the NSF output code to change the NSF header to run at faster-than-normal. Having said that, even in "normal" mode it probably takes too much CPU for anything more than a simple NES game. And there's no SFX engine. LOL

Anyway, for the curious:

http://dutycyclegenerator.com/sound/Cleptoplank.nsf

Note that it doesn't end very well because I got bored with the song so ended up fading out the WAV file in a sample editor before converting it to MP3.

by on (#61915)
Oh, I thought some people might be interested in the source files to that song too. I'm not sure if these still work in Nijuu but they should do.

http://dutycyclegenerator.com/sound/Cle ... source.zip

by on (#61934)
Sweet! Thanks. :)