I will try to implement this myself in a few hours, but I'm developing an audio plugin called WavShaper and I want to add the functionality to animate the shapes instead of using static shapes. My idea for implementation is to use an audio file like I'm using, but instead of choosing one cycle of the same animation I read one frame of animation per cycle of audio (so, 1 second @ 10Hz = 10 frames).
To that end, I have so far been going through the audio from osci-render by hand and clipping out each frame, but in the future I want to be able to use the audio from osci-render. This may be possible in a Lua plugin, not sure on that, but what I'm imagining is a button (either in osci-render or in the Blender plugin) to go through frame by frame and save 4800 samples for each frame to the same audio file. There is definitely a feature in Blender to bake some kind of animation, that can almost definitely be used with osci-render.
Written in C++, but should translate really easily to Java. The math syntax is super similar.
// Normalization factor (maximum sample absolute value)
double norm = 0;
// Floating-Point Calculation and Recording Pass
for (int frame = 0; i < nFrames; frame ++) {
for (int sample = 0; sample < sampsPerFrame; i ++) {
// ----- Calculate the sample and store it in sampleArray[frame][sample][channel] -----
// Left Channel
if(std::abs(sampleArray[frame][sample][0]) > norm) {
norm = std::abs(sampleArray[frame][sample][0]); // Math.abs() in Java
}
// Right Channel
if(std::abs(sampleArray[frame][sample][1]) > norm) {
norm = std::abs(sampleArray[frame][sample][1]); // Math.abs() in Java
}
}
}
// Reduce unnecessary floating-point divisions, they're way slower than multiplications
norm = 1 / norm;
// Floating-Point Normalization Pass
for (int frame = 0; i < nFrames; frame ++) {
for (int sample = 0; sample < sampsPerFrame; i ++) {
sampleArray[frame][sample][0] *= norm;
sampleArray[frame][sample][1] *= norm;
}
}
// ----- Convert the samples to whatever format (int16, int24, float32, etc) is needed -----
// ----- Store the converted samples to the output file -----