[Complete][Dev] Easy Audio Looping

Currently finalizing a plugin that allows developers to loop their audio by simply making a script call, or providing a text file




Rather than relying on the ogg reader to handle the looping for you, you could just go and write down when you want the loop to occur.


For example, if you're a composer and you want to loop your audio, you could just provide a text file with the loop settings, which the plugin will read and use during the game.


I have two basic uses cases


1. Specify looping in a text file


2. Specify looping during an event


I'm not sure how useful the second one would be, but since I started with it I figured I might as well leave it in.


You could also potentially have multiple loop settings for different purposes, though I'm not sure how common that is.
Sounds nice ! It will be very useful to be able to loop the same file at different places. Will we be able to loop for example between time A and time B, not necessarily from the start ?
Sounds nice ! It will be very useful to be able to loop the same file at different places. Will we be able to loop for example between time A and time B, not necessarily from the start ?
Originally the plan was to simply provide a way to write down loop points in a text file.

I may expand it to include audio offsets.

I call these "audio profiles".

A profile is basically a set of premade configuration settings for a particular audio.

For example, let's say you had your Battle1 BGM, with the following settings:

Battle1_normal,samples,0,320796,2822198Battle1_looped,samples,132300,132300,1238244The first value is the name of your profile. It is just any name that you choose.The second value is the measurement unit. I am planning to support both seconds and samples. MV uses seconds by default, but some people requested samples since it's more precise.

The third value is where the audio will start playing.

The fourth value is the start the loop

The fifth value is the length of the loop

I have not determined whether I will have people specify "start and end" or "start and length" (or both).

Before you play an audio, you can make a script call to load in an audio profile. When the audio is played, the appropriate settings will be loaded as well.

I am only planning to support BGM at the moment but may expand it to support other types of audio.
It seems really practical too, nice ! I will probably use it when I'll start doing my own soundtracks.
Here are the specifications for my audio looping plugin. I will be using a file-based format.

Setting up your data

This is how you will set it up.

Start by downloading the "template" I provide, which will look like this:

Profile Name,Audio Folder,Audio Name,Measure Unit,Loop Start,Loop Duration,Start PositionBattle_normal,Bgm,Battle1,samples,44100,4321393,0It can be edited in spreadsheet software like Excel.Profile name is the identifier for the entry. You will use this in the game to set up additional audio properties.

Audio folder is the name of the folder the music is found. This probably will always be BGM unless you want to loop ME or BGS.

I only include this in case people want more than just bgm looping.

The Audio Name is the exact name of the file, without the extension

Measure Unit will either be "samples" or "seconds"

Loop Start is the position in the track that the loop will begin. The unit will be in either samples or seconds depending on what you chose for the measure unit.

Loop Duration is how long the loop section is. The unit will be in either samples or seconds depending on what you chose for the measure unit.

The Start Position is where the song will begin. So for example, if this song should always start at the loop start, or anywhere you want. Again, unit is based on your measure unit.

Providing Input to Plugin

The expected input format will be JSON, but you can build it in a spreadsheet, export to CSV, and then convert the CSV to JSON using a plethora of tools available

Like this: http://www.csvjson.com/csv2json

After building your CSV file, you would run it through the CSV to JSON tools and get this

[ { "Profile Name": "Battle_normal", "Audio Folder": "Bgm", "Audio Name": "Battle1", "Measure Unit": "samples", "Loop Start": 44100, "Loop Duration": 4321393, "Start Position": 0 }]Using it in your projectLet's say you wanted to use a specific audio profile for your battle music for a specific boss battle.

You would make the following plugin command

load_audio_profile NAME_OF_AUDIO_PROFILETo load the appropriate profile.Then, the next time the audio plays, it will run with your new profile.
That's great !

This is exactly that I want.
Done




Writing up documentation.


Only works with WebAudio since HTML5 audio seems pretty limited.

Original thread: https://forums.rpgmakerweb.com/threads/complete-dev-easy-audio-looping.50383/