RMMV Trying to find the duration of a sound effect. How can I access WebAudio attributes?

Oatilis

Veteran
Veteran
Joined
Mar 16, 2016
Messages
41
Reaction score
15
First Language
Hebrew
Primarily Uses
Hey guys, I want to get the duration (play length) of a sound effect which is being played.
I've looked into:

JavaScript:
AudioManager.playSe
AudioManager.createBuffer
AudioManager.updateBufferParameters

I tried printing to console fields from WebAudio class, like totalTime, loopLength etc, but it seems like the WebAudio is still not fully populated in these functions, and all I get is null or undefined values (however, printing the buffer to console I can see the values populated, I guess this happens later).

I've been banging my head for a while now! How can I access the actual Web Audio data?
 

akoniti

Veteran
Veteran
Joined
Mar 4, 2020
Messages
140
Reaction score
127
First Language
English
Primarily Uses
RMMV
One approach would be to open the audio file in a media player (e.g. VLC) and view the length of the track.

You should see the file in the audio/se folder.

I may be misunderstanding your need, but this would be the easiest approach to finding the length I can think of.

EDIT: Also, what's the usecase for the track length?
 

Oatilis

Veteran
Veteran
Joined
Mar 16, 2016
Messages
41
Reaction score
15
First Language
Hebrew
Primarily Uses
One approach would be to open the audio file in a media player (e.g. VLC) and view the length of the track.

You should see the file in the audio/se folder.

I may be misunderstanding your need, but this would be the easiest approach to finding the length I can think of.

I need to get the length while the game is running because I'm using it to close the text window after a voiceover has finished playing.
 

akoniti

Veteran
Veteran
Joined
Mar 4, 2020
Messages
140
Reaction score
127
First Language
English
Primarily Uses
RMMV
Ahh, I see. You could add a Wait command (based on length of SE) after you initiate the SE, then close the window.
 

Oatilis

Veteran
Veteran
Joined
Mar 16, 2016
Messages
41
Reaction score
15
First Language
Hebrew
Primarily Uses
Ahh, I see. You could add a Wait command (based on length of SE) after you initiate the SE, then close the window.
I don't want to manually enter each file length - I want to program it in automatically. I know my way around events well enough, looking for a JS solution to this.
 

Latest Threads

Latest Posts

Latest Profile Posts

I am adamant about not having missable quests, which means having to write entirely new scenes at each plot progression that takes into account that time and events have passed since the quest could first be accepted while still having there be a quest to solve in the first place. It's worth every second.
Surprisingly useful and thought provoking
Working on animation. Trying to see if I can apply it meaningfully to my games!
ddwk.png

working on the sprite for Devali <3
My Game Development Livestream

Forum statistics

Threads
110,379
Messages
1,052,809
Members
143,421
Latest member
keiberus
Top