jombo23 / N64-Tools

N64 Tools
The Unlicense
239 stars 113 forks source link

N64 Soundbank Tool - Majora's Mask Midi Export #44

Open lankv2 opened 1 year ago

lankv2 commented 1 year ago

When exporting the southern swamp sequence there is no pitch bend events. If you listen to the track from the game's ost there is clearly pitch bend. I use wine to run n64 soundbank tool and I use rosegarden and midieditor to edit the midis. I'm using majora's mask (u) decompressed rom. Other sequences have been successful in exporting the pitch bend events.

SubDrag commented 1 year ago

You'll have to be much more specific on what midi specifically, and when pitch bend should come.

lankv2 commented 1 year ago

Legend of Zelda, The - Majora's Mask (U) Decompressed 0000000C 00C77B70.mid and the pitch bend should start at about 6 seconds in.

SubDrag commented 1 year ago

Here's the debug parse - don't see any pitch bend events? https://pastebin.com/E3vrH4ET

mmontag commented 1 year ago

@BENDER-V2 you're talking about the plucked instrument? This sounds like vibrato to me. There are a couple vibrato messages in the paste...

lankv2 commented 1 year ago

@mmontag Might be, when i exported it to a midi file it seems that it did not keep the vibrato.

SubDrag commented 1 year ago

Vibrato isn't supported for export. Midi doesn't support as much as the n64 sound engine does.

DeathWrench commented 1 year ago

What else is missing? I'm assuming vibrato isn't the only one. Are there any alternatives that are like vibrato that sound exacty like it when tweaked a certain way; that midi does support? I'm suggesting that if there is an alternative that sounds identical, could use that in replacement for things that have vibrato.

SubDrag commented 1 year ago

Tremolo, etc. I don't think there's a good way to encode in midi. I think someone suggested in the past maybe just putting them in as extra midi commands so someone opening it in a tool, could see them, and manually adjust. But anyways there's no good way to do actually support vibrato.

mmontag commented 1 year ago

I must be missing something here, but... doesn't vibrato depth usually map to MIDI CC 1, the mod wheel? For example, this is a default modulator in the SoundFont spec and FluidSynth.

There's also the GM2 CC 76 (Vibrato Rate), CC 77 (Vibrato Depth), and CC 78 (Vibrato Delay).

SubDrag commented 1 year ago

Sorry now I remember - the vibrato on N64 is defined on the *instruments, not in the midi. That's why most games I don't support vibrato (using standard formats). Now EAD games like Majora's Mask have it in the midi, so it might be possible. Do you know how the values translate from the debug parse to midi commands here? Not sure it's the same scale or direct translation. For example showing in this song vibrato of 05 and 09. Not sure what that translates too.

L-Spiro commented 1 year ago

EAD music has MIDI controls for vibrato delay (0xE3), vibrato depth (0xD8), and vibrato rate (0xD7). These can map to GM2 controls fine enough, and the vibrato works the same in all EAD games—a rate of 0x40 is always the default and runs at the same speed in all EAD games. So the EAD vibrato delay times, vibrato depths, and vibrato rates can all be translated into hard numbers using code you can find in Nintendo Synthy-4: https://github.com/L-Spiro/Nintendo-Synthy-4/blob/main/NS4/Src/MIDI/NS4MidiFile.h#L1812 Same with tremolo below that.

But there are 2 issues.

  1. The vibrato command in EAD isn’t always vibrato. In Lon Lon Ranch/Romani Ranch it is set to tremolo. In Yoshi’s Story: Rail Lift it is set to a ring modulator. It is the same set of commands (0xE3, 0xD8, and 0xD7), just the game patches it through a different effect externally from the MIDI file, so there is no way to know which effect to use. Still, it is almost always vibrato, and if the commands were added to the MIDI files then dozens of tracks will start to sound correct while only a few will sound incorrect.

  2. There is no MIDI standard for how to implement vibrato. We can know the EAD cycles-per-second, delay time, and total pitch-bend, but we can’t know these values on the GM side; they will be different in every player/synthesizer. Still, they should be at least similar, so you can take a few sample sets, time/measure them, and try to make conversions. But you should still keep the original data in the MIDI file, as it would be necessary for my work (though I currently just load the debug file). I would recommend adding them as comments/labels/lyrics inside the MIDI file, that way people who want the translated values can just play the file and people who want the original values can ignore the translated vibrato commands and parse the labels instead.

Here is the mentioned track with proper vibrato rendered using the code above: https://www.dropbox.com/s/skfvr6tmutsve18/042%20Southern%20Swamp%20%28Surround%29.mp3?dl=0