Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Plugin Easy Audio Looping

Tsukihime

Praised Adventurer
Xy$
0.00

While I was trying to figure out how to make audio play instantly, I noticed the OGG parsing functions and saw it was reading loop metadata.

And then I thought, what if we could provide our own, in-game?
 

Zebestian

The Artist formerly known as Kaimen
Resource Team
Now if that doesn't save me as audio creator a whole bunch of time, I don't know what will. Awesome. Amazing even! :D
 

Tsukihime

Praised Adventurer
Xy$
0.00
Now if that doesn't save me as audio creator a whole bunch of time, I don't know what will. Awesome. Amazing even! :D
Do you think it would be useful to have functions that automatically play music at a certain position?
 

Zebestian

The Artist formerly known as Kaimen
Resource Team
Do you think it would be useful to have functions that automatically play music at a certain position?
A certain position? As in on a map? I could imagine that being useful if you want to have dynamic music. Don't know if you've played Banjo-Kazooie but the Gruntilda's Lair theme changed version depending on where you were.
 

Tsukihime

Praised Adventurer
Xy$
0.00
A certain position? As in on a map? I could imagine that being useful if you want to have dynamic music. Don't know if you've played Banjo-Kazooie but the Gruntilda's Lair theme changed version depending on where you were.
Sorry, I meant position in the track.
Position seeking.
 

Zebestian

The Artist formerly known as Kaimen
Resource Team
Sorry, I meant position in the track.
Position seeking.
That would be useful just as much. I could imagine skipping the intro to a song if it doesn't fit the scene but the rest of the song does. Think a battle theme that starts calmly and only gets interesting after a minute. :)

Edit: Anything that saves audio editing is basically a good thing. :D
 
Last edited:

Tsukihime

Praised Adventurer
Xy$
0.00
That would be useful just as much. I could imagine skipping the intro to a song if it doesn't fit the scene but the rest of the song does. Think a battle theme that starts calmly and only gets interesting after a minute. :)

Edit: Anything that saves audio editing is basically a good thing. :D
When setting up audio loops, how do you usually set it up? What units of measurement do you use? Do you set the start and end, or do you set the start and then specify the duration?

I'm currently having users specify loop start and end in seconds (eg: start at 5 seconds, end at 8.34 seconds)

I'm taking sample rate out of the picture and normalizing things to seconds, since that's what RM does.
 

Zebestian

The Artist formerly known as Kaimen
Resource Team
When setting up audio loops, how do you usually set it up? What units of measurement do you use? Do you set the start and end, or do you set the start and then specify the duration?

I'm currently having users specify loop start and end in seconds (eg: start at 5 seconds, end at 8.34 seconds)

I'm taking sample rate out of the picture and normalizing things to seconds, since that's what RM does.
When I'm making looping .oggs I always go with samples. I tell the track to start the loop after X samples and let it go on for Y samples. If RM goes with the time code in seconds then I guess that's as accurate as you can get. For the average user, samples would be too confusing anyway, I'd wager.
 

Tsukihime

Praised Adventurer
Xy$
0.00
I could work with samples, as I'm planning to provide a standard text file for users to set up their loop points for different files, and you could then distribute those with the files if necessary. This means if someone for example wants you to help them loop something, you can just give them the loop data instead of a whole file.

When RM's reading your loop data, it's taking the sample and dividing it by the sample rate, so I can just tell it to divide it by the sample rate as well if the data is provided in samples.

I suppose it would be best to offer two options

1. Provide it in seconds, if that's enough
2. Provide it in samples, if you require the precision

If you were to set loop points, when do you expect the engine to stop looping and proceed to finish?
 

Zebestian

The Artist formerly known as Kaimen
Resource Team
I suppose it would be best to offer two options

1. Provide it in seconds, if that's enough
2. Provide it in samples, if you require the precision
Sounds good and easy enough. And you can always provide tutorials if people want to use the samples method. :)

If you were to set loop points, when do you expect the engine to stop looping and proceed to finish?
I'd say that depends on what part of a song you want to loop and when. Normally, in RM, songs loop infinitely between two set points until a new song is played. So, your plugin would loop somewhere inside that loop. I'd say it would be best, sound-wise, to just have it complete the loop and then go back to the initial looping. If that is what you meant. :D
 

Tsukihime

Praised Adventurer
Xy$
0.00
Do you know if anyone would need to do something like this?

1. Intro
2. Loop 1
3. Transition to part 2
4. Loop 2
5. Ending

I've seen this done in flash movies before, where they loop a particular scene for some time, and then after you hit "continue" it will proceed to the next scene. I'm assuming this is done for optimization purposes so that you could distribute one movie and just set loop points and seek points inside it, but I don't know if it's something that people do for music.
 

Zebestian

The Artist formerly known as Kaimen
Resource Team
Do you know if anyone would need to do something like this?

1. Intro
2. Loop 1
3. Transition to part 2
4. Loop 2
5. Ending
I could see this being useful for a lengthy scene where you would have to change soundtracks to fit the mood a lot. With this method you could have a more seamless musical background to accompany the scene. So instead of changing between multiple soundtracks, you have one big one with different loops.
I must admit though, not being a dev and only a musician, I don't know if that would actually something people would do in a game.
 

Tsukihime

Praised Adventurer
Xy$
0.00
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:

Code:
Profile Name,Audio Folder,Audio Name,Measure Unit,Loop Start,Loop Duration,Start Position
Battle_normal,Bgm,Battle1,samples,44100,4321393,0
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

Code:
[
  {
    "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 project

Let'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

Code:
load_audio_profile NAME_OF_AUDIO_PROFILE
To load the appropriate profile.
Then, the next time the audio plays, it will run with your new profile.

[doublepost=1447471908,1447443960][/doublepost]Finishing up. Supports custom start offset and looping. Multiple profiles can be set up for the same track if needed.
 
Top