fbpx
Skip to main content

MIDI Forum

Cleaning up convert...
 
Notifications
Clear all

Cleaning up converted MIDI files / SPC to MIDI

30 Posts
6 Users
0 Reactions
22.2 K Views
Jason
Posts: 438
Honorable Member
Topic starter
 

Hi Jason, I'll be interested to hear how much success you have converting SPC to MIDI. That is a hero's journey. 😀

I think I've come as close to perfecting the technique as I can, though I still need to find a solution for...

As for the fade out... this should be as simple as automating the Channel Volume (CC 07).

I really thought the Pro Mix accessory for Anvil Studio was going to let me do this easily, but so far I am running in to a brick wall with it. I can't seem to apply a volume control to all channels simultaneously, and the graph it gives you to edit each channel individually is not precise. It only lets you view the track volume graph in fractions of the total track length instead of by time duration (you can see 1/1, 1/2, 1/3, 1/4, etc). None of my other editors seem to want to let me do it either.

The close to final process (as of July 23, 2022):

0 - Figure out all of the basic instrumentation/pitch/etc (using SPCPLAY, Winamp, spc2midi, and my ears), save in a spreadsheet
1 - Export "all melodic instruments only" as a GM MIDI file using spc2midi at normal length +10 seconds for fade out (if a looping track)
2 - Export multiple "individual percussion only" (*set as melodic, Grand Piano) GM MIDI files using spc2midi at normal length +10 seconds for fade out (if a looping track)
3 - Edit melodic file with Anvil Studio to repair (if needed) and delete all empty channels
4 - Edit all individual percussion files with Anvil Studio to repair (if needed) and delete all empty channels, then switch channel type from melodic to percussion
5 - Edit all individual percussion files with MIDI-MIS to assign the correct percussion sound to each file
6 - Load melodic only MIDI file in to Anvil Studio
7 - Merge each modified now-fully-percussion MIDI file in to the melodic file to create a complete file including all instruments and percussion
8 - (fade out last 10 seconds of each looping track... somehow)
9 - Load the complete GM MIDI file in MIDI-MIS
10 - Convert from GM to GS, and assign GS instruments as necessary

This process will work for most games that I want to do. Some, as mentioned above, are much more complex so will require a ton of extra work applying effects and stuff to get them as close to the originals as I can. The oldest games are generally the easiest, because the programmers hadn't yet figured out how to fully exploit the sound hardware. I am not going to worry about tidying up the "viewability" of the final MIDI files. My biggest concern is that they play properly and sound how I want them to.

I have Super Castlevania 4 and Super R-Type nearly complete using the new process. The WIP files from earlier are all being redone, so they are forever frozen in time as a stepping stone to where the new ones will be.

See the attachments for a sample. I included the "building blocks" of Super R-Type "Solo Sortie", the combined GM file (WIP) and the nearly final GS file (WIP2). The final file is tuned specifically to the soundfonts I am using, which can be seen in screenshot 5.

Hear the original song:
https://www.zophar.net/music/nintendo-snes-spc/super-r-type
Track 2 Solo Sortie

Hear my versions as I hear them:
GM version
https://drive.google.com/file/d/1xMX_a5hSOk2tSgHwknsERxcwHavKnFjv/view?usp=sharing

"Final" GS version
https://drive.google.com/file/d/1PvioL4ofN5v2X89XgvnjuGQS37I8hEID/view?usp=sharing

I am open to any suggestions on how I can fade out the last 10 seconds of each finished MIDI file without killing myself doing it :p

 
Posted : 23/07/2022 1:44 pm
Bavi_H
Posts: 267
Reputable Member
 

Fade outs can be done with Volume (CC7) or Expression (CC11), as long as your MIDI sound source responds to Volume or Expression.

It is very easy to do in Cakewalk. Here's an example:

1. In the track list window, drag over the the last two measure numbers at the top of the right pane to select the last two measures in all tracks.

2. Go to the Insert menu and select the "Series of Controllers" command.

