How to properly use the AudioSourceToneGenerator Object

Hello there,

I am a fairly novice juce user who is running into issues while using the AudioSourceToneGenerator class.

I am attempting to create a plugin that uses the AudioSourceToneGenerator to play a tone in a DAW track. When I build and import my plugin into Reaper a tone is played but it is significantly higher frequency than the correct 261 Hz I expect. I have a basic plugin juce project where the only alterations are as follows:

Here is my prepareToPlay function:

void NewProjectAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
    toneGen.setAmplitude(1.0);
    toneGen.setFrequency(261.63); // middle C in Hz
    toneGen.prepareToPlay(sampleRate, samplesPerBlock);
}

The only line I added to the processBlock function was:

toneGen.getNextAudioBlock(juce::AudioSourceChannelInfo(buffer));

In PluginProcessor.h I declare the ToneGeneratorAudioSource as:

ToneGeneratorAudioSource toneGen;

I am importing the plugin as a vst and using Reaper to test it. Let me know if there is any other useful information I can provide. I appreciate you talking the time to help me out with this one!

  • AJ