Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 MP3 loop performance
#1
MP3 loop performance
Version: 1.03
Originally posted at http://members.jcom.home.ne.jp/cogwheel/


Introduction
This script allows you to play music files up to 'designated' points you establish and loop them accordingly. If you have a long intro or fanfare in your piece and don't want the music to repeat the fanfare, you can tell it to loop back to a later start position. You don't want it to go to the end of the file, tell it so.

Included here is a script to create an editor for use with the system.

*A correction was made in the English version.


Screenshot
[Image: mp3.jpg]
(Image from the editor script.)


Script
Japanese Originals
MP3 Player Editor
MP3 Loop System (the Engine)
MP3 Game_System sample

English Versions
MP3 Player Editor
MP3 Loop System (the Engine)
MP3 Game_System sample



Demo
MP3 Player Editor Demo


Add-On Help Window
Help Window Addon


Usage

Well, place the MP3 Loop script (the engine) above MAIN or below SCENE_DEBUG, with the Game_System sample script * directly underneath.

* The Editor script can generate a Game_System sample script for you.


Editing the Game_System sample script

when "satoc-boss09-2"
The name within the quotes is the name of the music file in question. It may be either mp3, ogg, wav and/or mid.

type = "Battle"
This determines the type of music file.
Normally, music is defaulted to 'Normal' indicating no custom looping is involved. However, the values of "Dungeon", "Battle" and "Other" are valid and can permit custom looping that this script allows.

START = 0
loop = 96040
fin = 202680


The START value sets the start position for the music playback rather than having the music start from the beginning of the file. Simple.

The LOOP value sets the position in the 'loop' where the music returns. When looping, the music will restart at this point rather than starting over from the beginning of the music file.

And the FIN (French for 'End') value sets the position in the 'loop' that forces the playback to rebound back to the beginning of the loop. Once the system hits the FIN value, the music will loop back and restart at the LOOP position

All values are measured in milliseconds.




Notes
  • The system does not like lowercase letters or spaces in the filenames.
  • When multiple actions are occuring, looping may not be totally accurate. Playback may not be perfect when various activities are occurring in-game.
  • If the position set in the 'FIN' value exceeds the maximum length of the music file, looping cannot be performed.
  • Compressed music files may not loop as accurately as uncompressed files. The higher a compression rate, the less accurate the loop.
  • The music pitch function may not function on music files defined as looping files.


IMPORTANT:
While .Ogg files are usable, PCs may not recognize Ogg Vorbis files as a playable music format. If media player and your Win32API.dll cannot play .ogg files, you may find a need to download a codex (decoder) to play them. Such a codex file may be found (>HERE<). Otherwise, you can always use .mp3 or .wma files.

While you can loop .Mid files with this system, the script will bypass the directX system to accomplish this. When playing files set to 'Dungeon', 'Battle' and/or 'Other', the music played by .mid will use the Windows soundfonts rather than the soundfonts in the DirectX library.

A minor fix was made in the Game_System sample script and the editor that generated Game_System code. This fix prevented (none) audio files from crashing the project.


* * * * *

The Editor System
The 'Editor' script includes both a menu system that takes over your project and includes a copy of the MP3_Loop script. It can generate a Game_System script you can use after you select the start, fin and loop positions for your music files.

Only music files stored within your Audio\BGM folder will show up within the menu. If there are no music files within the Audio\BGM folder, you will receive an error.



Compatability
This will alter systems that play music in your project, rewriting the play_bgm method.



Credits and Thanks
Thanks to Cogwheel for coding this script.


Terms and Conditions
Terms and Conditions
Reply }
#2
Can you make it for vx?
Reply }
#3
He did. (>CLICK ME<)
Reply }
#4
For those interested, I edited the first post and included an add-on in a spoiler. It's a little help window for first time users of the editor.

Couldn't hurt. :cheery:
Reply }
#5
A correction has been made to the system. As of now, it DOES accept spaces and lowercase letters. For some reason, this also fixed (dunno why) the .ogg looping.

When it cycles back to the start of a loop, the .ogg music file may suffer a 0.5 delay, but it's streaming audio now.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png] [Image: liM4ikn.png] [Image: fdzKgZA.png] [Image: sj0H81z.png]
[Image: QL7oRau.png] [Image: uSqjY09.png] [Image: GAA3qE9.png] [Image: 2Hmnx1G.png] [Image: BwtNdKw.png%5B]
Above are clickable links

Reply }
#6
Sorry if this counts as a bump, I don't suppose you know why there is a rather audible (or maybe it's just me being a perfectionist) gap when a loop restarts in mp3s?

This is kinda frustrating. I started off with a combination of MEs and BGMs to create a looping section and would (depending on my luck) have a slight jump at the start, but be good from then on. With this system it's the other way around, the jump is at the end of the loop.

Enterbraaaaaaaaain, why did you have to make Audio and Graphics hidden.

hi vvulf
Reply }
#7
An audible gap in .mp3? There is one for .ogg that I'm aware and was even noted by others. Yours is the first statement of an audible mp3 format gap.

A few questions. Is it your music that you've done? Was it music in the demo? I really looked to time the gaps in Mark II from IronMan. Yep the movie soundtrack. Perhaps it's a different PC Operating system? I still sport Windows XP and I'm aware of some audio issues with Win7. Have you tried .wma?

And yeah.... I wish you could cache music and SEs lke graphics.

BTW: Hey, Jirby.

Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png] [Image: liM4ikn.png] [Image: fdzKgZA.png] [Image: sj0H81z.png]
[Image: QL7oRau.png] [Image: uSqjY09.png] [Image: GAA3qE9.png] [Image: 2Hmnx1G.png] [Image: BwtNdKw.png%5B]
Above are clickable links

Reply }
#8
Oh, I thought you were aware of it? In the help file it talks about a slight jump before the looping section restarts. This is what happens with me. This is why I asked if you knew why it happened.

I tried to time the looping segments with parts that would sound okay with it, but it's still jarring. The example you mentioned - I think that was constructed in a way that made the jump unnoticeable.

On another note, I've found that the jump in my ME-BGM technique is noticeable after I've started something like Photoshop. Even closing it, even with 50FPS (what I've got my game set to), that jump will remain until a restart. Before that it is absolutely seamless.
Reply }
#9
(03-20-2011, 04:33 AM)DerVVulfman Wrote: An audible gap in .mp3? There is one for .ogg that I'm aware and was even noted by others. Yours is the first statement of an audible mp3 format gap.

A few questions. Is it your music that you've done? Was it music in the demo? I really looked to time the gaps in Mark II from IronMan. Yep the movie soundtrack. Perhaps it's a different PC Operating system? I still sport Windows XP and I'm aware of some audio issues with Win7. Have you tried .wma?

And yeah.... I wish you could cache music and SEs lke graphics.

BTW: Hey, Jirby.
Since you're bringing it up, I want to point out that .wma files don't play with this system.
At least not on my PC.
Friendship is born at that moment when one person says to another: "What! You, too? Thought I was the only one." (C.S. Lewis)
For the time you're laughing, there's nothing wrong in the world. (Colin Mochrie)

If it's funny, make sure people laugh. If it's not funny, make it funny (unless it's actually really serious). (silvercheers)

Please don't spell my name "Yamina-chan". It's all small. Thank you =D
Reply }
#10
Just an comment... why use .mp3? Midis *well made* can sound great, can be easly loopable, and aren't heavy as hell.
The "good quality" of MP3 don't make it for their high size and bad looping.
Also it's really disapointing download an 100MB game, and see that 80MBs are only for 10-25 musics.
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Victor Engine - Loop Animation Victor Sant 0 4,190 01-01-2012, 02:23 PM
Last Post: Victor Sant
   MP3 loop performance cogwheel 0 4,391 03-06-2008, 04:35 AM
Last Post: cogwheel



Users browsing this thread: