Maximum Audio Source "start_position" Value

I would like to get the maximum value for the “start_position” key in an audio source key frame. I’ve noticed it changes between audio files.

I have tried looking through source code, but I’m not too c++ savy yet. I’ve tried writing the “audio_file” value to a file and to getting the frame count from the waves python library but the file didn’t have a RIFF id so errors get thrown.

What does Vital convert dragged-in audio files into and how can I get the max “start_position” value from it?

1 Like

ANSWER

======================================================

Hey! I think I figured out what determined the max position of the last keyframe when you create a wavetable from an audio file.

HERE’S FORMULA:
Samples - Window Size = MaxPosition

Example:


WindowSize
PositionLastKeyFrame

So it would be: 30576 - 2048 = 28528

SOURCE CODE

======================================================
Here’s the source code if you need it!
(Look on lines 209 - 239):
WavetableCreatorSourceCode

Here’s the function when you turn an audio file into wavetable

Here’s where it creates the first and last keyframes
Code 3



Note: The last keyframe is created either on 226 or 229, depends on if statement.

Here’s where it sets the position of the first and last keyframes

EXTRA NOTES

======================================================
I’m also new to C++ so I’m not 100% sure on everything but I tried my best to decipher what I could in an hour XD. Let me know if you have any more questions! Hope this helps a little bit.

1 Like

Thanks for the time and effort! The Audio File Source has an “audio_file” parameter that contains the sample, any ideas on how to get the number of samples out of this thing?