mp3 file's duration?

● ARCHIVED · READ-ONLY
Started by Rime 7 posts View original ↗
  1. 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?
  2. 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.
  3. 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?
  4. Rime said:
    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
    Rime said:
    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.
  5. 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?).
  6.  

    cremnophobia said:
    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.

    Kaelan said:
    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.
  7. Rime said:
    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.