fbpx
Skip to main content

MIDI Forum

Change tempo of mid...
 
Notifications
Clear all

Change tempo of mid file without changing perceived timing

9 Posts
3 Users
0 Reactions
6,751 Views
Jason
Posts: 441
Honorable Member
Topic starter
 

I'm in a time pinch (unintentional tempo joke!). I activated a 30 day trial of Melodyne to try sussing out some MIDI files from non-instrumental audio in some SNES files that I am working on for the SNES MIDI Remaster Project. The game audio plays a single "note" that has varying pitches in the sound sample it uses, that I need to convert to multi-note MIDI.

Melodyne creates two separate files when exporting a MIDI file: a .mid file with a fixed tempo of 120 bpm, and a separate .mid file that contains a tempo map. I have tried just modifying the tempo in the normal .mid file to match the required 62.5 bpm of the rest of the song that I need to merge it with, but so far everything I have tried has simply changed the tempo, and not modified anything else to keep the song sounding the same.

I need to be able to change the tempo to 62.5, but have the song still play at the same actual speed, so all note lengths, delta times, etc would need to change along with the tempo change. Using Windows.

So far, I tried changing it in
Anvil Studio - stretches the final playback upon merge in Anvil Studio
Sekaiju - stretches the final playback upon merge in Anvil Studio
Cakewalk - works for the most part, but is a guessing game as to the correct amount to adjust because it doesn't let me stretch by tempo. I have to assign a tempo, and also stretch by time to go along with it using bars and frames. 62.5/120 does not come out nice.
MidiEditor - won't load files, claims corruption

Alternately, a decent free alternative to Melodyne where I can actually specify the output tempo of the file would also be fantastic.

 
Posted : 29/12/2022 11:00 am
Bavi_H
Posts: 267
Reputable Member
 

To make sure I understand, it sounds like you have three different MIDI files:
1. The Melodyne notes MIDI file.
2. The Melodyne tempo map MIDI file.
3. An existing MIDI file that you want to add the Melodyne MIDI notes into.

In the Melodyne notes MIDI file, you want to keep everything at the same positions in seconds, but change the tempo, measures, and quarter-note-based durations to musically correct values. Then you want to add the Melodyne MIDI notes into your existing MIDI file.

Question: What is the resolution of all three MIDI files?

When you open each MIDI file in Sekaiju, the status bar section that says "_TPQN" or "SMPTE_/_" indicates the resolution of the MIDI file. [Update: The following bug only applies to Sekaiju 7.6 or before, it was fixed in Sekaiju 7.7 released 2023-01-04.] However, Sekaiju [7.6 or before] has a bug where both SMPTE24 and SMPTE25 resolution formats are shown on the status bar as "SMPTE24/_". If the status bar says "SMPTE24/_", please double-click on the "SMPTE24/_" text (or go the File menu and choose Property) and confirm if the resolution format is SMPTE24 or SMPTE25.

Here are two ideas how to change the tempo but keep the notes at the same positions in seconds. We might need to test and tweak these steps. In the example steps I've written below, the first note should be at the very beginning of the MIDI file and should correspond to the first beat of the first measure. If that's not the case, we may have to add additional steps.

Idea 1: Use Sekaiju and temporary SMPTE resolution.

1. Open the Melodyne notes MIDI file in Sekaiju.

2. In the File menu, select Property. If the resolution format is TPQN, change to a SMPTE resolution format. For now, I suggest using SMPTE25 and 40 subframes per frame. (This is effectively 1000 ticks per second.) Once I know the exact resolutions each MIDI file uses, I might recommend some other value to help avoid precision loss.

When a MIDI file uses a SMPTE resolution format, Sekaiju shows event positions in seconds-based units (frames:subframes) instead of the quarter-note-based units (measure:beat:tick) used with TPQN resolution format. If you change the resolution format from TPQN to SMPTE, Sekaiju converts all event positions into these seconds-based units (frames:subframes).

3. In the Track List right pane, right-click on the area above the measure numbers (now actually frame numbers) and choose Modify Tempo. Enter the desired tempo (probably the tempo you see in the Melodyne tempo map MIDI file). Sekaiju will update the tempo value without changing the position of any of the events.

4. Go to File, Property. Change the resolution format to TPQN. (You probably want to use the resolution that your existing MIDI file is using.) Sekaiju will convert the event positions into quarter-note-based units (measure:beat:tick).

Idea 2: Use the Cakewalk "Set Measure/Beat at Now" command.

1. Open the Melodyne notes MIDI file in Cakewalk.

2. In the Views menu, select Event List. If there is nothing shown in the Event List window, click on the Tracks button, choose "Pick Tracks", and select one or multiple tracks with notes in it. Now you can click on a note event in the Event List to change Cakewalk's "now" position to the beginning of the note you clicked on.

3. In the Views menu, you can also open a Piano Roll window to help confirm where you are setting the "now" position when you click on a note in the Event List. Arrange the windows so you can see both the Piano Roll and Event List without overlapping.

4. Play the MIDI file from the beginning and ignore any measure:beat display shown in Cakewalk. Based on listening to the sound of the notes, manually count the beats and measures until you get to some point far along into the music. Pause the playback near a note that should be at the beginning of a measure.

5. In the Event List, click on a note to set the "now" position to the beginning of the note. It will probably be easier to click on a note that should be at the beginning of a measure.

6. In the Project menu, select the command "Set Measure/Beat at Now", then enter the measure number and beat number you want based on what you heard. (If you clicked on a note that should be at the beginning of a measure, enter the measure number you want and beat 1.) Cakewalk will keep events at the same seconds-based position but change the tempo value so all the events' quarter-note-based positions eventually end up at the measure and beat position you entered.

Further Technical Wonderings

I have Cakewalk and Sekaiju, but I'm not sure if I want to install Melodyne, Anvil Studio, and MidiEditor to test them. However, your problem really fascinates me. If I had access to all the same software you are using, I would want to investigate the following:

I wonder why Melodyne exports a separate tempo map? If it already knows the tempo I wonder why it doesn't just create one MIDI file with both the notes and the tempo value? I wonder if it is using one of the SMPTE resolution formats in the MIDI files it makes to help suggest the times should be based on seconds instead of quarter-note units.

Does the Melodyne notes MIDI file also contain tempo values? If so, then maybe the tempo map MIDI file is just an extra file that can be used with devices that need tempo information but don't need note information.

I wonder if MidiEditor is having problems with SMPTE resolution format?

If your MIDI files have different resolutions, I wonder if that could be causing unwanted stretching when you merge in Anvil Studio.

 
Posted : 29/12/2022 6:18 pm
Jason
Posts: 441
Honorable Member
Topic starter
 

To make sure I understand, it sounds like you have three different MIDI files:
1. The Melodyne notes MIDI file.
2. The Melodyne tempo map MIDI file.
3. An existing MIDI file that you want to add the Melodyne MIDI notes into.

That is correct.

In the Melodyne notes MIDI file, you want to keep everything at the same positions in seconds, but change the tempo, measures, and quarter-note-based durations to musically correct values. Then you want to add the Melodyne MIDI notes into your existing MIDI file.

That is also correct.

Question: What is the resolution of all three MIDI files?

Melodyne notes: 1920 TPQN
Melodyne tempo map: Most are 1920 TPQN, one is 48?
File to add in to: 240 TPQN

The Melodyne files (in this particular case) are the 5 parts of a 5-channel sound at the very beginning of the song. It it a robotic "indistinguishable" voice that plays before a boss comes on the screen to fight. I've then merged those 5 single mid files in to a combined file using Anvil Studio, it is 1920 TPQN.

Idea 1: Use Sekaiju and temporary SMPTE resolution.

So far so good! Now to test the merge. Please hold.

Merge appears successful! This "clip" is super short, only a couple of seconds long. Hopefully it all still lines up if I have to do a longer one eventually. And I have to find a good sound in my sondfonts to use 😛 I have one that's decent (64 117 Lightsaber XGM from ColomboGMGS2) but hopefully I can find an even better one.

Idea 2: Use the Cakewalk "Set Measure/Beat at Now" command.

I'll pass on this one 🙂 Unless it's something I might need to try later on for a longer clip.

I wonder why Melodyne exports a separate tempo map? If it already knows the tempo I wonder why it doesn't just create one MIDI file with both the notes and the tempo value?

Jason wonders the same...

I think it's for when it is used as a plugin for certain DAWs? Not sure why the standalone version would not combine them. I can manually set the tempo within Melodyne, but it still exports the notes file at 120 bpm no matter what.

I wonder if MidiEditor is having problems with SMPTE resolution format?

It's a freeware editor, and I believe there are certain things is just does not handle properly. I rarely use it, but have it on hand to test things out sometimes, like this!

If your MIDI files have different resolutions, I wonder if that could be causing unwanted stretching when you merge in Anvil Studio.

When merging files in Anvil Studio, the first file that is open is the "main" file, and any files merged in to it take on its properties.

So trying to merge a 120 bpm file into a 62.5 bpm file keeps the timings the same, so 120 beats from the 120 bpm file still take 120 beats in the 62.5 bpm file, effectively more than doubling the playback length of the 120 bpm segment.

Changing the bpm of the original file to 120 in Anvil Studio and then merging still does not provide a correct merged file, because it does not change any of the internal timing, just the playback speed, so the 120 bpm add-on still ends up overlapping the now extra fast playing original file.

 
Posted : 29/12/2022 9:58 pm
Bavi_H
Posts: 267
Reputable Member
 

I'm happy the method of using Sekaiju and temporarily using SMPTE resolution format to update the tempo is working for you.

I did some math to estimate the resolution loss, but I doubt it's audible:

A. The Melodyne MIDI files have an effective resolution of 0.26041666... milliseconds. (1920 ticks per quarter note and 120 quarter notes per minute)

B. The temporary SMPTE resolution format has an effective resolution of 1 millisecond. (25 frames per second and 40 subframes per frame)

C. The final MIDI file has an effective resolution of 4 milliseconds. (240 ticks per quarter note and 62.5 quarter notes per minute)

Thanks for describing the resolutions of the MIDI files. I mainly wanted to see if the Melodyne MIDI files were using SMPTE resolution format.

(Using the SMPTE resolution format can kind of be a way to specify note positions in seconds-based units without storing any kind of measures, beats, tempos, or quarter-note-based units, so I was curious if Melodyne's MIDI files might be doing that. However, using TPQN resolution format will maximize compatibility with other MIDI file software, so I agree it's a good idea for Melodyne to make MIDI files that way. My understanding is various MIDI file software doesn't work well with SMPTE resolution format because it's practically never used in MIDI files, so software doesn't get tested with it.)

By the way, Sekaiju has another resolution limitation: If the MIDI file resolution is over 1920 TPQN, Sekaiju will show a message when you open the file and convert it to 1920 TPQN. ("This MIDI data's time resolution is too high (_ TPQN). It is modified to 1920 TPQN.") If you get this message when opening a MIDI file in Sekaiju, then the original resolution is the one shown in parentheses in the message. But I guess it doesn't matter much if the original TPQN resolution was higher. It just means the effective resolution at point A above is more precise.

 
Posted : 30/12/2022 5:32 am
Jason
Posts: 441
Honorable Member
Topic starter
 

I think I've done the initial conversion of everything I need to do. Kind of baffled with the lack of options and UI choices in Melodyne as it is a rather expensive piece of software. If I was not using it as a trial product, I'd be a little miffed.

That being said, it does a pretty good job I think, but I'll know more once I sort through the multiple versions of each original file to see which one will work the best for me.

Currently, I used spcplay to export the complete audio channel that the sound is on as a wav file and used Melodyne on that. I may end up having to crop the originals to just contain the pieces I actually need, and possibly do some normalization before running them through Melodyne. Fortunately, I think there are only two games I need to do this for, and currently 17 total wav files (including the 5 I already did for the test earlier).

 
Posted : 30/12/2022 4:01 pm
Jason
Posts: 441
Honorable Member
Topic starter
 

I'll still be using this time tempo modding technique I think, but I am probably going to rethink how I'm creating the files to insert.

I tested out some of the online wav to midi converters, and they all come out essentially the same. They use a series of very short densely packed notes, as opposed to how Melodyne does it, which is to make longer, sometime pitch modified notes (depending on which of the conversion algorithms you choose). As I am mainly converting speech or pseudo-speech samples, I feel like I'm getting more "understandable" results with the online converters. Still not speech, but you can almost make out some words (highly dependent on the instrument chosen)?

I won't give away what he says, see if you can make out any words, ha ha. There are four Melodyne samples (I believe polyphonic sustain, polyphonic decay, percussive pitched, and melodic in that order), and a single online version which I've manually cut off some of the hi-pitched notes that it picked up from harmonics.

Once I make a final decision, I'll try working these in to the new song files once I make them (currently just messing around with my previous "old method" files from before I refined my entire SNES to MIDI process).

 
Posted : 31/12/2022 4:36 pm
Posts: 1
New Member
 

Not sure if this belongs, but...

Right now, I'm trying to change the resolution of a MIDI sequence using Cakewalk (from 480 to 168 TPQN; don't ask me why) and I can't understand the instructions -- I assume to stretch the sequence relative to a fixed number of ticks (7:20 scale in this case).

I do know how to change the TPQN of a MIDI file manually using HxD, but that will change the perceived timing without going through and changing all 14,000+ events' delta-times to reflect that.

Please note there are hundreds of tempo changes as I was aiming for smooth accelerandi. I don't want to simply convert the sequence to SMPTE and back again, losing all tempo data in the process, requiring me to rebuild the tempo map in Signal -- and let me tell you; this was already tedious once and I'm not doing it again.

I'm looking for a quick and easy solution to this truly baffling debacle and this is the best forum I could find where I could ask around.

 
Posted : 27/10/2024 4:37 pm
Jason
Posts: 441
Honorable Member
Topic starter
 

Sekaiju is free, and the method seems to work well. Give that a shot. It's more complicated to do in Cakewalk.

I *think* the changes in tempo would be unaffected?

The worst that could happen is that it doesn't work. 

That being said, the Cakewalk method above was based on my specific files. I didn't use Cakewalk to do it, but what you would do is change the TPQN setting of the file from the original 480 to the new 168.  This will audibly stretch your file. Then find the first note of, say, what is supposed to be measure 2, but will now be a completely different measure and beat because of the modified TPQN. Then use "Set Measure/Beat at Now", then enter the measure number and beat that it is SUPPOSED to be, which will then reassign all the measure counting in the file.

 
Posted : 13/11/2024 7:25 am
Bavi_H
Posts: 267
Reputable Member
 

Posted by: Sean Harding
I'm trying to change the resolution of a MIDI sequence using Cakewalk (from 480 to 168 TPQN [...]) and I can't understand the instructions

I didn't see Sean Harding's post on October 27. It sounds like Sean Harding just wants to change the ticks per quarter note resolution of a MIDI file, without changing the tempos, the musical time positions in quarter notes, or the absolute time positions in seconds.

If that's what you want to do, then either Cakewalk or Sekaiju will let you do this, all you need to do is change the ticks per quarter note value and nothing else.

In Cakewalk: Go to the Edit menu and choose the Preferences command. At the bottom, make sure the "Advanced" radio button is selected. Under the Project category, go to Clock. Under the "Ticks per Quarter-Note" setting, choose the value you want, then click OK. Now you can Save or Save As the MIDI file.

In Sekaiju: Go to the File menu and Choose the Property command. In the section for Time Mode Resolution, make sure "TPQN Base" is selected, then change the Resolution [Ticks / Quarter Note] value to whatever you want, then click OK. Now you can Save or Save As the MIDI file.

When you change the ticks per quarter note value, Cakewalk or Sekaiju will update the tick positions every event to use the new resolution, but keep all the tempos, musical time positions in quarter notes, and absolute time positions in seconds the same.

(The earlier posts in this thread were about a different kind of transformation -- how to change the tempo value but keep the notes at the same absolute time positions in seconds.)

 
Posted : 13/11/2024 10:13 am
Share: