Skip to content

Commit

Permalink
Making distortion section.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtytel committed May 26, 2017
1 parent 78d611b commit 9ec6313
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 10 deletions.
8 changes: 7 additions & 1 deletion src/common/helm_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ namespace mopo {
ValueDetails::kLinear, "", "Delay Sync" },
{ "delay_tempo", 0.0, 11.0, 12, 9.0, 0.0, 1.0,
ValueDetails::kLinear, "", "Delay Tempo" },
{ "distortion_type", 0.0, 4.0, 5, 0.0, 0.0, 1.0,
ValueDetails::kLinear, "", "Distortion Type" },
{ "distortion_drive", 0.0, 20.0, 0, 5.0, 0.0, 1.0,
ValueDetails::kLinear, "", "Distortion Drive" },
{ "distortion_mix", 0.0, 1.0, 0, 1.0, 0.0, 1.0,
ValueDetails::kLinear, "", "Distortion Mix" },
{ "fil_attack", 0.0, 4.0, 0, 0.0, 0.0, 1.0,
ValueDetails::kQuadratic, "secs", "Filter Attack" },
{ "fil_decay", 0.0, 4.0, 0, 1.5, 0.0, 1.0,
Expand Down Expand Up @@ -175,7 +181,7 @@ namespace mopo {
ValueDetails::kLinear, "", "Poly LFO Waveform" },
{ "polyphony", 1.0, 32.0, 32, 4.0, 0.0, 1.0,
ValueDetails::kLinear, "voices", "Polyphony" },
{ "portamento", -9.0, -1.0, 0, -9.0, 0.0, 12.0,
{ "portamento", -9.0, -1.0, 0, -7.0, 0.0, 12.0,
ValueDetails::kExponential, "s/oct", "Portamento" },
{ "portamento_type", 0.0, 2.0, 3, 0.0, 0.0, 1.0,
ValueDetails::kLinear, "", "Portamento Type" },
Expand Down
63 changes: 63 additions & 0 deletions src/editor_sections/distortion_section.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* Copyright 2013-2017 Matt Tytel
*
* helm is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* helm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with helm. If not, see <https://www.gnu.org/licenses/>.
*/

#include "distortion_section.h"

#include "colors.h"
#include "fonts.h"
#include "synth_button.h"

#define KNOB_WIDTH 40

DistortionSection::DistortionSection(String name) : SynthSection(name) {

addSlider(type_ = new SynthSlider("distortion_type"));
type_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);

addSlider(drive_ = new SynthSlider("distortion_drive"));
drive_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);

addSlider(mix_ = new SynthSlider("distortion_mix"));
mix_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
}

DistortionSection::~DistortionSection() {
type_ = nullptr;
drive_ = nullptr;
mix_ = nullptr;
}

void DistortionSection::paintBackground(Graphics& g) {
SynthSection::paintBackground(g);

g.setColour(Colors::controlLabelText);
g.setFont(Fonts::instance()->proportional_regular().withPointHeight(10.0f));

drawTextForComponent(g, TRANS("TYPE"), type_);
drawTextForComponent(g, TRANS("DRIVE"), drive_);
drawTextForComponent(g, TRANS("MIX"), mix_);
}

void DistortionSection::resized() {
float space = (getWidth() - (3.0f * KNOB_WIDTH)) / 4.0f;
int y = 36;

type_->setBounds(space, y, KNOB_WIDTH, KNOB_WIDTH);
drive_->setBounds((KNOB_WIDTH + space) + space, y, KNOB_WIDTH, KNOB_WIDTH);
mix_->setBounds(2 * (KNOB_WIDTH + space) + space, y, KNOB_WIDTH, KNOB_WIDTH);

SynthSection::resized();
}
41 changes: 41 additions & 0 deletions src/editor_sections/distortion_section.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* Copyright 2013-2017 Matt Tytel
*
* helm is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* helm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with helm. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once
#ifndef DISTORTION_SECTION_H
#define DISTORTION_SECTION_H

#include "JuceHeader.h"
#include "synth_section.h"
#include "synth_slider.h"

class DistortionSection : public SynthSection {
public:
DistortionSection(String name);
~DistortionSection();

void paintBackground(Graphics& g) override;
void resized() override;

private:
ScopedPointer<SynthSlider> type_;
ScopedPointer<SynthSlider> drive_;
ScopedPointer<SynthSlider> mix_;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistortionSection)
};

