How to analize songs, and take out instruments?[NSFIMPORTED]

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
How to analize songs, and take out instruments?[NSFIMPORTED]
by on (#135177)
Hello. I want to take songs from Darkwing Duck and Chip&Dale2, and memorise every bit of it. For that, I need to record an output of NSF as a list of register values, get some info on how these registers converts to actual soundwave, and get notes and instruments out of this mess.

Actually, I want to convert them to flash markup language. And make some visulation program. I want to see it, not just hear. I want to know it, to keep it in my head clear as much as possible.

You can give some shortcuts for me, don't you?
Re: How to analize songs, and take out instruments?
by on (#135180)
NSF importer should come in handy: http://rainwarrior.ca/projects/nes/nsfimport.html
Re: How to analize songs, and take out instruments?
by on (#135182)
If you're familiar with Famitracker, this program will let you analyze the frame-by-frame changes visually:
http://rainwarrior.ca/projects/nes/nsfimport.html

Edit: TheFox beat me to it while I had the tab open.
Re: How to analize songs, and take out instruments?[NSFIMPOR
by on (#135210)
Is "Flash markup language" the same thing as FlMML?:
Google Translate wrote:
FlMML is a library for you to play the music in Flash.
It allows you to play the melody just pass the text of the MML notation.

I found a script for the NES emulator FCEUX that looks like it will convert NES audio playing in FCEUX into MML. (I have never used MML. I found this script while looking for sound visualization scripts for FCEUX.)

The script collection: emu2midi-lua. In the right margin, click on Download ZIP.
A blog post about how to use it: MIDI Converter Runs On Emulator

FCUEX can play NSF files, so if the script works, maybe this will do what you want.
_____

I got the script to write a MML file, but I don't know how to use the MML file to confirm it works well. EDIT: The MML text works well, see below.

The script normally requires a base64 extension and a MIDI extension, but I don't know how to install those. In nes2midi.lua, it looks like the base64 code is only used to embed DPCM samples, so I just disabled that code for now. And if you remove the line that writes the MIDI file, then the script will still write the MML file and a debugging text file. These are the changes I made:

In nes2midi.lua, find this line near the top and remove it:

local base64 = require("base64")

Near the bottom, find this line:

ch.patch = string.format("%d,%d,%s", ch.dmcseed, ch.dmcloop and 1 or 0, base64.encode(memory.readbyterange(ch.dmcaddress, ch.dmcsize)))

Change the part beginning with 0, to the end of the line to be: 0, "")

Also near the bottom, remove this line:

writer:writeMidiFile("testVGM.mid")

_____

EDIT: Using the stand-alone Flash player, I opened flmll.swf from this download and pasted in the MML text. The converted MML text works well for internal audio and NTSC speeds. Expansion audio isn't converted. Music designed for PAL speeds will play fast in the MML version, but you can lower the T number at the beginning of the MML text to adjust the speed.
Re: How to analize songs, and take out instruments?[NSFIMPOR
by on (#135211)
By the way, FCEUX comes with some example music visualization scripts (SoundDisplay.lua and SoundDisplay2.lua). If you are willing to use something other than Flash, maybe you can make visualizations the way you want using FCEUX's scripting language. For example, I made my own script to visualize things the way I wanted to:

Script: Scrolling Pitch Display.
Videos: Battle Kid 2 Demo startup story and title screen, Utaco credits screen.
(I'm not good at converting videos for YouTube. The script runs smoothly and in sync in FCEUX.)

If you still want to use Flash, the FCEUX visualization scripts might still help you understand NES audio better. For example, when using the FCEUX visualizations with NES ROMs, you can pause the emulator, then press the Frame Advance key to step one frame at a time and watch the visualization change. This can help you analyze how some of the faster effects are created.

Unfortunately, when you open an NSF file in FCEUX, the script isn't allowed to draw graphics on the screen, so you can't normally use visualization scripts when FCEUX is playing an NSF file. However, in the FCEUX source code, a line can be added to allow the script to draw graphics on the NSF playback screen. If you're interested and unfamiliar with compiling it yourself, I think I can compile a (edit:) Windows version.
Re: How to analize songs, and take out instruments?[NSFIMPOR
by on (#135310)
And direct conversion to FlMML, amasing! Thank you all, really.

(I forgot to mention, nsfplay have a nice visualizer too. With register values, volume, and a nice little keyboard. Just click "NSFplug" -> view -> keyboard)
Re: How to analize songs, and take out instruments?
by on (#135435)
Tried emu2midi-lua, output is kind of unreadable. I, I'm wondering if there is a tool to export/import famitrackef files as text. Like this http://famitracker.com/forum/posts.php?id=3129 . I'll try to understand output in meantime.

And a little unrelated question, just to not create another thread. Can you recommend lightweight midi editor? For both linux and windows. Not for creating something complex, just to look inside midi files.

Edit: Tried to nsfimport stage select music from DW (at 160 rows per frame), music slied down one row every 9-10 frames. I guess importing process does loses some data, it's not a perfect convertion. Btw, there is a line "Harware length counters are not supported by FamiTracker, and are essentially rounded down to the nearest frame by the import process." in the readme. I know it's a very very minor detail, but it still bugs me.
Re: How to analize songs, and take out instruments?
by on (#135439)
michikaze wrote:
And a little unrelated question, just to not create another thread. Can you recommend lightweight midi editor? For both linux and windows. Not for creating something complex, just to look inside midi files.


BRELS MIDI editor is pretty simple and direct: http://breno.sarmen.to/midi/
Re: How to analize songs, and take out instruments?
by on (#135480)
michikaze wrote:
Can you recommend lightweight midi editor?
I like Sekaiju, a MIDI sequencer for Windows. It defaults to Japanese, but you can change it to English: Go to the (S) menu and choose Language.