Skip to content
Snippets Groups Projects
Commit f369bf7d authored by Caleb Kemere's avatar Caleb Kemere
Browse files

Noise gate implemented next to volume on top of screen. Works but levels are too abrupt.

parent cd8a0e1a
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@
#include "Channel.h"
AudioNode::AudioNode()
: GenericProcessor("Audio Node"), audioEditor(0), volume(0.00001f),
: GenericProcessor("Audio Node"), audioEditor(0), volume(0.00001f), noiseGateLevel(0.0f),
bufferA(2,10000),
bufferB(2,10000)
{
......@@ -136,6 +136,13 @@ void AudioNode::setParameter(int parameterIndex, float newValue)
// volume level
volume = newValue*0.1f;
}
else if (parameterIndex == 2)
{
// noiseGateLevel level
noiseGateLevel = newValue*0.01f; // not sure about this scaling???
std::cout << "Changed noiseGateLevel: " << noiseGateLevel << std::endl;
}
else if (parameterIndex == 100)
{
......@@ -316,6 +323,7 @@ void AudioNode::process(AudioSampleBuffer& buffer,
remainingSamples, // number of samples
gain // gain to apply
);
}
orphanedSamples = nSamples - samplesToCopy2;
......@@ -334,7 +342,7 @@ void AudioNode::process(AudioSampleBuffer& buffer,
gain // gain to apply
);
backupBuffer->addFrom(0, // destination channel
backupBuffer->addFrom(0, // destination channel
samplesInBackupBuffer, // destination start sample
buffer, // source
i, // source channel
......@@ -344,7 +352,17 @@ void AudioNode::process(AudioSampleBuffer& buffer,
);
}
// HERE IS WHERE WE NEED TO NOISE GATE
float *leftChannelData = buffer.getSampleData(0);
float *rightChannelData = buffer.getSampleData(1);
float gateLevel = noiseGateLevel/(float(0x7fff));
for (int i=0; i < buffer.getNumSamples(); i++) {
if (abs(leftChannelData[i]) < gateLevel)
leftChannelData[i] = 0;
if (abs(rightChannelData[i]) < gateLevel)
rightChannelData[i] = 0;
}
}
}
......
......@@ -103,6 +103,7 @@ private:
Array<int> leftChan;
Array<int> rightChan;
float volume;
float noiseGateLevel;
/** An array of pointers to the channels that feed into the AudioNode. */
Array<Channel*> channelPointers;
......
......@@ -98,13 +98,21 @@ AudioEditor::AudioEditor(AudioNode* owner)
//
addAndMakeVisible(audioWindowButton);
volumeSlider = new Slider("High-Cut Slider");
volumeSlider = new Slider("Volume Slider");
volumeSlider->setRange(0,100,1);
volumeSlider->addListener(this);
volumeSlider->setTextBoxStyle(Slider::NoTextBox,
false, 0, 0);
addAndMakeVisible(volumeSlider);
noiseGateSlider = new Slider("Noise Gate Slider");
noiseGateSlider->setRange(0,100,1);
noiseGateSlider->addListener(this);
noiseGateSlider->setTextBoxStyle(Slider::NoTextBox,
false, 0, 0);
addAndMakeVisible(noiseGateSlider);
//acw = new AudioConfigurationWindow(getAudioComponent()->deviceManager, (Button*) audioWindowButton);
}
......@@ -119,7 +127,8 @@ void AudioEditor::resized()
{
muteButton->setBounds(0,0,30,25);
volumeSlider->setBounds(35,0,50,getHeight());
audioWindowButton->setBounds(90,0,200,getHeight());
noiseGateSlider->setBounds(85,0,50,getHeight());
audioWindowButton->setBounds(140,0,200,getHeight());
}
bool AudioEditor::keyPressed(const KeyPress& key)
......@@ -208,7 +217,10 @@ void AudioEditor::buttonClicked(Button* button)
void AudioEditor::sliderValueChanged(Slider* slider)
{
getAudioProcessor()->setParameter(1,slider->getValue());
if (slider == volumeSlider)
getAudioProcessor()->setParameter(1,slider->getValue());
else if (slider == noiseGateSlider)
getAudioProcessor()->setParameter(2,slider->getValue());
}
void AudioEditor::paint(Graphics& g)
......
......@@ -131,7 +131,8 @@ private:
AudioConfigurationWindow* acw;
Slider* volumeSlider;
Slider* noiseGateSlider;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AudioEditor);
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment