Jump to content

How To: Seamlessly Looping Music


Recommended Posts

How To: Seamlessly Looping Music
This guide will detail how you can make the music (and other sound) in your fangame using Pokémon Essentials loop at specified loop points, allowing for an ideally seamless loop. The guide is written such that these steps should work for both mkxp-z and regular RPG Maker XP. Some of the steps do not necessarily need to be followed in all specifics depending on your setup, however following them should guarantee success.

 

Setup

Before you can start working on adding loop points, there is some setup work to be done.

 

1. Download Audacity and ffmpeg. Both are free, open-source software available for all desktop operating systems.

 

2. Add ffmpeg to your environment variables. On Windows, you can do this by searching for environment variables, opening Edit the system environment variables, clicking on Environment Variables..., scrolling to Path on the top or bottom table (top is for just your user account, bottom for all), double-clicking path, clicking New in the newly opened window and writing down the path to the folder in which you put ffmpeg. Specify the location of the folder containing ffmpeg, i.e. don't include ffmpeg.exe in your input. A restart is required for this change to take effect. If you need further help, there should be other online resources regarding adding programs to Path.

 

3. Open Audacity. On the bottom of the window, you should see two boxes labelled with Selection. Click on the arrow on the right-hand side of both boxes and select samples for both. Additionally, click on Edit > Preferences. On Audio Settings > Quality set Default Sample Rate: to 44100Hz.

 

4. If your project is not using mkxp-z: You need to add RGSS FmodEx extension to your project. Paste the downloaded files into the root of your project as described.

 

Making It Loop

Now comes the actual hard part: Finding and setting the right loop points. Generally, this is done by adding two metadata fields to the audio file: LOOPSTART and LOOPLENGTH. Note that the capitalisation is important.

 

1. Open the audio file you want to set loop points for in Audacity.


2. Listen to the audio and see if there is already a point where it loops. This is usually the case, though there may or may not be minor differences on the second loop, if one is baked into the audio file.

 

If there is:

3a. Zoom in at the end of the loop and find a visually distinct point. You can usually find these right at the start of a drum kit sound. Zoom in until the wave changes into individual points (samples). Set the playback position at a sample that is as close to 0 amplitude (the middle) on one (or both) channels (channels being left or right ear, left is the upper one) as possible. Be careful to not accidentally edit the sample by clicking directly on it. Press CTRL+B to place a marker. You can name it however you want.


4a. Find the same spot at the beginning of the loop. Note that the wave/ samples are unlikely to be a 100% match due to compression and other factors but if you chose a sufficiently visually distinct point you should still be able to find it. Once again, make sure it is as close to 0 amplitude on the same channel as possible and place a marker.

 

If there is not:

3b. Determine two parts for the beginning and end of your loop that you think are closest together in sound. Remove the audio past the end of your desired loop. Copy the beginning of that part to right after the end of the loop.

 

4b. Select a desired region for crossfading. You may need to experiment. To apply the crossfading, click Effect > Fading > Crossfade Clips.

 

5. You can test your selection by selecting the region of the loop and enabling looping (button next to the record button). Make sure you made a looping region selection (indicated by black triangles at the start and end of your selection) rather than a "regular" selection.


6. Make a selection from the first to the second marker. Audacity should snap your selection as long as you are close to the markers.


7. Note the sample count of the start and length of your selection. You can optionally save the Audacity project.

If you cut the remainder of the audio file to save file size: Your selection may sometimes extend one sample beyond the end of the track. If this happens and you use that length, the track will not loop. Decreasing the LOOPLENGTH value by one should fix that.


8.

If your original audio file was a .ogg file:

In a CLI (such as Command Prompt on Windows), type:

ffmpeg -i "name of input file.ogg" -metadata LOOPSTART="beginning of your selection" -metadata LOOPLENGTH="length of your selection" -codec copy "name of output file.ogg"

Note that the output file name needs to be distinct from the input file name.

 

If your original audio file was not a .ogg file:

Since the file needs to be re-encoded anyway to be in .ogg format, there is no need to use ffmpeg to keep the encoding. In this case you can click on Edit > Metadata in Audacity and add two metadata fields named LOOPSTART and LOOPLENGTH with the corresponding sample counts. Then click on File > Export Audio and select Ogg Vorbis Files as the Format. Make sure the Sample Rate is set to 44100Hz.


9. Replace the input file with the output file. Depending on your project setup, you may or may not need to change occurrences of the audio file in your project to the new file extension if the file extension changed.

 

10. Done!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...