[2001/11/10] [MIDI series] *** RPG MAKER 2000 TUTORIAL *** HOW TO LOOP MIDI FILES AT A CUSTOM POSITION by BadSector ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ I once wanted to use premade MIDIs like those on vgmusic.com, or eventually compose my own soundrack. I imported a midi version of the Final Fantasy 2 battle theme which in the original game starts by an intro, and then the rest of the tune loops until the battle finishes. The MIDI standard does not include such a feature, because it was meant for simple communication between musical instruments and computers, not to serve as a video game soundtrack. Due to the lack of technical information about the way RM2K interprets media and resource files, I tried to figure out myself. Here's what I found. MIDI uses special events named controllers in order to add special effects such as portamento, volume, modulator wheel, et caetera. These are stocked in the MIDI file the same way as note events. ASCII only chose an unused event (111) for the loopback position. When the music is finished, instead of looping at the beginning of the song, it takes you back to the place it saw the 111 controller before. Every original ASCII RTP midi files have this controller at the looping position, track 1, channel 1. Now how to add an 111 controller? Many MIDI editors have a raw MIDI code viewer utility which show every codes used in the MIDI file, its position, its track, its MIDI channel, et caetera. The editor I use is CakeWalk SONAR. The operations I will describe are for this software. You can get the 30-day trial version at this URL : http://www.cakewalk.com/download/ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ *** VERY IMPORTANT! make a backup of the MIDI file you are trying to alter. If you find your tune all screwed up, don't blame me! :-P First, start SONAR and close the sample project window that appears. Open the midi file (in the File menu) and look at the track manager (the one that just popped up when you opened the midi file.) Play the song (spacebar) and note the measure number (above the tracks) where you want to loop your tune. Positions in midi are counted as MBT, or Measure Beat Tick. Measures are generally made of 4 beats, which beat is made of 100 ticks. Generally you'll want loop at the beginning of a measure so just know the measure in question. Select "Series of controllers" from the Insert menu. There, select the "Controller" radio button, The Number is 111, the MIDI channel is 1, the Value Range is 0 in the "begin" field and 0 in the End field also. Both time ranges are "X:01:000", where X is the measure where you want the music to loop. For example, if your song has to return to measure 3 when finished, just enter in the two fields "3:01:000". Now click OK, and save the tune! That's all! The music won't loop when you play it in SONAR or any MIDI player, but try it in RM2K! ;-) If you want to make it loop at another place than the beginning of a measure, then you'll need to be more attentive to the song's timing, because every tune has different timing rules. But these cases are pretty rare! One problem remaining. Some MIDI files use a lot of controls in their conception. As RPG Maker 2000 only move the position of the MIDI engine while doing loops (and even while switching between songs,) it happens that controllers such as volume and pitch bend remains at the same value as it was before, which is not necessarily the same value as the song's default settings; it could have changed values during the MIDI playback, and as long as there are no event placed to set these controls to their original value, the notes played at the beginning of a tune could inherit the controller values of the previous note. If the folk who wrote the MIDI file didn't think about looping the song, he(she) did not matter about resetting the channels default controls at the beginning of the looping measure. Some default settings are in the track's original definition (left part of the tracks window), and some are at the early part of event changes. To see a list of every raw event happening during the playback of the MIDI sequence, press ALT+4 to open the event list window, and press T in that window to change between tracks. Anyway, that will be the purpose of my next MIDI technical tutorial. So just don't blame me if your song loops but the music is messed up after the loop! ;-P