Hello! I made an audio -> time contraption on Scratch! Simply insert the code in your project then add the audio, you'll be able to get a (near) accurate audio length! EXPLANATION BELOW!
HOW IT WORKS? I decided to make something that can (nearly) decipher the length of a Scratch audio. The main thing I tried to do to make the system work is to understand the pitch change of a Scratch pitch unit. If you don't know, Scratch has special blocks and value system for sounds known as pitch, along with the set pitch to [], change pitch by [], and pitch reporter blocks. Values can range from -330 (lowest pitch value) to 330 (highest pitch value), but how much is one individual pitch unit? Let's find out. Since the ranges go from multiples of 30, I thought testing out 30 pitch would be a good starter. I did some testing and realized that pitching a Scratch audio by 30 is equivalent to pitching by 0.2 pitch! How I was able to get the amount of pitch from 1 Scratch pitch unit? I simply divided 0.2 by 30 to get .006... (repeating decimal, 6 would go on forever in the decimal value). The reason I tried to estimate the amount of pitch in a Scratch pitch unit is so I could scale the time of the pitched audio by what amount was pitched. Because, when you pitch audios up, they are less long! Why is that good? Well, to find the length of a long audio with the code set would take forever. So when it's pitched up, calculating the length of the audio will take less time as there is less to wait for. For example, speeding up 3 minutes by 330 Scratch pitch would reduce the overall time to ~1/7th! Around half an hour! While still long, this greatly reduces the wait time for making a (near) efficient sound -> time calculator. But why'd I say "near"? Well, it's all down to my calculations from before on how much pitch is gained from a Scratch pitch unit. Since it's a repeating decimal (and I set the value to the hundredth's place), I can't ensure that the audio is calculated at its fully accurate length.