3. Fill in the options to insert type Controller, Number 11 Expression, Value Range Begin 127 to End 0. (The time range is already filled in based on the selected range. The MIDI Channel doesn't matter*.) Click OK.

*Cakewalk will insert all the controllers for the same channel. But when you opened the MIDI file, Cakewalk recognized that each track has only one channel in it and set a "channel number" property for each track. When you save the MIDI file, the events in each track get changed to the channel number property for the track.

View: cakewalk-fadeout.png

 
Posted : 23/07/2022 4:28 pm
Jason
Posts: 438
Honorable Member
Topic starter
 

[quotePost id=15189]Fade outs can be done with Volume (CC7) or Expression (CC11), as long as your MIDI sound source responds to Volume or Expression.

It is very easy to do in Cakewalk. Here's an example:
[/quotePost]
Thanks, I tried it out and it seems to do the trick, with a caveat. The files don't line up nice with editors, so it doesn't line up with the measures at the top. I was able to switch the view to hours:minutes:seconds:frames, which is what I would like to use, but the "Series Of Controllers" and selection snapping seems to only display in measures, so it may take some finagling to get it to line up exactly where I need it, unless there's a way to turn off snapping to measures? So far, 1000% more track fade-out than I had before. 😀

 
Posted : 23/07/2022 6:03 pm
Bavi_H
Posts: 267
Reputable Member
 

Oh. I must have changed the default snap setting. The snap tools are to the left of the the play / pause / stop buttons in the toolbar:


You can click the snap button (A) to turn off the snap to grid function.
Or
You can right-click on the snap amount (D) to choose a different snap setting.

For more information about various buttons and things, you can go to the View menu and choose "Help Module". This will open a window that will explain anything you hover over.

 
Posted : 23/07/2022 11:38 pm
Jason
Posts: 438
Honorable Member
Topic starter
 

I've messed around with it some more. I am able to do exactly what I need, but now it is messing up the beginning of my songs after I add the expression fade out to the end. The tracks are getting misaligned starts, with some of them being delayed about 3.5 to 3.8 seconds. I've posted on the Cakewalk forum to see if anyone has any suggestions on why that might be happening. In the meantime, is anything inherently wrong with the order of these events from the first track (technically track 2)? No testers find any errors.

[ 156] MTrk:
[ 165] 0: b1 00 12 -- Bank Select MSB
[ 169] 0: b1 20 00 -- Bank Select LSB
[ 173] 0: c1 75 -- Program Change (Jungle Snare Drum)
[ 176] 0: ff7f -- Sequencer Specific: 05 0f 09 08 40
[ 185] 0: ff7f -- Sequencer Specific: 05 0f 06 47 65 6e 65 72 61 6c 20 4d 49 44 49 20 2d 20 56 69 72 74 75 61 6c 4d 49 44 49 53 79 6e 74 68 20 23 31
[ 226] 0: ff03 -- Sequence Name: 02 Solo Sortie USE.mid
[ 252] 0: ff02 -- Copyright: Converted by spc2midi
[ 277] 0: b1 7b 00 -- All Notes Off
[ 281] 0: b1 7f 7f -- Poly Mode On
[ 285] 0: b1 79 00 -- Reset All Controllers
[ 289] 0: b1 65 00 -- Registered Parameter Number MSB
[ 293] 0: b1 64 00 -- Registered Parameter Number LSB
[ 297] 0: b1 06 0c -- Data Entry MSB (RPN 00 00: Pitch Bend Sensitivity)
[ 301] 0: b1 26 00 -- Data Entry LSB (RPN 00 00: Pitch Bend Sensitivity)
[ 305] 0: b1 07 43 -- Channel Volume MSB
[ 309] 0: b1 27 54 -- Channel Volume LSB
[ 313] 0: b1 0a 1b -- Pan MSB
[ 317] 0: b1 5b 1e -- Effects 1 Depth
[ 321] 0: b1 5d 0a -- Effects 3 Depth
[ 325] 0: e1 38 3e -- Pitch Wheel
[ 329] 0: 91 49 64 -- Note On
[ 333] 1: b1 0b 7f -- Expression Controller MSB
[ 337] 1: b1 2b 7f -- Expression Controller LSB
[ 341] 2: 81 49 14 -- Note Off

Here's what I'm left with after Cakewalk has a go. You can see that events have been re-arranged, and timing has been modified.

[ 667] MTrk:
[ 676] 0: ff03 -- Sequence Name: 02 Solo Sortie USE.mid
[ 702] 0: ff7f -- Sequencer Specific: 05 0f 09 08 40
[ 711] 0: ff7f -- Sequencer Specific: 05 0f 06 47 65 6e 65 72 61 6c 20 4d 49 44 49 20 2d 20 56 69 72 74 75 61 6c 4d 49 44 49 53 79 6e 74 68 20 23 31
[ 752] 0: b1 7b 00 -- All Notes Off
[ 756] 0: b1 7f 7f -- Poly Mode On
[ 759] 0: b1 79 00 -- Reset All Controllers
[ 762] 0: b1 65 00 -- Registered Parameter Number MSB
[ 765] 1: b1 64 00 -- Registered Parameter Number LSB
[ 768] 2: b1 06 0c -- Data Entry MSB (RPN 00 00: Pitch Bend Sensitivity)
[ 771] 3: b1 26 00 -- Data Entry LSB (RPN 00 00: Pitch Bend Sensitivity)
[ 774] 3: b1 27 54 -- Channel Volume LSB
[ 777] 3: b1 5b 1e -- Effects 1 Depth
[ 780] 3: b1 5d 0a -- Effects 3 Depth
[ 783] 3: e1 38 3e -- Pitch Wheel
[ 788] 241: b1 00 12 -- Bank Select MSB
[ 792] 242: b1 20 00 -- Bank Select LSB
[ 795] 242: c1 75 -- Program Change (Jungle Snare Drum)
[ 798] 242: b1 07 43 -- Channel Volume MSB
[ 802] 242: b1 0a 1b -- Pan MSB
[ 806] 960: 91 49 64 -- Note On
[ 810] 961: b1 0b 7f -- Expression Controller MSB
[ 814] 961: b1 2b 7f -- Expression Controller LSB
[ 817] 962: 91 49 00 -- Note Off

 
Posted : 24/07/2022 2:20 pm
Bavi_H
Posts: 267
Reputable Member
 

Oh no! I don't use Cakewalk very often, I forgot it can rearrange and move events like this. It looks like Cakewalk decided there wasn't enough time at the beginning to send all of the initial setup events, so Cakewalk moved all the notes one measure later. Additionally, when you open a MIDI file, I think Cakewalk likes to store things in its own kind of internal format. So when you save back to the MIDI file, events can get rearranged or moved compared to the original MIDI file.

As an alternative for you, I'm thinking of posting how to do a fade-out in Sekaiju. It's a little more work, but it shouldn't rearrange or move events in your MIDI file.

The rest of this post is technical discussion, mainly about what Cakewalk rearranged.

Anything wrong?

[quotePost id=15198]is anything inherently wrong with the order of these events [...]?[/quotePost]
My only recommendation is to put the track name at time zero and before any events that would get sent out to the MIDI port (that is, before any event with a MIDI channel number or any System Exclusive event). I remember reading somewhere that some MIDI file software might only search for a track name until it reaches an event for MIDI output or it encounters a non-zero delta time. So if the track name comes after an event for MIDI output, some software might not show the track name.

First track

[quotePost id=15198]the first track (technically track 2)[/quotePost]
You should be aware that in a Format 1 MIDI file, in the actual bytes of the file, the first track (the first MTrk chunk) is used for events like tempo, time signature, and key signature, and can't contain any notes.

Often, MIDI file editors (including Cakewalk) do not show this first track in their track list window. They reserve their track list window for tracks that can contain notes. You might have to use another window or a timeline header to see things like the tempo, time signature, or key signature events. For example, in Cakewalk, in the View menu, you can open the windows called Markers, Tempo, or Meter/Key to view things that are stored in the first track of the MIDI file.

Any time you or other people use different kinds of software to examine a MIDI file, you have to be careful when discussing which track you are referring to. In my comments below I will call the actual first track in the MIDI file "the conductor track", and I will call the tracks after that "the first note track", "the second note track", and so on.

Cakewalk view notes

As mentioned above, Cakewalk will put various events from the conductor track into their own special windows: Markers, Tempo, and Meter/Key.

Cakewalk will put the Track Name from the conductor track, Copyright events from any track, and Text events at time zero from any track into its Notes window (View menu, Browser command, Notes tab). It won't show them as events in the Event List window.

Cakewalk will consider the Track Name and initial Bank and Program Change events in a note track as a track property. It won't show them as events in the Event List window, only as values for the track in the Track List window.

Cakewalk will combine note start and note end events into a single "Note" event that has a start time, velocity, and duration.

Cakewalk will combine the Control Change events used for sending a RPN or NRPN into a single "RPN" or "NRPN" event the Event List.

With your MIDI file

Cakewalk rearranged many of the initial setup events.

It looks like Cakewalk decided there wasn't enough time at the beginning to send all of the initial setup events, so Cakewalk moved all the notes one measure later.

Some of the tracks have volume events before the first note event. In general, Cakewalk didn't move volume events before the first note event (except if it was very close to the beginning, it might move it one beat later). But at the point the first note event happens, Cakewalk moved the first note and every following event in the track one measure later.

In particular, the 8th to 11th note tracks are all for Channel 10 percussion sounds. Some of these tracks contain various volume events before the first note. Perhaps those volume events were originally intended to affect Channel 10 notes found on the other tracks.

More details

It looks like Cakewalk rearranges the order of initial setup events when you open the file, but at this point the events still have the same measure:beat:tick timestamps, they've just been rearranged into a different order within the events at same timestamp.

Once you save the file and re-open it in Cakewalk (or look at it in other MIDI file software), you will see Cakewalk has moved some events to a new measure:beat:tick timestamp:

Some of the initial setup events were moved around 1 to 3 ticks later.

Some of the initial setup events were moved 1 beat later.

All of the note events were moved 1 measure later, and any event after the first note event in each track was also moved 1 measure later.

Any other event before the first note event in each track was not moved.

It moved the Copyright event from the first note track to the conductor track.

Example pictures

I used Sekaiju to look at the file "02 Solo Sortie WIP2.mid" before and after I edited it with Cakewalk.

Note: In Sekaiju I changed the setup options to number the tracks starting with 0. So the "conductor track" is shown as track 0 and "the first note track" is shown as track 1.

1-event-lists.png

These event lists show the beginning of the 1st note track before and after saving the file in Cakewalk.

The Copyright event (marked with an asterisk) was moved to the conductor track.

The initial setup events were rearranged, and some of them moved 1 to 3 ticks or 1 beat later.

The first note and everything after it was moved one measure later.

2-piano-rolls.png

These piano rolls show the 10th note track notes (the very small lines in the top panes) and Volume events (bottom panes). The left window is before and the right window is after saving the file in Cakewalk. You can see Cakewalk moved the note events and the volume events after the first note event one measure later. The volume events before the first note event weren't moved.

3-track-lists.png

These track lists show the 8th to 11th note tracks.

In the right pane of the Track List, Sekaiju draws vertical lines to represent events like Control Change or Pitch Bend. The height represents the value, or a little circle represents zero. In your MIDI file these vertical lines are usually Volume messages.

In the right pane of the Track List, Sekaiju draws horizontal lines to represent notes.

If you look closely, you can see where the first note and other events were moved 1 measure later.

8th note track: there's a new gap at measure 1.
9th note track: there's a new gap at measure 27.
10th note track: there's a new gap at about measure 31.
11th note track: there's a new gap at measure 1.

As mentioned previously, in your MIDI file, the 8th to 11th note tracks are all for Channel 10 percussion sounds. Some of these tracks contain various volume events before the first note. Perhaps those volume events were originally intended to affect Channel 10 notes found on the other tracks.

Slightly related - Reordering simultaneous note start and note end

Previous threads here have mentioned rearranging the order of simultaneous note start and note end events for the same pitch and channel:

Reordering simultaneous events
SMF Format 1 Tracks and Channels

I now think this is an artifact of how some MIDI editors store notes. If a MIDI file editor combines the note start and note end events that are in the MIDI file into an internal format "note" event that has a start time and duration, then when it saves that back to a MIDI file, it will put the note end before the note start at the same time on a track. If there's a note start and note end for the same pitch and channel on different tracks, then the re-saving doesn't rearrange the file events, but when it plays the notes, it will play the note ends on every track before the note starts at the same time on every track.

 
Posted : 25/07/2022 4:52 am
Bavi_H
Posts: 267
Reputable Member
 

I found a Cakewalk INI file setting that will avoid most of the note movement issue. I posted a reply in your Cakewalk Forums thread.

The attached text file has some steps to do a fadeout in Sekaiju. (How to draw a fadeout line in one track and duplicate it to the other tracks, or just draw a fadeout line in each track.) If you are only doing one file, the Sekaiju steps are a little more work than the Cakewalk method. However, I reviewed this entire thread to get up to speed on your project, and I see you want to edit many MIDI files. Using the Sekaiju steps to make a fadeout in many MIDI files might be not fun.

sekaiju-fadeout.txt

 
Posted : 25/07/2022 1:46 pm
Jason
Posts: 438
Honorable Member
Topic starter
 

Very thorough breakdown indeed!

As mentioned previously, in your MIDI file, the 8th to 11th note tracks are all for Channel 10 percussion sounds. Some of these tracks contain various volume events before the first note. Perhaps those volume events were originally intended to affect Channel 10 notes found on the other tracks.

For this particular one, those were all part of the original in-game Track 8, which is why they all bear the same name. Because of the way I have to save the percussion separately to retain the dynamics, it looks like the volume events (mostly?) duplicate between all of the former pieces of Track 8. I thought Anvil Studio would compensate when merging them together. Perhaps it has a "merge track" option that might neaten it up a bit.

I actually wouldn't mind Cakewalk adding a measure of "silence" at the beginning, if it could be proven that it was consistent across all tracks, but I'm not sure all notes and dynamics ended up where they should be, just shifted by one measure? I'd have to give it a realllll careful listen...

 
Posted : 25/07/2022 8:06 pm
Jason
Posts: 438
Honorable Member
Topic starter
 

[quotePost id=15215]I found a Cakewalk INI file setting that will avoid most of the note movement issue. I posted a reply in your Cakewalk Forums thread.

[...]

Using the Sekaiju steps to make a fadeout in many MIDI files might be not fun.][/quotePost]
I'll check out the Cakewalk file when I get a chance.

As for the Sekaiju method, I wish it were easier 😉 I was originally using Sekaiju to do the percussion portions, but even for that it was roughly the same process and number of steps to grab the percussion from the "old track", move it to the percussion track, and convert it in to actual percussion (not to mention all the additional times I would forget a key step and have to redo it all over again when I messed it up). For the amount of times I have to do this, a more efficient method is a must. I'm glad I figured out how to do that part in Anvil Studio at least.

 
Posted : 25/07/2022 8:14 pm
Jason
Posts: 438
Honorable Member
Topic starter
 

Given that Cakewalk adds a setup measure to a file on purpose (Thanks for checking, Bavi) I may end up leaving them mostly as is after running them through Cakewalk. I know that currently, it usually takes my softsynth a split second to load all of the appropriate patches and whatnot, so my tracks don't always play smooth/correctly at the very beginning, so this added "setup measure" may actually be a good thing. Additionally, since I am first creating the files with a very incomplete piece of software, and then editing it multiple times with various other pieces of software, it seems maybe having Cakewalk rearrange the events may be helpful as well to make the file more... logical? It also appears that Cakewalk makes it easy to rename tracks and other naming info, like song name, album, etc. So I will probably end up using it as the second-next to last step in my process. I ran a repair check with Anvil Studio on the resulting file after Cakewalk was done with it, and it found and removed some extra unneeded stuff created by Cakewalk (I forgot what specifically, but I think a few pitch bends, some expressions that ended up after the last note of the song, maybe a few other little things). And then Sekaiju as the final step to remove all of the sequencer specific meta data that Anvil Studio insists on putting all over every file.

