Code
from IPython.display import Audio
"beatles_orig.wav", rate=48000) Audio(
In my proposal, I mentioned that the Rubber Band Library, a 3rd-party library compatible with Blender’s open source license, could be used to implement pitch correction into Blender’s video sequence editor (VSE). This would mean that we wouldn’t have to implement the algorithm manually! However, before proceeding with this approach, there several things that had to be considered:
As a preliminary task, I wanted to attempt to build the Rubber Band Library and looked at extern/audaspace
to better understand Blender’s build process. Surprisingly enough, I’ve never used CMAKE (though I have used makefile
before) nor never downloaded a library for any of my C++ programs during university. So, I thought it would be a good to try to utilize the Rubber Band Library on a bare bones command-line program, where you can specify the input audio file and then the output audio file at 2x speed which will be pitch-corrected by the library.
After downloading the source code, I looked at COMPILING.md
which had some references to Meson but more importantly… something about RubberBandSingle.cpp and adding it as a static library, which is the approach I went with…
File Structure:
RubberBandTest
├─ CMakeLists.txt
├─ beatles.wav
├─ main.cpp
└─ rubberband
Notes to add and explain…
RubberBandStretcher
class with optionssetTimeRatio()
method, where setTimeRatio(0.5)
makes the audio 2x quicker and setTimeRatio(2.0)
makes the audio 0.5x quicker. Both preserve pitch.study
and process
method. The process
method does the actual transformation on the float vector audio data.retrieve
method…setPitchScale
method.Original Audio:
from IPython.display import Audio
"beatles_orig.wav", rate=48000) Audio(
2x Speed:
0.5x Speed:
The code for this example can be found here… [TODO]
Checking the static library librubberband_static.a
, the library size is 2.6 MB
.
Here’s RubberBandSingle.cpp