-
Notifications
You must be signed in to change notification settings - Fork 12
Sample Player
During the development process it is very likely that you will make mistakes which can lead to very high levels of unwanted noise and DC! Be sure to protect your ears and your hardware by choosing a very low listening level and don't use too expensive equipment (high levels of DC can damage your loudspeakers and amplifiers)! I personally often used headphones but didn't put them on to check if there was any unexpected behavior before I switched on my studio monitors. Also I often used my laptops internal speakers in the early stages of development when I wasn't sure what exactly was going on.
To check if JUCE is set up correctly we should compile the project and then open it in the JUCE Plugin-Host. This should look something like this:
First we declare a variable formatManager
of the type AudioFormatManager
in the file PluginEditor.h
:
AudioFormatManager formatManager;
The AudioFormatManager
class keeps a list of audio formats (such as WAVE or AIFF) and can decide which to use when opening a file. We use it here to be able to load sound files of different types.
In the AudioProcessor.h
file we declare two variables:
AudioSampleBuffer buffer;
int filePosition;
The AudioSampleBuffer
class will hold the audio data we'll load later. The data is essentially a list of sample values for each channel. With the integer filePosition
we will keep track of which sample we should be reading right now.
Finally we will initialize the variable formatManager
in the constructor of the AudioProcessorEditor class (refer back to the last chapter where to find that).
formatManager.registerBasicFormats();
Next we will implement a function for loading a file into a buffer.