Creation Asylum Banner
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

"McTricky: Why the hell is your room so messy?
Phoenix: ......I was depressed."

McTricky & Phoenix
Quick Jump: The AsylumV | EntertainmentV | Game MakingV | Creative ForumV | Technology & ComputersV | TranslationsV

3 Pages V   1 2 3 >  
Reply to this topicStart new topic
> Loop MP3 music, The script that makes it possible
GubiD
post Apr 27 2008, 03:14 PM
Post #1


...meh...
Group Icon
Group Icon


Moderator

Member No.: 4,335
Posts Liked: 63 *
Joined: 7-August 06
Posts: 7,638
-->
From: Hue

RPG Maker Level:
Master

Class Title:
Scripting Nerd

Country:



Introduction
Ever want to have better audio but to still have loop functionality? This script will allow you to configure by song name a start/begin loop/end loop position that will allow you to achive looping regardless the file format. Be it MID, MP3, OGG, or WAV.

The script


Instructions
At line 35 you start "case @name", each when statement below there should contain the file name of the song you are trying to play. (Note: All song files must be in the Audio\BGM folder!)
When a song is specified "When 035-Dungeon01", then you can define 4 things: type, start, loop, fin

Type:
Type is the type of song it is. This generally doesn't matter UNLESS you are calling a "battle" during a "dungeon". When a "Battle" is called from a "Dungeon", the "Dungeon" is paused and will later be resumed when called again.

Start:
This is the location to start the song. If you want to skip the first 10 seconds, then you are more than welcome to do so.

Loop:
This will be the location in which the song resumes when FIN in reached.

Fin:
This is the "end of song" or "end of loop". When reached, this will "rewind" the song to "loop" position. If this position is exceeded because the game is inactive, it will loop when the song is complete.

If there is not a "When *" statement for the song, then it will use the default audio system and looping. Also be sure that file names specified here must contain no SPACES: 106 IGNITION = BAD, 106_IGNITION = Good
Also note that if your Windows Media Player supports the audio type, then you can update this script to use that audio type as well. Just update the "def name?" method to search for that file extension.

Note:
All time measurements are done in 1/1000 sec, so 1000 would be 1 second. Whenever the song "rewinds" it has about a .2 second rewind time.


DEMO!

This post has been edited by GubiD: Nov 23 2008, 07:06 PM






My Forums: SponAsylum.DynDns.org Minecraft Server: SponAsylum.DynDns.org
Help maintain the server by 'ing

My Intertubes Speeds
RM Stuff

Go to the top of the page
 
Thanks+Quote Post
Ratty524
post Apr 27 2008, 03:23 PM
Post #2


X-Treme
Group Icon


X-Treme

Member No.: 12,624
Posts Liked: 0 *
Joined: 1-February 08
Posts: 273
-->

RPG Maker Level:
Good

Class Title:
Artist

Country:



Sweet. Now I can do what all those commercial games do! :O



Lolz I joined a trend.


Go to the top of the page
 
Thanks+Quote Post
stupidstormy36
post Apr 27 2008, 04:25 PM
Post #3


X-Treme
Group Icon


X-Treme

Member No.: 12,823
Posts Liked: 0 *
Joined: 14-February 08
Posts: 230
-->
From: (Somewhere in hell), MA

RPG Maker Level:
Expert

Class Title:
Scripter, Graphic Artist, Debugger, Training myself to be a better writer.

Country:



Nice! I'll try it out now.

EDIT: Hmm, it doesn't seem to work with the mp3 file I have here. It doesn't loop.

Syntax


This post has been edited by stupidstormy36: Apr 27 2008, 04:39 PM





Last Update: Thursday, February 9th, 2012 (02/09/2012) at 6:24am (06:24) EST (US & Canada GMT -5)

StupidStormy36 (aka Stormy036) Current Projects Listings:

PLEASE NOTE:
I AM FINALLY BACK UP AND RUNNING. THANK YOU FOR BEING PATIENT. HOWEVER, PROGRESS ON ANY PROJECT WILL BE SPORADIC. I AGAIN ASK YOU TO BE PATIENT.


Current RMXP Project 1:

Star Ocean 3 CMS


Current RMXP Project 2:

Final Fantasy X CMS


Current RMXP Project 3:

Working Title


