Is their a way to get soundDatas BPM rate? or even better the total amount of time it takes to play a song? I've been browsing the wiki and I can't seem to see a function for this. It might sound like a stupid question but its helpful for timing audio sequences. I think there was one function to check if love.audio is still playing a sound (if the sound has stopped) or maybe that was something else.
Edit: I think I was mixing up LOVE documentation for another engine.
Renpy Audio Functions
renpy.seen_audio(filename)
Returns True if the given filename has been played at least once on the current user's system.
renpy.music.get_playing(channel='music')
If the given channel is playing, returns the playing file name. Otherwise, returns None.
renpy.music.is_playing(channel='music')
Returns True if the channel is currently playing a sound, False if it is not, or if the sound system isn't working.
Is there a LOVE equivalent for the above?
[SOLVED] How do check audio BPM?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[SOLVED] How do check audio BPM?
Last edited by zikesha93 on Fri Jan 22, 2016 5:39 am, edited 1 time in total.
- Kalamitous
- Prole
- Posts: 9
- Joined: Thu Jun 18, 2015 4:34 am
- Location: Behind you.
Re: How do check audio BPM?
Getting the BPM would require an FFT module. You can get the soundData's length in seconds with this formula:
Code: Select all
soundData:getSize() / soundData:getSampleRate() / soundData:getChannels() / (soundData:getBitDepth() / 8)
Last edited by Kalamitous on Fri Jan 22, 2016 5:57 pm, edited 1 time in total.
- zorg
- Party member
- Posts: 3477
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: How do check audio BPM?
Or, you know, with [wiki]SoundData:getDuration[/wiki]Kalamitous wrote:Getting the BPM would require an FFT module. You can get the soundData's length in seconds with this formula:Code: Select all
soundData:getSize() / soundData:getSampleRate() / soundData:getChannels() / (soundData:getBitDepth() / 8)
The first can be implemented fairly simply by yourself (though i'd rephrase it to "if the given filename has been played at least once from the start of the application.", though if you want this to work persistently, as how i'm guessing the ren'py function makes it sound, then that's a bit more work, basically your own small-ish audio handling libzikesha93 wrote: Renpy Audio Functions
renpy.seen_audio(filename)
Returns True if the given filename has been played at least once on the current user's system.
renpy.music.get_playing(channel='music')
If the given channel is playing, returns the playing file name. Otherwise, returns None.
renpy.music.is_playing(channel='music')
Returns True if the channel is currently playing a sound, False if it is not, or if the sound system isn't working.

The last function behaves just like [wiki]Source:isPlaying[/wiki], and the middle one is a hybrid of the last and a function returning the filename one used to create a source... also your own audio lib territory.
Last edited by zorg on Sat Jan 23, 2016 1:05 pm, edited 1 time in total.
Me and my stuff
True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

- Kalamitous
- Prole
- Posts: 9
- Joined: Thu Jun 18, 2015 4:34 am
- Location: Behind you.
Re: How do check audio BPM?
Wow, I didn't even know that existed lol.zorg wrote: Or, you know, with [wiki]SoundData:getDuration[/wiki]
Re: How do check audio BPM?
Thanks, I completely forgot about love.sound. Will check there in the wiki for more details. Thanks for the BPM formula. I'm sure I can work on a very small sound library.
- zorg
- Party member
- Posts: 3477
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: How do check audio BPM?
Just to be clear, in no post in this thread was a formula for Tempo detection written, unless you mean the suggestion to look into Fast Fourier Transforms. The only formula was for getting the duration the slow way (and it was wrong, since it was missing a pair of parentheses around the "getBitDepth / 8" part)zikesha93 wrote:Thanks, I completely forgot about love.sound. Will check there in the wiki for more details. Thanks for the BPM formula. I'm sure I can work on a very small sound library.
Me and my stuff
True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

- Kalamitous
- Prole
- Posts: 9
- Joined: Thu Jun 18, 2015 4:34 am
- Location: Behind you.
Re: How do check audio BPM?
Oops, my bad. Fixed.zorg wrote:zikesha93 wrote:(and it was wrong, since it was missing a pair of parentheses around the "getBitDepth / 8" part)
Who is online
Users browsing this forum: Amazon [Bot], Google [Bot] and 6 guests