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 }


Messages In This Thread
MP3 loop performance - by cogwheel - 03-05-2008, 06:32 AM
RE: MP3 loop performance - by Taylor - 03-20-2011, 02:36 AM
RE: MP3 loop performance - by DerVVulfman - 03-20-2011, 04:33 AM
RE: MP3 loop performance - by yamina-chan - 03-20-2011, 01:13 PM
RE: MP3 loop performance - by Taylor - 03-20-2011, 05:38 AM
RE: MP3 loop performance - by Victor Sant - 03-20-2011, 10:30 PM
RE: MP3 loop performance - by Taylor - 03-20-2011, 11:00 PM
RE: MP3 loop performance - by DerVVulfman - 03-22-2011, 05:24 AM
RE: MP3 loop performance - by Espon - 03-22-2011, 10:18 AM
RE: MP3 loop performance - by xnadvance - 06-06-2011, 02:46 AM
MP3 loop performance - by MFBMR - 03-22-2010, 08:47 AM
MP3 loop performance - by DerVVulfman - 03-22-2010, 09:59 PM
MP3 loop performance - by DerVVulfman - 07-11-2010, 04:04 AM
MP3 loop performance - by DerVVulfman - 10-14-2010, 03:35 AM



Users browsing this thread: 2 Guest(s)