So I guess my next step is to try it out on the whole soundtrack and see if I can make my first official release for the SNES MIDI Remaster Project!

Stay tuned...

 
Posted : 27/07/2022 8:59 pm
Jason
Posts: 438
Honorable Member
Topic starter
 

Feel free to check out my first SNES MIDI Remaster Project WIP video upload!

I am playing my WIP MIDI files back using a program called MIDITrail, and recording the video with XBox game bar set at the highest settings it will allow. I'll probably have this up until I release my first officially complete soundtrack.

Currently, there are still a few issues with the ends of some of the tracks. I'm using Bavi's script to add the fadeouts.
https://midi.org/forum/15301-applying-expression-to-expression

A couple of them I must not have dragged the expression controllers far enough, because there is a quick burst of sound at the very end. I'm also having an issue where certain tracks are getting extended past the point where I am snipping them. I'm hoping it's just a setting in Cakewalk that I have to turn on or off. Most of the time it doesn't make much difference, but one track is 5 seconds longer than it should be. I also need to update track names and such in the MIDI files, and do some miscellaneous cleanup. One song I had to use a combination of Bavi's expression-fadeout script on 5 of the tracks and manually selecting three tracks and applying the expression controllers, otherwise those three tracks never faded out.

I will be uploading a complete soundtrack video to my YouTube account for each game I finish. I will also be hosting the finished MIDI soundtrack files on my Google Drive, along with an instrument list for each song (via a screenshot from MIDI-MIS) and a description of the process used to create the MIDI files and video from start to finish.

SNES MIDI Remaster Project Test Super R-Type WIP
https://www.youtube.com/watch?v=1eELPMK-NcU

 
Posted : 02/08/2022 5:49 pm
Matt
 Matt
Posts: 4
New Member
 

Hey Jason, just stumbled across this thread again (haven't been getting notifications for replies 🙁 ).
Looks like you made lots of progress! (Would like to check the YouTube link but it's private.)

For my own project, I am doing something very similar: extracting music from Nintendo 64 games. There are existing tools for this (Subdrag's N64 Sound Tool) but the data still requires a lot of cleanup.

I am not mapping the instruments to General MIDI, but preserving the game soundbank as SoundFonts. I embed a little instruction in the MIDI files (Meta text event) to point to a SF2 SoundFont file.

Check out the results here: https://mmontag.github.io/chip-player-js/browse/Nintendo%2064%20(SoundFont%20MIDI)

Player Settings allows you to tweak the sound, such as reverb.

 
Posted : 15/12/2022 6:49 pm
Jason
Posts: 438
Honorable Member
Topic starter
 

Oh, yes, I removed all the test versions from public view. I forgot I had a link here.

But good news, check this thread for the currently completed soundtracks!
https://www.midi.org/forum/15496-snes-midi-remaster-project-now-online

I'll check out yours when I get a chance. I planned on doing Castlevania 64 and Legacy of Darkness in a similar fashion to my SNES project, but this is taking plenty of time, and figuring it all out again for N64, well I'll probably be a senior citizen by then :p

 
Posted : 15/12/2022 7:08 pm
Wee
 Wee
Posts: 1
New Member
 

Great posts! Thanks

 
Posted : 29/11/2023 3:40 am
Rusy Martien
Posts: 1
New Member
 

good...

 
Posted : 29/11/2023 3:41 am
Page 2 / 2
Share: