Introduction
DJ hardware controllers allow DJs to emulate traditional vinyl turntables by sending signals from the controller turntable to the PC DJ software in order to alter the speed of the PC audio playback thus emulating "scratching". This technique has given DJs the option of replacing suitcases of vinyl records with a disk of MP3 files. For this to be possible the PC software must be able to dynamically resample the audio signal so that the speed and direction of playback can be controlled. This needs to be done with as little latency as possible. This sample application shows how this may be achieved in Microsoft Windows using WASAPI with some help from Intel's IPP library. The application does the following:
- allows a user to select an MP3 file. The MP3 file must have exactly two channels (i.e. stereo) and be sampled at 44100Hz.
- extracts the audio signal from the MP3 in PCM wave format.
- uses Intel IPP to re-sample the resulting wave file from 44100Hz to the sampling frequency used by WASAPI (normally 48000Hz).
- duplicates the resulting waveform and passes it through a low pass filter with a cutoff just below 0.25 the sampling frequency. This is to avoid potential aliasing artifacts if played back faster than the original speed. The application currently supports playback at a maximum of twice the original recorded speed. Any higher than this then the cutoff frequency would need to be lower then 0.25. When played back at the normal speed or slower the first (unfiltered) waveform is used.
- passes the two 48000 Hz signals to the WASAPI audio renderer.
- allows a user to emulate a turntable by using a slider to dynamically control the speed and direction of playback by re-sampling/interpolating the wave just before it is passed to the WASAPI buffer.
Building the application
-
Intel's IPP library must be installed first. If Intel IPP is not installed, close Visual Studio before installing it. After installing Intel IPP, open the Project Settings in Visual Studio 2019 and under Configuration Properties make sure there is an entry called Intel Performance Libraries and check that the Use Intel IPP option is set to Single-threaded Static Library.
-
The project was written using Visual Studio 2019 (make sure the desktop C++ and MFC options are installed).
Credits