Plug-in with AudioVisualiserComponent


#1

Hello everyone,
I’m a newbie. I try to do a plug in which has only audio input and which displays it! For that I create a AudioVisualiserComponent in Plug in Editor.
My problem is the following:
When I add this plug-in on the plug-in host, the plug-in host crash and must be started again.
I think that my error come from my ProcessBlock function:
//Process Block
void Plug_in_3AudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
const int totalNumInputChannels = getTotalNumInputChannels();
const int totalNumOutputChannels = getTotalNumOutputChannels();

// In case we have more outputs than inputs, this code clears any output
// channels that didn't contain input data, (because these aren't
// guaranteed to be empty - they may contain garbage).
// This is here to avoid people getting screaming feedback
// when they first compile a plugin, but obviously you don't need to keep
// this code if your algorithm always overwrites all the output channels.
for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
    buffer.clear (i, 0, buffer.getNumSamples());

// This is the place where you'd normally do the guts of your plugin's
// audio processing...
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
    float* channelData = buffer.getWritePointer (channel);
    float* audioBufferData = audioBuffer.getWritePointer(channel);
    for (int sample = 0; sample < buffer.getNumSamples(); ++sample)
        {
            if (channelData!=nullptr) {
                audioBufferData[sample]=channelData[sample];
            }
        }

    audioBuffer.clear();
    // ..do something to the data...
}

}

Here is the part where I create and set my AudioVisualiser:
visualiser.setSize(400,250);
visualiser.setRepaintRate(100);
visualiser.setSamplesPerBlock(256);
visualiser.setBufferSize(256);
visualiser.setNumChannels(1);
visualiser.setColours(Colours::white,Colours::black);
visualiser.pushBuffer(processor.audioBuffer);
addAndMakeVisible (&visualiser);

visualiser is my AudioVisualiserComponent
audioBuffer is my AudioSampleBuffer

Sorry for my bad english,
Thanks,
Léo


#2

I solve my problem, but I come up with another issue: my screen display nothing when I plug in with the audio input in my Plug-in Host.

Here is the code of my updated ProcessBlock function:

void Plug_in_3AudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
const int totalNumInputChannels = getTotalNumInputChannels();
const int totalNumOutputChannels = getTotalNumOutputChannels();
audioBuffer.setSize(totalNumOutputChannels,buffer.getNumSamples(),false,true,true);

// In case we have more outputs than inputs, this code clears any output
// channels that didn't contain input data, (because these aren't
// guaranteed to be empty - they may contain garbage).
// This is here to avoid people getting screaming feedback
// when they first compile a plugin, but obviously you don't need to keep
// this code if your algorithm always overwrites all the output channels.
for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
    {
        buffer.clear (i, 0, buffer.getNumSamples());
    }
// This is the place where you'd normally do the guts of your plugin's
// audio processing...


for (int channel = 0; channel < totalNumInputChannels; ++channel)
    {
        float* channelData = buffer.getWritePointer (channel);
        float* audioBufferData = audioBuffer.getWritePointer(channel);
        for (int sample = 0; sample < buffer.getNumSamples(); ++sample)
            {
                audioBufferData[sample]=buffer.getSample(channel,sample)*0.10;
            }
    }

}

Do you have any advice?
Thanks,


#3

Now I have something at the very right from my visualizer, do you have any advice to display it on all my visualizer?