mp3 file's duration?

Rime

Veteran
Veteran
Joined
Jul 12, 2014
Messages
37
Reaction score
11
Primarily Uses
Is there a way to get an mp3 file's duration without having the user to specify it?

Alternatively, is there a way to make RPG::BGM.play only do it once (instead of looped), and run a check if the file is still being played?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
I can do that in midi files. But I never tried in mp3 or ogg. The basic concept is to put the music loop at the end of the music so that they won't be looped. AFAIK, RGSS3 can not get the mp3 file duration. But dunno.
 

Rime

Veteran
Veteran
Joined
Jul 12, 2014
Messages
37
Reaction score
11
Primarily Uses
I see. Well, if that's the case, is there a way to stop making the BGM play while the game is not focused (Alt+Tab)? 

in an unrelated note, I've also noticed that there's some short lag (~1s) that occurs when loading something from a module for the first time. This lag disappears after the first occurrence though. Is there a way to preload modules when the game starts?
 

cremnophobia

Veteran
Veteran
Joined
Dec 10, 2013
Messages
216
Reaction score
97
Primarily Uses
I see. Well, if that's the case, is there a way to stop making the BGM play while the game is not focused (Alt+Tab)?
http://forums.rpgmakerweb.com/index.php?/topic/33744-pausing-bgmsounds-when-game-window-is-defocused/?p=330944
in an unrelated note, I've also noticed that there's some short lag (~1s) that occurs when loading something from a module for the first time. This lag disappears after the first occurrence though. Is there a way to preload modules when the game starts?
By modules, you mean MIDI, don't you? They are known to cause some loading time issues under newer Windows versions (Vista+). In VX Ace they are disabled by default. So when a MIDI is played for the first time, not only the file has to be read, but also all required stuff to play it has to be initialized. There is an option to do that at startup. It can be found in the database, system tab.
 

Kaelan

Veteran
Veteran
Joined
May 14, 2012
Messages
797
Reaction score
537
First Language
Portuguese
Primarily Uses
RMMV
I've tried looking for a way to do that before and, I've never found anything; there's no way that I know of to find whether something is playing. If you absolutely need something to only play once, and need to know when it's done playing, the hacky solution is to use Audio.bgm_pos to find a position near the end of the song and wait for that to be reached, then do whatever you need to do when that happens. I don't know if there's any better solution to that problem, given how RM Audio works (I think there were some FMOD plugins for RM around, maybe those would do the job?).
 

Rime

Veteran
Veteran
Joined
Jul 12, 2014
Messages
37
Reaction score
11
Primarily Uses
 

By modules, you mean MIDI, don't you? They are known to cause some loading time issues under newer Windows versions (Vista+). In VX Ace they are disabled by default. So when a MIDI is played for the first time, not only the file has to be read, but also all required stuff to play it has to be initialized. There is an option to do that at startup. It can be found in the database, system tab.
by modules, I meant Script modules where the script's constants are placed. 

module RIMETHIS_IS_A_CONSTANT = 1endwhen a script calls the constant through RIME::THIS_IS_A_CONSTANT, it produces a ~1s lag the first time it's called. This lag doesn't appear when called after the first time.

I've tried looking for a way to do that before and, I've never found anything; there's no way that I know of to find whether something is playing. If you absolutely need something to only play once, and need to know when it's done playing, the hacky solution is to use Audio.bgm_pos to find a position near the end of the song and wait for that to be reached, then do whatever you need to do when that happens. I don't know if there's any better solution to that problem, given how RM Audio works (I think there were some FMOD plugins for RM around, maybe those would do the job?).
Thanks. With your idea I just declared a variable @play_time and stops the audio when it reaches a user-specified Audio.bgm_pos indicating the duration of the bgm.
 
Last edited by a moderator:

cremnophobia

Veteran
Veteran
Joined
Dec 10, 2013
Messages
216
Reaction score
97
Primarily Uses
by modules, I meant Script modules where the script's constants are placed. 

Code:
module RIMETHIS_IS_A_CONSTANT = 1end
when a script calls the constant through RIME::THIS_IS_A_CONSTANT, it produces a ~1s lag the first time it's called. This lag doesn't appear when called after the first time.
It kinda makes sense, since the Ruby VM caches the value (1), and if the cache wasn't invalidated in the meantime, it simply retrieves the value directly from the cache, but it shouldn't be *that* noticeable. Without more info, I can't help you out here.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top