#endif // DISTORTION_SECTION_H
2 changes: 1 addition & 1 deletion src/editor_sections/filter_section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#define KEYTRACK_TOP_PADDING 5
#define KEYTRACK_HEIGHT 14
#define KEYTRACK_WIDTH 60
#define STYLE_SLIDER_PADDING 2
#define STYLE_SLIDER_PADDING 4
#define STYLE_LABEL_WIDTH 30
#define STYLE_LABEL_PADDING_X 5
#define STYLE_LABEL_PADDING_Y 3
Expand Down
2 changes: 1 addition & 1 deletion src/editor_sections/synth_section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void SynthSection::paintBackground(Graphics& g) {
g.fillRoundedRectangle(0, 0, getWidth(), TITLE_WIDTH, 1.0f);

// Draw text title.
g.setColour(Colour(0xff999999));
g.setColour(Colour(0xffbbbbbb));
g.setFont(Fonts::instance()->proportional_light().withPointHeight(14.0f));
g.drawText(TRANS(getName()), 0, 0, getWidth(), TITLE_WIDTH,
Justification::centred, true);
Expand Down
11 changes: 8 additions & 3 deletions src/editor_sections/synthesis_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ SynthesisInterface::SynthesisInterface(
addSubSection(oscillator_section_ = new OscillatorSection("OSCILLATORS"));
addSubSection(poly_lfo_section_ = new LfoSection("POLY LFO", "poly_lfo", false));
addSubSection(reverb_section_ = new ReverbSection("REVERB"));
addSubSection(distortion_section_ = new DistortionSection("DISTORTION"));
addSubSection(step_sequencer_section_ = new StepSequencerSection("STEP SEQUENCER"));
addSubSection(stutter_section_ = new StutterSection("STUTTER"));
addSubSection(sub_section_ = new SubSection("SUB"));
Expand All @@ -75,6 +76,7 @@ SynthesisInterface::SynthesisInterface(
SynthesisInterface::~SynthesisInterface() {
amplitude_envelope_section_ = nullptr;
delay_section_ = nullptr;
distortion_section_ = nullptr;
dynamic_section_ = nullptr;
extra_envelope_section_ = nullptr;
extra_mod_section_ = nullptr;
Expand Down Expand Up @@ -105,6 +107,7 @@ void SynthesisInterface::paintBackground(Graphics& g) {

section_shadow.drawForRectangle(g, amplitude_envelope_section_->getBounds());
section_shadow.drawForRectangle(g, delay_section_->getBounds());
section_shadow.drawForRectangle(g, distortion_section_->getBounds());
section_shadow.drawForRectangle(g, dynamic_section_->getBounds());
section_shadow.drawForRectangle(g, extra_envelope_section_->getBounds());
section_shadow.drawForRectangle(g, extra_mod_section_->getBounds());
Expand Down Expand Up @@ -174,9 +177,11 @@ void SynthesisInterface::resized() {
extra_envelope_section_->getWidth(), step_lfo_height);

delay_section_->setBounds(column_4_x, 4.0f, COLUMN_WIDTH_4, 105.0f);
reverb_section_->setBounds(column_4_x, delay_section_->getBottom() + CELL_PADDING,
COLUMN_WIDTH_4, 105.0f);
volume_section_->setBounds(column_4_x, reverb_section_->getBottom() + CELL_PADDING,
// reverb_section_->setBounds(column_4_x, delay_section_->getBottom() + CELL_PADDING,
// COLUMN_WIDTH_4, 105.0f);
distortion_section_->setBounds(column_4_x, delay_section_->getBottom() + CELL_PADDING,
COLUMN_WIDTH_4, 105.0f);
volume_section_->setBounds(column_4_x, distortion_section_->getBottom() + CELL_PADDING,
COLUMN_WIDTH_4, 64.0f);
voice_section_->setBounds(column_1_x, step_sequencer_section_->getBottom() + CELL_PADDING,
DYNAMIC_WIDTH, 64.0f);
Expand Down
2 changes: 2 additions & 0 deletions src/editor_sections/synthesis_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "helm_engine.h"

#include "delay_section.h"
#include "distortion_section.h"
#include "dynamic_section.h"
#include "envelope_section.h"
#include "extra_mod_section.h"
Expand Down Expand Up @@ -66,6 +67,7 @@ class SynthesisInterface : public SynthSection {
ScopedPointer<OscillatorSection> oscillator_section_;
ScopedPointer<LfoSection> poly_lfo_section_;
ScopedPointer<ReverbSection> reverb_section_;
ScopedPointer<DistortionSection> distortion_section_;
ScopedPointer<StepSequencerSection> step_sequencer_section_;
ScopedPointer<StutterSection> stutter_section_;
ScopedPointer<SubSection> sub_section_;
Expand Down
16 changes: 14 additions & 2 deletions src/synthesis/helm_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,18 @@ namespace mopo {

addProcessor(voice_handler_);

// Distortion
Distortion* distortion = new Distortion();
Value* distortion_type = createBaseControl("distortion_type");
Output* distortion_drive = createMonoModControl("distortion_drive", true);
Output* distortion_mix = createMonoModControl("distortion_mix", true);

distortion->plug(voice_handler_, Distortion::kAudio);
distortion->plug(distortion_type, Distortion::kType);
distortion->plug(distortion_drive, Distortion::kDrive);
distortion->plug(distortion_mix, Distortion::kMix);
addProcessor(distortion);

// Delay effect.
Output* delay_free_frequency = createMonoModControl("delay_frequency", true);
Output* delay_frequency = createTempoSyncSwitch("delay", delay_free_frequency->owner,
Expand All @@ -191,14 +203,14 @@ namespace mopo {
delay_samples->plug(delay_frequency_smoothed);

Delay* delay = new Delay(MAX_DELAY_SAMPLES);
delay->plug(voice_handler_, Delay::kAudio);
delay->plug(distortion, Delay::kAudio);
delay->plug(delay_samples, Delay::kSampleDelay);
delay->plug(delay_feedback_clamped, Delay::kFeedback);
delay->plug(delay_wet, Delay::kWet);

BypassRouter* delay_container = new BypassRouter();
delay_container->plug(delay_on, BypassRouter::kOn);
delay_container->plug(voice_handler_, BypassRouter::kAudio);
delay_container->plug(distortion, BypassRouter::kAudio);
delay_container->addProcessor(delay_feedback_clamped);
delay_container->addProcessor(delay_frequency_audio_rate);
delay_container->addProcessor(delay_frequency_smoothed);
Expand Down
4 changes: 2 additions & 2 deletions src/synthesis/peak_meter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ namespace mopo {
current_peak_left_ *= decay_left;
current_peak_right_ *= decay_right;

current_peak_left_ = std::max(current_peak_left_ - movement, peak_left);
current_peak_right_ = std::max(current_peak_right_ - movement, peak_right);
current_peak_left_ = utils::max(current_peak_left_ - movement, peak_left);
current_peak_right_ = utils::max(current_peak_right_ - movement, peak_right);
output()->buffer[0] = current_peak_left_;
output()->buffer[1] = current_peak_right_;
}
Expand Down
6 changes: 6 additions & 0 deletions standalone/builds/osx/Helm.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
CBDEF0B7ACD825C1ACFC3687 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA170B8B6946E4F4B51585CC /* QuartzCore.framework */; };
D1948DCD1ED75450001D4725 /* synth_button.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D1948DCB1ED75450001D4725 /* synth_button.cpp */; };
D1948DD01ED75F31001D4725 /* text_selector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D1948DCE1ED75F31001D4725 /* text_selector.cpp */; };
D1948DD31ED79ED1001D4725 /* distortion_section.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D1948DD11ED79ED1001D4725 /* distortion_section.cpp */; };
D33B878F0A7EBAE0E7BB2E30 /* phaser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 431F67091922F7BD0109A828 /* phaser.cpp */; };
D562CDFE66DF2CD372C19DCE /* patch_selector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46626E47D3A373BACDCD5144 /* patch_selector.cpp */; };
D5C1B8FB22BE482D16D30041 /* fonts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F4B2B9D30EBFB201CA94989 /* fonts.cpp */; };
Expand Down Expand Up @@ -1360,6 +1361,8 @@
D1948DCC1ED75450001D4725 /* synth_button.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = synth_button.h; path = ../../../src/editor_components/synth_button.h; sourceTree = "<group>"; };
D1948DCE1ED75F31001D4725 /* text_selector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = text_selector.cpp; path = ../../../src/editor_components/text_selector.cpp; sourceTree = "<group>"; };
D1948DCF1ED75F31001D4725 /* text_selector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = text_selector.h; path = ../../../src/editor_components/text_selector.h; sourceTree = "<group>"; };
D1948DD11ED79ED1001D4725 /* distortion_section.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = distortion_section.cpp; path = ../../../src/editor_sections/distortion_section.cpp; sourceTree = "<group>"; };
D1948DD21ED79ED1001D4725 /* distortion_section.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = distortion_section.h; path = ../../../src/editor_sections/distortion_section.h; sourceTree = "<group>"; };
D1D453BE13BA62BB78EA3FC2 /* juce_LuaCodeTokeniser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_LuaCodeTokeniser.h; path = ../../../JUCE/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.h; sourceTree = SOURCE_ROOT; };
D2194F176DD979D13CD5C635 /* oscillator_section.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = oscillator_section.cpp; path = ../../../src/editor_sections/oscillator_section.cpp; sourceTree = SOURCE_ROOT; };
D23DAB91D491228D740AA92C /* sample_decay_lookup.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = sample_decay_lookup.cpp; path = ../../../mopo/src/sample_decay_lookup.cpp; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -2965,6 +2968,8 @@
90454FC49E1CF1991CE70BB7 /* editor_sections */ = {
isa = PBXGroup;
children = (
D1948DD11ED79ED1001D4725 /* distortion_section.cpp */,
D1948DD21ED79ED1001D4725 /* distortion_section.h */,
C7550594C7A61E383666EE0A /* about_section.cpp */,
5D0DA4CBD7A3428F29339186 /* about_section.h */,
4416E848ACA1FC962DEA131D /* arp_section.cpp */,
Expand Down Expand Up @@ -4281,6 +4286,7 @@
56100466C368D965FC38E73E /* synth_base.cpp in Sources */,
1362658F311F79DD5D372E7C /* synth_gui_interface.cpp in Sources */,
63780BC73998AF310CA57D53 /* bpm_slider.cpp in Sources */,
D1948DD31ED79ED1001D4725 /* distortion_section.cpp in Sources */,
F899359DAB7673BD37CA8E79 /* filter_response.cpp in Sources */,
71086D0AF8FEC143EE9A115E /* filter_selector.cpp in Sources */,
B2AFABF78A86B9E736855665 /* global_tool_tip.cpp in Sources */,
Expand Down

0 comments on commit 9ec6313

Please sign in to comment.