Current RMXP Project 4:

A Dumbass Adventure


Current RMXP Project 5:

Dynasty Warriors Tactics XP


Other Projects:

Other Projects


Terms of Use:

Terms of Use




Have Fun and See Ya!!!!!

Go to the top of the page
 
Thanks+Quote Post
GubiD
post Apr 27 2008, 10:20 PM
Post #4


...meh...
Group Icon
Group Icon


Moderator

Member No.: 4,335
Posts Liked: 63 *
Joined: 7-August 06
Posts: 7,638
-->
From: Hue

RPG Maker Level:
Master

Class Title:
Scripting Nerd

Country:



Should have mentioned that if the type is "Normal" then no looping will occur. It must be "Battle" or "Dungeon" for the looping to occur.






My Forums: SponAsylum.DynDns.org Minecraft Server: SponAsylum.DynDns.org
Help maintain the server by 'ing

My Intertubes Speeds
RM Stuff

Go to the top of the page
 
Thanks+Quote Post
chiem1000
post Apr 28 2008, 05:44 PM
Post #5


X-Treme
Group Icon


X-Treme

Member No.: 7,468
Posts Liked: 0 *
Joined: 17-March 07
Posts: 213
-->
From: Netherlands

RPG Maker Level:
Good

Class Title:
Animator, writer, Spriter, Scripter learner



hey i didn't saw this yesterday, but i see now :), i can use this ^^,thx Gubid ^^, just what i needed :P



I"M BACK!!!!!! <><><><><><><><>
I use VX now so :D

[br]Click here To feed me.. Please?!

Randomness

Go to the top of the page
 
Thanks+Quote Post
-Vilkku-
post Apr 29 2008, 12:25 AM
Post #6


X-Treme
Group Icon


X-Treme

Member No.: 6,793
Posts Liked: 0 *
Joined: 13-February 07
Posts: 350
-->
From: Finland

RPG Maker Level:
Master

Class Title:
Writer/2D Artist/Composer/Novice scripter

Country:



Wow! Something I requested a year ago! Thanks Gubid!
Or like my friend would say: WOWOMGTYM8




Go to the top of the page
 
Thanks+Quote Post
vikirosen
post Apr 29 2008, 03:41 AM
Post #7


Expert
Group Icon


Expert

Member No.: 12,635
Posts Liked: 0 *
Joined: 2-February 08
Posts: 172
-->
From: Nantes, France

RPG Maker Level:
Getting good

Class Title:
Writer, Scripter

Country:



I've actually been looking for something like this... Thanks a lot, GubiD!
I have a question though. Is it possible to trick the .2 delay when rewinding? I have yet to actually try the script (I'm downloading the demo now), but what does this .2 rewind time mean? Is it silence, or does the song exceed FIN by .2 seconds before it starts over from LOOP? If it is silence, is there maybe a way to fill it with something, anything?
Go to the top of the page
 
Thanks+Quote Post
GubiD
post Apr 29 2008, 07:32 PM
Post #8


...meh...
Group Icon
Group Icon


Moderator

Member No.: 4,335
Posts Liked: 63 *
Joined: 7-August 06
Posts: 7,638
-->
From: Hue

RPG Maker Level:
Master

Class Title:
Scripting Nerd

Country:



It is dead air, and its the seek from WMP that takes that amount of time. unless you can establish another stream to start as soon as the other hits fin, then you could fill that space. You can hear the "gap" in the demo as well. But if you have someone helping you create music, they could build something in and make it sound like it was meant to be that way.






My Forums: SponAsylum.DynDns.org Minecraft Server: SponAsylum.DynDns.org
Help maintain the server by 'ing

My Intertubes Speeds
RM Stuff

Go to the top of the page
 
Thanks+Quote Post
I_Can_Explode
post Apr 30 2008, 04:44 AM
Post #9


Member
Group Icon


Member

Member No.: 6,029
Posts Liked: 0 *
Joined: 4-January 07
Posts: 55
-->

RPG Maker Level:
Expert

Class Title:
Writer, Frankenscripter.



GubiD...you are so awesome.

This is a very useful script.
Go to the top of the page
 
Thanks+Quote Post
GoldenShadow
post Apr 30 2008, 05:26 AM
Post #10


The One
Group Icon


Crazy

Member No.: 755
Posts Liked: 29 *
Joined: 1-June 05
Posts: 5,122
-->
From: Holland, Europe

RPG Maker Level:
Good

Class Title:
Coder, Level Designer, Game Designer

Last.fm ID: LAST.FM SUCKS LOL

Country:



It's a very handy script you have there, I was developing one myself for ES, ran into some problems, so I don't know if you have the same:
- When main window loses focus, will music still be updated?
- When music transision occurs (from battle to map, for example), will it "clear cache" of the previous and update the new song normally?

On a sidenote, OGG files can have built-in LOOP flags compiled into them. I have yet to find any useful program to do so, but it certainly would beat having a script to check the (milli)seconds.

Anyway. I like the script, I'll be probably using it in my own project sooner than later. Great job. ^^



Even a sheet of paper has two sides.

Creation Asylum official unofficial Discord Server

Go to the top of the page
 
Thanks+Quote Post
GubiD
post Apr 30 2008, 08:03 AM
Post #11


...meh...
Group Icon
Group Icon


Moderator

Member No.: 4,335
Posts Liked: 63 *
Joined: 7-August 06
Posts: 7,638
-->
From: Hue

RPG Maker Level:
Master

Class Title:
Scripting Nerd

Country:



When focus is lost the music keeps playing until focus is returned in the "standard" fashion. By this I mean that it will continue playing until the EoF is reached and then return to 0 of the song.

When a song is replaced with a new one, it acquires the others memory space and hence, clears the cache.






My Forums: SponAsylum.DynDns.org Minecraft Server: SponAsylum.DynDns.org
Help maintain the server by 'ing

My Intertubes Speeds
RM Stuff

Go to the top of the page
 
Thanks+Quote Post
Chiem100
post May 1 2008, 03:23 AM
Post #12


Newbie
Group Icon


Newbie

Member No.: 13,582
Posts Liked: 0 *
Joined: 30-April 08
Posts: 11
-->

RPG Maker Level:
Good

Class Title:
Writer,Animator,spriter, scripter beginner



huh it doesnt work anymore ? (the script) and error whit ???

EDIT: Ugh nvm already fixed it

This post has been edited by Chiem100: May 1 2008, 03:24 AM
Go to the top of the page
 
Thanks+Quote Post
stupidstormy36
post May 9 2008, 05:41 PM
Post #13


X-Treme
Group Icon


X-Treme

Member No.: 12,823
Posts Liked: 0 *
Joined: 14-February 08
Posts: 230
-->
From: (Somewhere in hell), MA

RPG Maker Level:
Expert

Class Title:
Scripter, Graphic Artist, Debugger, Training myself to be a better writer.

Country:



I should have known it wasn't gonna loop. Sorry.

Ok I tried changing it to dungeon and now it won't play at all. I'll try a different MP3 file and see if that's the case.

Hmm. Does not seem to be working with any mp3 I use. Normal is the only thing that allows it to play.

Well at least one of my all time questions have been answered. Does ogg format support looping? And yes, it does. That's why it has to be completely loaded to play instead of mp3 where it supports streaming, right?

This post has been edited by stupidstormy36: May 11 2008, 10:35 AM





Last Update: Thursday, February 9th, 2012 (02/09/2012) at 6:24am (06:24) EST (US & Canada GMT -5)

StupidStormy36 (aka Stormy036) Current Projects Listings:

PLEASE NOTE:
I AM FINALLY BACK UP AND RUNNING. THANK YOU FOR BEING PATIENT. HOWEVER, PROGRESS ON ANY PROJECT WILL BE SPORADIC. I AGAIN ASK YOU TO BE PATIENT.


Current RMXP Project 1:

Star Ocean 3 CMS


Current RMXP Project 2:

Final Fantasy X CMS


Current RMXP Project 3:

Working Title


Current RMXP Project 4:

A Dumbass Adventure


Current RMXP Project 5:

Dynasty Warriors Tactics XP


Other Projects:

Other Projects


Terms of Use:

Terms of Use




Have Fun and See Ya!!!!!

Go to the top of the page
 
Thanks+Quote Post
GubiD
post May 11 2008, 09:17 PM
Post #14


...meh...
Group Icon
Group Icon


Moderator

Member No.: 4,335
Posts Liked: 63 *
Joined: 7-August 06
Posts: 7,638
-->
From: Hue

RPG Maker Level:
Master

Class Title:
Scripting Nerd

Country:



That is correct. If the song just doesnt play it is likely because it isnt in the BGM folder. If it is, then what are the time values you entered for start, loop and fin? perhaps you could provide me with the file if you cannot get it to work.






My Forums: SponAsylum.DynDns.org Minecraft Server: SponAsylum.DynDns.org
Help maintain the server by 'ing

My Intertubes Speeds
RM Stuff

Go to the top of the page
 
Thanks+Quote Post
stupidstormy36
post May 12 2008, 03:48 PM
Post #15


X-Treme
Group Icon


X-Treme

Member No.: 12,823
Posts Liked: 0 *
Joined: 14-February 08
Posts: 230
-->
From: (Somewhere in hell), MA

RPG Maker Level:
Expert

Class Title:
Scripter, Graphic Artist, Debugger, Training myself to be a better writer.

Country:



It is in the BGM folder and the values are as follows:

CODE
        when  "106 IGNITION"
          type = "Battle"
          start = 0
          loop = 1000
          fin = 15000



Here is the bgm.

MediaFire:
http://www.mediafire.com/?me00mkzy4iz

Sorry, I couldn't upload it as a direct download. File size too big.

It was only supposed to be a test.

Does file size have anything to do with it?

Also, do mp3 formats support different codecs? If so, is this the case as to why it is not working?





Last Update: Thursday, February 9th, 2012 (02/09/2012) at 6:24am (06:24) EST (US & Canada GMT -5)

StupidStormy36 (aka Stormy036) Current Projects Listings:

PLEASE NOTE:
I AM FINALLY BACK UP AND RUNNING. THANK YOU FOR BEING PATIENT. HOWEVER, PROGRESS ON ANY PROJECT WILL BE SPORADIC. I AGAIN ASK YOU TO BE PATIENT.


Current RMXP Project 1:

Star Ocean 3 CMS


Current RMXP Project 2:

Final Fantasy X CMS


Current RMXP Project 3:

Working Title


Current RMXP Project 4:

A Dumbass Adventure


Current RMXP Project 5:

Dynasty Warriors Tactics XP


Other Projects:

Other Projects


Terms of Use:

Terms of Use




Have Fun and See Ya!!!!!

Go to the top of the page
 
Thanks+Quote Post
GubiD
post May 13 2008, 03:10 PM
Post #16


...meh...
Group Icon
Group Icon


Moderator

Member No.: 4,335
Posts Liked: 63 *
Joined: 7-August 06
Posts: 7,638
-->
From: Hue

RPG Maker Level:
Master

Class Title:
Scripting Nerd

Country:



Hmm. You found an interesting bug. Its a bug but with how the filename is given to winmm.dll. It seems that if the name has a SPACE in it, then it wont work. Just rename it to have an _ in the name or a hyphen like all the default things and it should work for you.

As for the codecs thing. If it plays in Media Player it should work in here as well. We just called a private session of audio(from WinMediaPlayer) for the game is all.






My Forums: SponAsylum.DynDns.org Minecraft Server: SponAsylum.DynDns.org
Help maintain the server by 'ing

My Intertubes Speeds
RM Stuff

Go to the top of the page
 
Thanks+Quote Post
stupidstormy36
post May 13 2008, 06:53 PM
Post #17


X-Treme
Group Icon


X-Treme

Member No.: 12,823
Posts Liked: 0 *
Joined: 14-February 08
Posts: 230
-->
From: (Somewhere in hell), MA

RPG Maker Level:
Expert

Class Title:
Scripter, Graphic Artist, Debugger, Training myself to be a better writer.

Country:



Hmm, makes sense somehow to me seeing how the methods, constants, and variables are written the same way. OK, I'll try to add the underscore now.

I figured with the codec thing, though.

EDIT: Hey GubiD, I just realized, not too long ago,that I found out one of my mp3 files won't work in rmxp, even in a default script setup (meaning no edits to the scripting or addons what so ever), but will play in Media Player. That file seems to be the only one that doesn't work. Maybe it has something to with licensing or the id3 tags in the mp3 file seeing how the codec may not be the case here? Not sure. I'm not trying to imply anything, but just a thought and maybe something worth bringing attention to.

I haven't been able to try the other file by putting an underscore in the file name yet. I've been away for a while and not been using my own computer, but I will let you know if it worked for me as soon as I can.

I'm not a complete idiot when it comes to scripting and the syntax language, but I can understand a majority of the syntax when I sit down and actually have time to look at it. But I do have one more question. When you called a private session from WinMediaPlayer, where exactly did you call it from, the .exe file? How do you know how to call things like this from other programs? I would like to play around with such things as it seems very interesting.

Later and thanks for your help!

EDIT: OK! I got it to work now! Thanks a whole bunch. Anybody who else is having trouble, remember NO SPACES IN THE FILE NAME!

This post has been edited by stupidstormy36: May 16 2008, 10:17 PM





Last Update: Thursday, February 9th, 2012 (02/09/2012) at 6:24am (06:24) EST (US & Canada GMT -5)

StupidStormy36 (aka Stormy036) Current Projects Listings:

PLEASE NOTE:
I AM FINALLY BACK UP AND RUNNING. THANK YOU FOR BEING PATIENT. HOWEVER, PROGRESS ON ANY PROJECT WILL BE SPORADIC. I AGAIN ASK YOU TO BE PATIENT.


Current RMXP Project 1:

Star Ocean 3 CMS


Current RMXP Project 2:

Final Fantasy X CMS


Current RMXP Project 3:

Working Title


Current RMXP Project 4:

A Dumbass Adventure


Current RMXP Project 5:

Dynasty Warriors Tactics XP


Other Projects:

Other Projects


Terms of Use:

Terms of Use




Have Fun and See Ya!!!!!

Go to the top of the page
 
Thanks+Quote Post
pkmnfrk
post Jul 13 2008, 09:23 PM
Post #18


Newbie
Group Icon


Newbie

Member No.: 14,338
Posts Liked: 0 *
Joined: 13-July 08
Posts: 2
-->

RPG Maker Level:
Good

Class Title:
Scripter



Hi, new here. Sorry about the necro-post, but I'd like to point out a few fixes I made to the script to get it to work properly. First off, when I pasted it into RMXP, I got a bunch of syntax errors, from likes like this one:

CODE
    @play.call("Close all", "\" * 255, 255, 0)


The problem was the "\", which is not a string with a slash in it, but a string with a literal quote, that extends to the end of the line (where it errors). I searched and replaced all "\" with "\\", and then it worked.

The other problem was the "File with spaces won't play" issue. That was an easy fix, you just have to pass quotes to WinMM. Replace this line:

CODE
        @play.call("Open " + name + " alias " + type + " type MPEGVideo",


with this one:

CODE
        @play.call("Open \"" + name + "\" alias " + type + " type MPEGVideo",


Also, when it was finally working properly, I did not experience the delay in rewinding that others experienced. :shrug:

This is the full script with these problems fixed:

Full script
Go to the top of the page
 
Thanks+Quote Post
GubiD
post Jul 14 2008, 08:01 AM
Post #19


...meh...
Group Icon
Group Icon


Moderator

Member No.: 4,335
Posts Liked: 63 *
Joined: 7-August 06
Posts: 7,638
-->
From: Hue

RPG Maker Level:
Master

Class Title:
Scripting Nerd

Country:



Cool, thanks for the review and the code refinement. This was my first script actually editing and playing with DLL's outside of the application. It was an adventure to say the least. Thanks again.






My Forums: SponAsylum.DynDns.org Minecraft Server: SponAsylum.DynDns.org
Help maintain the server by 'ing

My Intertubes Speeds
RM Stuff

Go to the top of the page
 
Thanks+Quote Post
pkmnfrk
post Jul 14 2008, 08:10 AM
Post #20


Newbie
Group Icon


Newbie

Member No.: 14,338
Posts Liked: 0 *
Joined: 13-July 08
Posts: 2
-->

RPG Maker Level:
Good

Class Title:
Scripter



No problem!

Also, I just realized that you're the same one who made the Tactical Battle System, which I am also using in my game. Cool! Thank you for all your efforts!
Go to the top of the page
 
Thanks+Quote Post

3 Pages V   1 2 3 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- The Staff Team Lo-Fi Version Time is now: 11th December 2020 - 02:28 PM