Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Waveform #26

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Magical8bitPlug2.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
file="Source/SliderComponent.cpp"/>
<FILE id="qIuf9N" name="SliderComponent.h" compile="0" resource="0"
file="Source/SliderComponent.h"/>
<FILE id="uajfNh" name="SliderVerticalComponent.cpp" compile="1" resource="0"
file="Source/SliderVerticalComponent.cpp"/>
<FILE id="p2nPNB" name="SliderVerticalComponent.h" compile="0" resource="0"
file="Source/SliderVerticalComponent.h"/>
</GROUP>
<FILE id="SFqkUr" name="AdvancedParamsComponent.cpp" compile="1" resource="0"
file="Source/AdvancedParamsComponent.cpp"/>
Expand Down Expand Up @@ -68,6 +72,13 @@
file="Source/VibratoParamsComponent.h"/>
</GROUP>
<GROUP id="{630C27C7-03AA-CFC6-2FC4-4CE2DBE3640A}" name="Source">
<FILE id="WS1wsR" name="WaveformParamsComponent.cpp" compile="1" resource="0"
file="Source/WaveformParamsComponent.cpp"/>
<FILE id="miNL07" name="WaveformParamsComponent.h" compile="0" resource="0"
file="Source/WaveformParamsComponent.h"/>
<FILE id="vVn1lo" name="WaveformVoice.cpp" compile="1" resource="0"
file="Source/WaveformVoice.cpp"/>
<FILE id="iZpU3j" name="WaveformVoice.h" compile="0" resource="0" file="Source/WaveformVoice.h"/>
<FILE id="H2Vgbj" name="FrameSequenceParseErrors.cpp" compile="1" resource="0"
file="Source/FrameSequenceParseErrors.cpp"/>
<FILE id="Gwt2vB" name="FrameSequenceParseErrors.h" compile="0" resource="0"
Expand Down
1 change: 1 addition & 0 deletions Source/BasicParamsComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ void BasicParamsComponent::comboBoxChanged (ComboBox* comboBoxThatHasChanged)
{
processor.setupVoice();
editor.resized();
editor.resizeWholePanel();
printf ("setup voice!!\n");
}

Expand Down
26 changes: 23 additions & 3 deletions Source/NoiseVoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
NoiseVoice::NoiseVoice(SettingRefs *sRefs) : TonalVoice(sRefs) {}

void NoiseVoice::startNote(int midiNoteNumber, float velocity, SynthesiserSound *, int currentPitchBendPosition) {
TonalVoice::startNote(midiNoteNumber, velocity, 0, currentPitchBendPosition);
//TonalVoice::startNote(midiNoteNumber, velocity, 0, currentPitchBendPosition);
int midiNote = midiNoteNumber;
int midiNoteRange[16] = { 5, 17, 29, 34, 41, 46, 53, 57, 61, 65, 70, 77, 89, 101, 113, 125 };
switch (settingRefs->noiseAlgorithm()) {
case kNoiseInfinite2:
cycleLength = MathConstants<float>::pi / 25.0;
Expand All @@ -29,10 +31,19 @@ void NoiseVoice::startNote(int midiNoteNumber, float velocity, SynthesiserSound
cycleLength = MathConstants<float>::pi / 8.0;
break;

case kNoiseLongNes:
case kNoiseShortNes:
cycleLength = MathConstants<float>::pi / 20.175;
//rgstr = 0x8000;
//rgstr = rand();
midiNote = midiNoteRange[(midiNote + 8) % 16];
break;

default:
cycleLength = MathConstants<float>::pi / 8.0;
break;
}
TonalVoice::startNote(midiNote, velocity, 0, currentPitchBendPosition);
}

float NoiseVoice::voltageForAngle (double angle)
Expand All @@ -58,9 +69,10 @@ float NoiseVoice::voltageForAngle (double angle)
{
if (settingRefs->noiseAlgorithm() == kNoiseInfinite2)
{
currentVoltage = float (rand() % 16 - 8) / 16.;
currentVoltage = float (rand() % 16 - 8) / 16.0;
//currentVoltage = float(rand() % 16 - 7.5) / 15.0;
}
else
else if (settingRefs->noiseAlgorithm() == kNoiseLong || settingRefs->noiseAlgorithm() == kNoiseShort)
{
int compareBitPos = settingRefs->noiseAlgorithm() == kNoiseLong ? 1 : 6;

Expand All @@ -76,6 +88,14 @@ float NoiseVoice::voltageForAngle (double angle)

currentVoltage = (float)bit0 - 0.5;
}
else
{
int shortFreq = settingRefs->noiseAlgorithm() == kNoiseLongNes ? 1 : 6;

rgstr >>= 1;
rgstr |= ((rgstr ^ (rgstr >> shortFreq)) & 1) << 15;
currentVoltage = (float)(rgstr & 1) - 0.5;
}

nextAngle = (double) ((int) (angle / cycleLength) + 1) * cycleLength;

Expand Down
31 changes: 28 additions & 3 deletions Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "BendParamsComponent.h"
#include "SweepParamsComponent.h"
#include "VibratoParamsComponent.h"
#include "WaveformParamsComponent.h"

//==============================================================================
Magical8bitPlug2AudioProcessorEditor::Magical8bitPlug2AudioProcessorEditor (Magical8bitPlug2AudioProcessor& p)
Expand All @@ -29,7 +30,7 @@ Magical8bitPlug2AudioProcessorEditor::Magical8bitPlug2AudioProcessorEditor (Magi

basicCompo.reset (new BasicParamsComponent (p, *this));
addAndMakeVisible (basicCompo.get());

envCompo.reset (new EnvelopeParamsComponent (p));
addAndMakeVisible (envCompo.get());

Expand All @@ -51,6 +52,10 @@ Magical8bitPlug2AudioProcessorEditor::Magical8bitPlug2AudioProcessorEditor (Magi
vibCompo.reset (new VibratoParamsComponent (p));
addAndMakeVisible (vibCompo.get());

// waveform
waveformCompo.reset (new WaveformParamsComponent (p));
addAndMakeVisible (waveformCompo.get());

(p.parameters.getParameter ("isVolumeSequenceEnabled_raw"))->addListener (this);
(p.parameters.getParameter ("isDutySequenceEnabled_raw"))->addListener (this);

Expand Down Expand Up @@ -141,7 +146,7 @@ struct
+ genericControlHeight;
const int sweepCompoHeight = componentMargin * 2
+ indexHeight
+ genericControlHeight * 2;
+ genericControlHeight * 3;
const int vibCompoHeight = componentMargin * 2
+ indexHeight
+ genericControlHeight * 4;
Expand Down Expand Up @@ -240,6 +245,11 @@ void Magical8bitPlug2AudioProcessorEditor::resized()
y3 += sizes.sectionSeparatorHeight;
advCompo->setBounds (x, y3, sizes.fullComponentWidth, sizes.advCompoHeight);

// Waveform
int wrX = sizes.leftMargin + sizes.totalWidth;
int wrY = sizes.topMargin;
waveformCompo->setBounds(wrX, wrY, waveformCompo->getWidth(), waveformCompo->getHeight());

//
// Visibility
//
Expand Down Expand Up @@ -272,7 +282,12 @@ void Magical8bitPlug2AudioProcessorEditor::resized()

void Magical8bitPlug2AudioProcessorEditor::resizeWholePanel()
{
setSize (sizes.totalWidth, sizes.totalHeight (processor.settingRefs.isAdvancedPanelOpen()));
int totalWidth = sizes.totalWidth;
if (processor.settingRefs.oscillatorType() == kVoiceTypeWaveform)
{
totalWidth += sizes.leftMargin * 2 + waveformCompo->getWidth();
}
setSize (totalWidth, sizes.totalHeight (processor.settingRefs.isAdvancedPanelOpen()));
}

void Magical8bitPlug2AudioProcessorEditor::parameterValueChanged (int parameterIndex, float newValue)
Expand All @@ -291,3 +306,13 @@ void Magical8bitPlug2AudioProcessorEditor::parameterValueChanged (int parameterI
}
}

// waveform
//void Magical8bitPlug2AudioProcessorEditor::waveformInit()
//{
// waveformCompo->sliderInit();
//}

void Magical8bitPlug2AudioProcessorEditor::waveformUpdate()
{
waveformCompo->sliderRepaint();
}
6 changes: 6 additions & 0 deletions Source/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class NoiseParamsComponent;
class BendParamsComponent;
class SweepParamsComponent;
class VibratoParamsComponent;
class WaveformParamsComponent;

//==============================================================================
/**
Expand All @@ -40,6 +41,10 @@ class Magical8bitPlug2AudioProcessorEditor : public AudioProcessorEditor
void parameterValueChanged (int parameterIndex, float newValue) override;
void parameterGestureChanged (int parameterIndex, bool gestureIsStarting) override {};

// waveform
//void waveformInit();
void waveformUpdate();

private:
Magical8bitPlug2AudioProcessor& processor;

Expand All @@ -51,6 +56,7 @@ class Magical8bitPlug2AudioProcessorEditor : public AudioProcessorEditor
std::unique_ptr<BendParamsComponent> bendCompo;
std::unique_ptr<SweepParamsComponent> sweepCompo;
std::unique_ptr<VibratoParamsComponent> vibCompo;
std::unique_ptr<WaveformParamsComponent> waveformCompo;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Magical8bitPlug2AudioProcessorEditor)
};
Loading