Skip to content

Commit

Permalink
Rename torsion -> offset
Browse files Browse the repository at this point in the history
  • Loading branch information
artfwo committed May 26, 2018
1 parent d64d913 commit 3b1c80c
Show file tree
Hide file tree
Showing 22 changed files with 317 additions and 317 deletions.
66 changes: 33 additions & 33 deletions Source/AndesLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,59 +20,59 @@

AndesLookAndFeel::AndesLookAndFeel()
{
setColourScheme (LookAndFeel_V4::getDarkColourScheme());
setColour (Slider::rotarySliderFillColourId, Colours::white);
setColour (Slider::textBoxOutlineColourId, Colours::transparentWhite);
setColourScheme(LookAndFeel_V4::getDarkColourScheme());
setColour(Slider::rotarySliderFillColourId, Colours::white);
setColour(Slider::textBoxOutlineColourId, Colours::transparentWhite);
}

void AndesLookAndFeel::drawRotarySlider (Graphics& g, int x, int y, int width, int height, float sliderPos,
float rotaryStartAngle, float rotaryEndAngle, Slider& slider)
void AndesLookAndFeel::drawRotarySlider(Graphics& g, int x, int y, int width, int height, float sliderPos,
float rotaryStartAngle, float rotaryEndAngle, Slider& slider)
{
const auto bounds = Rectangle<int> (x, y, width, height).toFloat();
const auto bounds = Rectangle<int>(x, y, width, height).toFloat();

auto radius = jmin (bounds.getWidth(), bounds.getHeight()) / 2.0f;
auto radius = jmin(bounds.getWidth(), bounds.getHeight()) / 2.0f;
const auto toAngle = rotaryStartAngle + sliderPos * (rotaryEndAngle - rotaryStartAngle);
auto lineW = jmin (4.0f, radius * 0.5f);
auto lineW = jmin(4.0f, radius * 0.5f);
auto arcRadius = radius - lineW * 0.5f;

Path backgroundArc;
backgroundArc.addCentredArc (bounds.getCentreX(),
bounds.getCentreY(),
arcRadius,
arcRadius,
0.0f,
rotaryStartAngle,
rotaryEndAngle,
true);

g.setColour (slider.findColour (Slider::rotarySliderOutlineColourId));
g.strokePath (backgroundArc, PathStrokeType (lineW, PathStrokeType::curved, PathStrokeType::rounded));

if (slider.isEnabled())
{
Path valueArc;
valueArc.addCentredArc (bounds.getCentreX(),
backgroundArc.addCentredArc(bounds.getCentreX(),
bounds.getCentreY(),
arcRadius,
arcRadius,
0.0f,
rotaryStartAngle,
toAngle,
rotaryEndAngle,
true);

g.setColour (slider.findColour (Slider::rotarySliderFillColourId));
g.strokePath (valueArc, PathStrokeType (lineW, PathStrokeType::curved, PathStrokeType::rounded));
g.setColour(slider.findColour(Slider::rotarySliderOutlineColourId));
g.strokePath(backgroundArc, PathStrokeType(lineW, PathStrokeType::curved, PathStrokeType::rounded));

if (slider.isEnabled())
{
Path valueArc;
valueArc.addCentredArc(bounds.getCentreX(),
bounds.getCentreY(),
arcRadius,
arcRadius,
0.0f,
rotaryStartAngle,
toAngle,
true);

g.setColour(slider.findColour(Slider::rotarySliderFillColourId));
g.strokePath(valueArc, PathStrokeType(lineW, PathStrokeType::curved, PathStrokeType::rounded));
}

const auto knobRadius = arcRadius - lineW * 1.5f;
g.setColour (slider.findColour (Slider::rotarySliderOutlineColourId));
g.fillEllipse (Rectangle<float> (knobRadius * 2, knobRadius * 2).withCentre (bounds.getCentre()));
g.setColour(slider.findColour(Slider::rotarySliderOutlineColourId));
g.fillEllipse(Rectangle<float>(knobRadius * 2, knobRadius * 2).withCentre(bounds.getCentre()));

Path pointer;
const float pointerLength = knobRadius * 0.5f;
const float pointerThickness = 2.0f;
pointer.addRoundedRectangle (-pointerThickness * 0.5f, -knobRadius, pointerThickness, pointerLength, pointerThickness / 2.0f);
pointer.applyTransform (AffineTransform::rotation (toAngle).translated (bounds.getCentreX(), bounds.getCentreY()));
g.setColour (slider.findColour (Slider::rotarySliderFillColourId));
g.fillPath (pointer);
pointer.addRoundedRectangle(-pointerThickness * 0.5f, -knobRadius, pointerThickness, pointerLength, pointerThickness / 2.0f);
pointer.applyTransform(AffineTransform::rotation(toAngle).translated(bounds.getCentreX(), bounds.getCentreY()));
g.setColour(slider.findColour(Slider::rotarySliderFillColourId));
g.fillPath(pointer);
}
4 changes: 2 additions & 2 deletions Source/AndesLookAndFeel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ class AndesLookAndFeel : public LookAndFeel_V4
public:
AndesLookAndFeel();

void drawRotarySlider (Graphics& g, int x, int y, int width, int height, float sliderPos,
float rotaryStartAngle, float rotaryEndAngle, Slider& slider) override;
void drawRotarySlider(Graphics& g, int x, int y, int width, int height, float sliderPos,
float rotaryStartAngle, float rotaryEndAngle, Slider& slider) override;
};
8 changes: 4 additions & 4 deletions Source/AndesSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ AndesSlider::~AndesSlider()
{
}

void AndesSlider::setGetTextFromValueFunc (std::function<String(double)> getTextFromValueFunc)
void AndesSlider::setGetTextFromValueFunc(std::function<String(double)> getTextFromValueFunc)
{
this->getTextFromValueFunc = getTextFromValueFunc;
}

String AndesSlider::getTextFromValue (double value)
String AndesSlider::getTextFromValue(double value)
{
if (getTextFromValueFunc)
{
return getTextFromValueFunc (value);
return getTextFromValueFunc(value);
}
return Slider::getTextFromValue (value);
return Slider::getTextFromValue(value);
}
6 changes: 3 additions & 3 deletions Source/AndesSlider.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class AndesSlider : public Slider
AndesSlider();
~AndesSlider();

void setGetTextFromValueFunc (std::function<String(double)> getTextFromValueFunc);
String getTextFromValue (double value) override;
void setGetTextFromValueFunc(std::function<String(double)> getTextFromValueFunc);
String getTextFromValue(double value) override;

private:
std::function<String(double)> getTextFromValueFunc;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AndesSlider)
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AndesSlider)
};
6 changes: 3 additions & 3 deletions Source/AndesSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@

