Skip to content

Commit

Permalink
added channel flip button
Browse files Browse the repository at this point in the history
  • Loading branch information
mzuther committed Aug 28, 2016
1 parent a8a0239 commit 55e8fd4
Show file tree
Hide file tree
Showing 60 changed files with 312 additions and 114 deletions.
13 changes: 13 additions & 0 deletions Source/plugin_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ KmeterAudioProcessorEditor::KmeterAudioProcessorEditor(KmeterAudioProcessor *own
ButtonMute.addListener(this);
addAndMakeVisible(ButtonMute);

ButtonFlip.addListener(this);
addAndMakeVisible(ButtonFlip);

ButtonReset.addListener(this);
addAndMakeVisible(ButtonReset);

Expand Down Expand Up @@ -174,6 +177,7 @@ KmeterAudioProcessorEditor::KmeterAudioProcessorEditor(KmeterAudioProcessor *own
updateParameter(KmeterPluginParameters::selMono);
updateParameter(KmeterPluginParameters::selDim);
updateParameter(KmeterPluginParameters::selMute);
updateParameter(KmeterPluginParameters::selFlip);

// locate directory containing the skins
skinDirectory = KmeterPluginParameters::getSkinDirectory();
Expand Down Expand Up @@ -245,6 +249,7 @@ void KmeterAudioProcessorEditor::applySkin()
skin.placeAndSkinButton(&ButtonMono, "button_mono");
skin.placeAndSkinButton(&ButtonDim, "button_dim");
skin.placeAndSkinButton(&ButtonMute, "button_mute");
skin.placeAndSkinButton(&ButtonFlip, "button_flip");

skin.placeAndSkinButton(&ButtonReset, "button_reset");
skin.placeAndSkinButton(&ButtonSkin, "button_skin");
Expand Down Expand Up @@ -492,6 +497,10 @@ void KmeterAudioProcessorEditor::updateParameter(int nIndex)
// will also apply skin to plug-in editor
needsMeterReload = true;
break;

case KmeterPluginParameters::selFlip:
ButtonFlip.setToggleState(nValue != 0, dontSendNotification);
break;
}

// prevent meter reload during initialisation
Expand Down Expand Up @@ -612,6 +621,10 @@ void KmeterAudioProcessorEditor::buttonClicked(Button *button)
{
audioProcessor->changeParameter(KmeterPluginParameters::selMute, button->getToggleState() ? 0.0f : 1.0f);
}
else if (button == &ButtonFlip)
{
audioProcessor->changeParameter(KmeterPluginParameters::selFlip, button->getToggleState() ? 0.0f : 1.0f);
}
else if (button == &ButtonAbout)
{
// manually activate button (will be deactivated in dialog
Expand Down
1 change: 1 addition & 0 deletions Source/plugin_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class KmeterAudioProcessorEditor : public AudioProcessorEditor, public ButtonLis
ImageButton ButtonMono;
ImageButton ButtonDim;
ImageButton ButtonMute;
ImageButton ButtonFlip;
ImageButton ButtonReset;

ImageButton ButtonValidation;
Expand Down
7 changes: 7 additions & 0 deletions Source/plugin_parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ KmeterPluginParameters::KmeterPluginParameters() :
add(ParameterMute, selMute);


frut::parameter::ParBoolean *ParameterFlip =
new frut::parameter::ParBoolean("On", "Off");
ParameterFlip->setName("Flip channels");
ParameterFlip->setDefaultBoolean(false, true);
add(ParameterFlip, selFlip);


frut::parameter::ParString *ParameterValidationFileName =
new frut::parameter::ParString(String::empty);
ParameterValidationFileName->setName("Validation file");
Expand Down
1 change: 1 addition & 0 deletions Source/plugin_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class KmeterPluginParameters :
selMono,
selDim,
selMute,
selFlip,

numberOfParametersRevealed,

Expand Down
31 changes: 22 additions & 9 deletions Source/plugin_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,18 +499,31 @@ void KmeterAudioProcessor::processBlock(AudioBuffer<float> &buffer, MidiBuffer &
audioFilePlayer->fillBufferChunk(&buffer);
}

bool bMono = getBoolean(KmeterPluginParameters::selMono);

// convert stereo input to mono if "Mono" button has been pressed
if (isStereo && bMono)
// process two channels only
if (isStereo)
{
float *output_left = buffer.getWritePointer(0);
float *output_right = buffer.getWritePointer(1);
float *inputLeft = buffer.getWritePointer(0);
float *inputRight = buffer.getWritePointer(1);

for (int i = 0; i < nNumSamples; ++i)
// "Mono" button has been pressed
if (getBoolean(KmeterPluginParameters::selMono))
{
for (int i = 0; i < nNumSamples; ++i)
{
inputLeft[i] = 0.5f * (inputLeft[i] + inputRight[i]);
inputRight[i] = inputLeft[i];
}
}
// "Flip" button has been pressed
else if (getBoolean(KmeterPluginParameters::selFlip))
{
output_left[i] = 0.5f * (output_left[i] + output_right[i]);
output_right[i] = output_left[i];
for (int i = 0; i < nNumSamples; ++i)
{
float oldInputLeft = inputLeft[i];

inputLeft[i] = inputRight[i];
inputRight[i] = oldInputLeft;
}
}
}

Expand Down
36 changes: 30 additions & 6 deletions skins/Default.skin
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,17 @@
image_off="buttons/button_mono_off.png"
/>

<button_dim
<button_flip
x="130"
y="538"
image_on="buttons/button_flip_on.png"
image_over="buttons/button_flip_over.png"
image_off="buttons/button_flip_off.png"
/>

<button_dim
x="130"
y="488"
image_on="buttons/button_dim_on.png"
image_over="buttons/button_dim_over.png"
image_off="buttons/button_dim_off.png"
Expand Down Expand Up @@ -177,7 +185,7 @@

<label_debug
x="140"
y="487"
y="462"
image="labels/label_debug.png"
/>
</default>
Expand Down Expand Up @@ -591,9 +599,17 @@
image_off="buttons/button_mono_off.png"
/>

<button_dim
<button_flip
x="130"
y="518"
image_on="buttons/button_flip_on.png"
image_over="buttons/button_flip_over.png"
image_off="buttons/button_flip_off.png"
/>

<button_dim
x="130"
y="468"
image_on="buttons/button_dim_on.png"
image_over="buttons/button_dim_over.png"
image_off="buttons/button_dim_off.png"
Expand Down Expand Up @@ -625,7 +641,7 @@

<label_debug
x="140"
y="467"
y="441"
image="labels/label_debug.png"
/>

Expand Down Expand Up @@ -871,9 +887,17 @@
image_off="buttons/button_mono_off.png"
/>

<button_dim
<button_flip
x="354"
y="518"
image_on="buttons/button_flip_on.png"
image_over="buttons/button_flip_over.png"
image_off="buttons/button_flip_off.png"
/>

<button_dim
x="354"
y="468"
image_on="buttons/button_dim_on.png"
image_over="buttons/button_dim_over.png"
image_off="buttons/button_dim_off.png"
Expand Down Expand Up @@ -913,7 +937,7 @@

<label_debug
x="364"
y="467"
y="441"
image="labels/label_debug.png"
/>

Expand Down
Loading

0 comments on commit 55e8fd4

Please sign in to comment.