Get wav length in milliseconds OR sample rate
-
Hey all.
I'd like to get my wav file's length in milliseconds. I can do sample.getSampleLength() and get the length in samples and then do:var ms = (samples/samplerate) * 1000
However, how can I get the samplerate of the wav?
-
@dejaru there's a method called
AudioFile.getSampleRate()
-
You could also use
Engine.getMilliSecondsForSamples()
-
Appreciated guys, can't believe I missed these! Also got a bit confused with getting getSampleLength and getSampleRate.
Case of the mondays I guess.const var SamplePlayer1 = Synth.getAudioSampleProcessor("SamplePlayer1"); const var audioFile1 = SamplePlayer1.getAudioFile(0); const var samples = SamplePlayer1.getSampleLength(); const var sampleRate = audioFile1.getSampleRate(); const var lengthMs = (samples / sampleRate) * 1000;
Thanks again.