#include "AndesSound.h"

AndesSound::AndesSound ()
AndesSound::AndesSound()
{
}

bool AndesSound::appliesToNote (int /*midiNoteNumber*/)
bool AndesSound::appliesToNote(int /*midiNoteNumber*/)
{
return true;
}

bool AndesSound::appliesToChannel (int /*midiChannel*/)
bool AndesSound::appliesToChannel(int /*midiChannel*/)
{
return true;
}
4 changes: 2 additions & 2 deletions Source/AndesSound.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ class AndesSound : public SynthesiserSound
public:
AndesSound();

bool appliesToNote (int /*midiNoteNumber*/) override;
bool appliesToChannel (int /*midiChannel*/) override;
bool appliesToNote(int /*midiNoteNumber*/) override;
bool appliesToChannel(int /*midiChannel*/) override;
};
36 changes: 18 additions & 18 deletions Source/AndesVoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@
#include "AndesVoice.h"
#include "AndesSound.h"

AndesVoice::AndesVoice (AndesAudioProcessor& processor)
: currentPhase (0), phaseDelta (0), level (0),
AndesVoice::AndesVoice(AndesAudioProcessor& processor)
: currentPhase(0), phaseDelta(0), level(0),
processor(processor),
envGen(processor)
{
}

bool AndesVoice::canPlaySound (SynthesiserSound* sound)
bool AndesVoice::canPlaySound(SynthesiserSound* sound)
{
return dynamic_cast<AndesSound*> (sound) != nullptr;
}

void AndesVoice::startNote (int midiNoteNumber, float velocity, SynthesiserSound *sound, int currentPitchWheelPosition)
void AndesVoice::startNote(int midiNoteNumber, float velocity, SynthesiserSound *sound, int currentPitchWheelPosition)
{
currentPhase = 0.0;
level = velocity;

frequency = MidiMessage::getMidiNoteInHertz (midiNoteNumber);
maxFrequency = MidiMessage::getMidiNoteInHertz (midiNoteNumber + 4);
minFrequency = MidiMessage::getMidiNoteInHertz (midiNoteNumber - 4);
frequency = MidiMessage::getMidiNoteInHertz(midiNoteNumber);
maxFrequency = MidiMessage::getMidiNoteInHertz(midiNoteNumber + 4);
minFrequency = MidiMessage::getMidiNoteInHertz(midiNoteNumber - 4);
normalizedFrequency = frequency / getSampleRate();

phaseDelta = normalizedFrequency * 2.0;
Expand All @@ -47,7 +47,7 @@ void AndesVoice::startNote (int midiNoteNumber, float velocity, SynthesiserSound
envGen.reset(getSampleRate());
}

void AndesVoice::stopNote (float velocity, bool allowTailOff)
void AndesVoice::stopNote(float velocity, bool allowTailOff)
{
if (allowTailOff)
{
Expand All @@ -62,7 +62,7 @@ void AndesVoice::stopNote (float velocity, bool allowTailOff)
}
}

void AndesVoice::pitchWheelMoved (int newPitchWheelValue)
void AndesVoice::pitchWheelMoved(int newPitchWheelValue)
{
double frequencyOffset = (newPitchWheelValue / 8192.0f) - 1.0f;
double newFrequency;
Expand All @@ -78,26 +78,26 @@ void AndesVoice::pitchWheelMoved (int newPitchWheelValue)
phaseDelta = newFrequency / getSampleRate() * 2.0;
}

void AndesVoice::controllerMoved (int controllerNumber, int newControllerValue)
void AndesVoice::controllerMoved(int controllerNumber, int newControllerValue)
{
}

void AndesVoice::renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples)
void AndesVoice::renderNextBlock(AudioSampleBuffer& outputBuffer, int startSample, int numSamples)
{
if (phaseDelta != 0.0)
{
while (--numSamples >= 0)
{
float phase = fmod (currentPhase, 2);
float phase = fmod(currentPhase, 2);
const float envLevel = envGen.next();
const float currentSample = processor.noise.gen (phase,
(int) *processor.parameters.getRawParameterValue ("octaves"),
*processor.parameters.getRawParameterValue ("persistence"),
*processor.parameters.getRawParameterValue ("torsion"),
*processor.parameters.getRawParameterValue ("warping")) * level * envLevel;
const float currentSample = processor.noise.gen(phase,
(int) *processor.parameters.getRawParameterValue("octaves"),
*processor.parameters.getRawParameterValue("persistence"),
*processor.parameters.getRawParameterValue("offset"),
*processor.parameters.getRawParameterValue("warping")) * level * envLevel;

for (int i = outputBuffer.getNumChannels(); --i >= 0;)
outputBuffer.addSample (i, startSample, currentSample);
outputBuffer.addSample(i, startSample, currentSample);

currentPhase += phaseDelta;
++startSample;
Expand Down
14 changes: 7 additions & 7 deletions Source/AndesVoice.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
class AndesVoice : public SynthesiserVoice
{
public:
AndesVoice (AndesAudioProcessor& processor);
AndesVoice(AndesAudioProcessor& processor);

//==============================================================================
bool canPlaySound (SynthesiserSound* sound) override;
void startNote (int midiNoteNumber, float velocity, SynthesiserSound *sound, int currentPitchWheelPosition) override;
void stopNote (float velocity, bool allowTailOff) override;
void pitchWheelMoved (int newPitchWheelValue) override;
void controllerMoved (int controllerNumber, int newControllerValue) override;
void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override;
bool canPlaySound(SynthesiserSound* sound) override;
void startNote(int midiNoteNumber, float velocity, SynthesiserSound *sound, int currentPitchWheelPosition) override;
void stopNote(float velocity, bool allowTailOff) override;
void pitchWheelMoved(int newPitchWheelValue) override;
void controllerMoved(int controllerNumber, int newControllerValue) override;
void renderNextBlock(AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override;

private:
double currentPhase, phaseDelta, level;
Expand Down
64 changes: 32 additions & 32 deletions Source/EnvelopeEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,49 +22,49 @@
//==============================================================================
EnvelopeEditor::EnvelopeEditor(AndesAudioProcessor& processor) : processor(processor)
{
sliderGroup.setText ("Envelope");
addAndMakeVisible (sliderGroup);
sliderGroup.setText("Envelope");
addAndMakeVisible(sliderGroup);

attSlider.setSliderStyle (Slider::Rotary);
attSlider.setTextBoxStyle (Slider::TextBoxBelow, true, 50, 15);
attSlider.setSliderStyle(Slider::RotaryVerticalDrag);
attSlider.setTextBoxStyle(Slider::TextBoxBelow, true, 50, 15);
attSlider.setGetTextFromValueFunc([](double value) { return String(round(value * 1000)) + " ms"; });
sliderGroup.addAndMakeVisible (&attSlider);
attAttachment = new SliderAttachment (processor.parameters, "env1att", attSlider);
sliderGroup.addAndMakeVisible(&attSlider);
attAttachment = new SliderAttachment(processor.parameters, "env1att", attSlider);


decSlider.setSliderStyle (Slider::Rotary);
decSlider.setTextBoxStyle (Slider::TextBoxBelow, true, 50, 15);
decSlider.setSliderStyle(Slider::RotaryVerticalDrag);
decSlider.setTextBoxStyle(Slider::TextBoxBelow, true, 50, 15);
decSlider.setGetTextFromValueFunc([](double value) { return String(round(value * 1000)) + " ms"; });
sliderGroup.addAndMakeVisible (&decSlider);
decAttachment = new SliderAttachment (processor.parameters, "env1dec", decSlider);
sliderGroup.addAndMakeVisible(&decSlider);
decAttachment = new SliderAttachment(processor.parameters, "env1dec", decSlider);

susSlider.setSliderStyle (Slider::Rotary);
susSlider.setTextBoxStyle (Slider::TextBoxBelow, true, 50, 15);
susSlider.setSliderStyle(Slider::RotaryVerticalDrag);
susSlider.setTextBoxStyle(Slider::TextBoxBelow, true, 50, 15);
susSlider.setGetTextFromValueFunc([](double value) { return String(round(value * 100)) + "%"; });
sliderGroup.addAndMakeVisible (&susSlider);
susAttachment = new SliderAttachment (processor.parameters, "env1sus", susSlider);
sliderGroup.addAndMakeVisible(&susSlider);
susAttachment = new SliderAttachment(processor.parameters, "env1sus", susSlider);

relSlider.setSliderStyle (Slider::Rotary);
relSlider.setTextBoxStyle (Slider::TextBoxBelow, true, 50, 15);
relSlider.setSliderStyle(Slider::RotaryVerticalDrag);
relSlider.setTextBoxStyle(Slider::TextBoxBelow, true, 50, 15);
relSlider.setGetTextFromValueFunc([](double value) { return String(round(value * 1000)) + " ms"; });
sliderGroup.addAndMakeVisible (&relSlider);
relAttachment = new SliderAttachment (processor.parameters, "env1rel", relSlider);
sliderGroup.addAndMakeVisible(&relSlider);
relAttachment = new SliderAttachment(processor.parameters, "env1rel", relSlider);

attLabel.setText("Attack", NotificationType::dontSendNotification);
attLabel.setJustificationType (Justification::centred);
sliderGroup.addAndMakeVisible (&attLabel);
attLabel.setJustificationType(Justification::centred);
sliderGroup.addAndMakeVisible(&attLabel);

decLabel.setText("Decay", NotificationType::dontSendNotification);
decLabel.setJustificationType (Justification::centred);
sliderGroup.addAndMakeVisible (&decLabel);
decLabel.setJustificationType(Justification::centred);
sliderGroup.addAndMakeVisible(&decLabel);

susLabel.setText("Sustain", NotificationType::dontSendNotification);
susLabel.setJustificationType (Justification::centred);
sliderGroup.addAndMakeVisible (&susLabel);
susLabel.setJustificationType(Justification::centred);
sliderGroup.addAndMakeVisible(&susLabel);

relLabel.setText("Release", NotificationType::dontSendNotification);
relLabel.setJustificationType (Justification::centred);
sliderGroup.addAndMakeVisible (&relLabel);
relLabel.setJustificationType(Justification::centred);
sliderGroup.addAndMakeVisible(&relLabel);
}

EnvelopeEditor::~EnvelopeEditor()
Expand All @@ -73,16 +73,16 @@ EnvelopeEditor::~EnvelopeEditor()

void EnvelopeEditor::resized()
{
sliderGroup.setBounds (0, 0, getWidth(), getHeight());
sliderGroup.setBounds(0, 0, getWidth(), getHeight());

int sliderY = 15;
int sliderHeight = sliderGroup.getHeight() - 40;
int sliderHeight = sliderGroup.getHeight() - 40;
int sliderWidth = sliderGroup.getWidth() / 4;

attSlider.setBounds (sliderWidth * 0, sliderY, sliderWidth, sliderHeight);
decSlider.setBounds (sliderWidth * 1, sliderY, sliderWidth, sliderHeight);
susSlider.setBounds (sliderWidth * 2, sliderY, sliderWidth, sliderHeight);
relSlider.setBounds (sliderWidth * 3, sliderY, sliderWidth, sliderHeight);
attSlider.setBounds(sliderWidth * 0, sliderY, sliderWidth, sliderHeight);
decSlider.setBounds(sliderWidth * 1, sliderY, sliderWidth, sliderHeight);
susSlider.setBounds(sliderWidth * 2, sliderY, sliderWidth, sliderHeight);
relSlider.setBounds(sliderWidth * 3, sliderY, sliderWidth, sliderHeight);

attLabel.setBounds(sliderWidth * 0, sliderY + sliderHeight + 5, sliderWidth, 10);
decLabel.setBounds(sliderWidth * 1, sliderY + sliderHeight + 5, sliderWidth, 10);
Expand Down
2 changes: 1 addition & 1 deletion Source/EnvelopeEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ class EnvelopeEditor : public Component

AndesAudioProcessor& processor;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EnvelopeEditor)
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(EnvelopeEditor)
};
Loading

0 comments on commit 3b1c80c

Please sign in to comment.