Revamped pitch and auto bend restriction

- Changed restriction from a single slider to 2 check boxes: 1 for restricting auto bend to semitones, 1 for pitch bend
- Still need translation for new labels
- Can't get project to run properly as a VST3; might be a problem on my end
This commit is contained in:
Archonic 2023-07-01 23:48:52 -04:00
parent 09d21d5c90
commit 4fbb8d28c6
5 changed files with 47 additions and 22 deletions

View File

@ -21,7 +21,7 @@
//[/Headers] //[/Headers]
#include "AdvancedParamsComponent.h" #include "AdvancedParamsComponent.h"
#include "CheckBoxComponent.h"
//[MiscUserDefs] You can add your own user definitions and misc code here... //[MiscUserDefs] You can add your own user definitions and misc code here...
//[/MiscUserDefs] //[/MiscUserDefs]
@ -60,9 +60,23 @@ AdvancedParamsComponent::AdvancedParamsComponent (Magical8bitPlug2AudioProcessor
addAndMakeVisible (coarseOrFineChoice.get()); addAndMakeVisible (coarseOrFineChoice.get());
coarseOrFineChoice->setName ("Coarse or fine"); coarseOrFineChoice->setName ("Coarse or fine");
bendResolutionSlider.reset(new SliderComponent(p, "bendResolution", "Bend Reso")); restrictionLabel.reset (new juce::Label ("new label2",
addAndMakeVisible(bendResolutionSlider.get()); "Pitch Restriction")); //no translation on the pitch restriction stuff
bendResolutionSlider->setName("bend resolution component"); addAndMakeVisible (restrictionLabel.get());
restrictionLabel->setFont (juce::Font (17.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
restrictionLabel->setJustificationType (juce::Justification::centredLeft);
restrictionLabel->setEditable (false, false, false);
restrictionLabel->setColour (juce::TextEditor::textColourId, juce::Colours::black);
restrictionLabel->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000));
restrictionLabel->setBounds(0, 170, 150, 24);
restrictAutoBend.reset (new CheckBoxComponent(p, "restrictAutoBend_raw", "Restrict Auto Bend to Semitones"));
addAndMakeVisible (restrictAutoBend.get());
restrictAutoBend->setName ("restrict auto bend component");
restrictPitchBend.reset (new CheckBoxComponent(p, "restrictPitchBend_raw", "Restrict Pitch Bend to Semitones"));
addAndMakeVisible (restrictPitchBend.get());
restrictPitchBend->setName ("restrict pitch bend component");
//[UserPreSize] //[UserPreSize]
//[/UserPreSize] //[/UserPreSize]
@ -112,7 +126,8 @@ void AdvancedParamsComponent::resized()
pitchCompo->setBounds (0, 82, getWidth() - 204, 56); pitchCompo->setBounds (0, 82, getWidth() - 204, 56);
dutyCompo->setBounds (0, 138, getWidth() - 160, 56); dutyCompo->setBounds (0, 138, getWidth() - 160, 56);
coarseOrFineChoice->setBounds (getWidth() - 4 - 200, 86, 200, 28); coarseOrFineChoice->setBounds (getWidth() - 4 - 200, 86, 200, 28);
bendResolutionSlider->setBounds(0, 200, getWidth() - 50, 80); restrictAutoBend->setBounds(0, 195, getWidth() - 80, 200);
restrictPitchBend->setBounds(0, 225, getWidth() - 80, 200);
//[UserResized] Add your own custom resize handling here.. //[UserResized] Add your own custom resize handling here..
//[/UserResized] //[/UserResized]
} }

View File

@ -24,6 +24,7 @@
#include "CustomEnvelopeComponent.h" #include "CustomEnvelopeComponent.h"
#include "ChoiceComponent.h" #include "ChoiceComponent.h"
#include "SliderComponent.h" #include "SliderComponent.h"
#include "CheckBoxComponent.h"
//[/Headers] //[/Headers]
@ -63,7 +64,9 @@ private:
std::unique_ptr<CustomEnvelopeComponent> pitchCompo; std::unique_ptr<CustomEnvelopeComponent> pitchCompo;
std::unique_ptr<CustomEnvelopeComponent> dutyCompo; std::unique_ptr<CustomEnvelopeComponent> dutyCompo;
std::unique_ptr<ChoiceComponent> coarseOrFineChoice; std::unique_ptr<ChoiceComponent> coarseOrFineChoice;
std::unique_ptr<SliderComponent> bendResolutionSlider; std::unique_ptr<Label> restrictionLabel;
std::unique_ptr<CheckBoxComponent> restrictAutoBend;
std::unique_ptr<CheckBoxComponent> restrictPitchBend;
//============================================================================== //==============================================================================

View File

@ -114,17 +114,17 @@ Magical8bitPlug2AudioProcessor::Magical8bitPlug2AudioProcessor()
// For Noise // For Noise
// //
std::make_unique<AudioParameterChoice> ("noiseAlgorithm_raw", "Algorithm", StringArray ({"4bit Pure Random", "1bit Long Cycle", "1bit Short Cycle"}), 0), std::make_unique<AudioParameterChoice> ("noiseAlgorithm_raw", "Algorithm", StringArray ({"4bit Pure Random", "1bit Long Cycle", "1bit Short Cycle"}), 0),
std::make_unique<AudioParameterBool> ("restrictsToNESFrequency_raw", "Restricts to NES frequency", false), std::make_unique<AudioParameterBool> (ParameterID{"restrictsToNESFrequency_raw", 1}, "Restricts to NES frequency", false),
// //
// Sequence // Sequence
// //
std::make_unique<AudioParameterBool> ("isVolumeSequenceEnabled_raw", "Enabled", false), std::make_unique<AudioParameterBool> ("isVolumeSequenceEnabled_raw", "Enabled", false),
std::make_unique<AudioParameterBool> ("isPitchSequenceEnabled_raw", "Enabled", false), std::make_unique<AudioParameterBool> ("isPitchSequenceEnabled_raw", "Enabled", false),
std::make_unique<AudioParameterBool> ("isDutySequenceEnabled_raw", "Enabled", false), std::make_unique<AudioParameterBool> ("isDutySequenceEnabled_raw", "Enabled", false),
std::make_unique<AudioParameterChoice> ("pitchSequenceMode_raw", "Mode", StringArray ({"Coarse", "Fine"}), 0), std::make_unique<AudioParameterChoice> ("pitchSequenceMode_raw", "Mode", StringArray ({"Coarse", "Fine"}), 0),
//Pitch steps //Restrict pitch modifications to semitones
//0 is max resolution, 1 will cause pitch bend to only work in semitones std::make_unique<AudioParameterBool> ("restrictPitchBend_raw", "Restrict Pitchbend", false),
std::make_unique<AudioParameterFloat> ("bendResolution", "Bend Resolution", 0.0f, 1.0f, 1.0f) std::make_unique<AudioParameterBool>("restrictAutoBend_raw", "Restrict Auto Bend + Portamento", false)
} }
) )
, settingRefs (&parameters) , settingRefs (&parameters)

View File

@ -147,7 +147,8 @@ struct SettingRefs
float* isDutySequenceEnabled_raw = nullptr; float* isDutySequenceEnabled_raw = nullptr;
float* pitchSequenceMode_raw = nullptr; float* pitchSequenceMode_raw = nullptr;
//pitch resolution //pitch resolution
float* bendResolution = nullptr; float* restrictPitchBend_raw = nullptr;
float* restrictAutoBend_raw = nullptr;
FrameSequence volumeSequence; FrameSequence volumeSequence;
FrameSequence pitchSequence; FrameSequence pitchSequence;
@ -179,6 +180,9 @@ struct SettingRefs
bool isVolumeSequenceEnabled() { return *isVolumeSequenceEnabled_raw > 0.5; } bool isVolumeSequenceEnabled() { return *isVolumeSequenceEnabled_raw > 0.5; }
bool isPitchSequenceEnabled() { return *isPitchSequenceEnabled_raw > 0.5; } bool isPitchSequenceEnabled() { return *isPitchSequenceEnabled_raw > 0.5; }
bool isDutySequenceEnabled() { return *isDutySequenceEnabled_raw > 0.5; } bool isDutySequenceEnabled() { return *isDutySequenceEnabled_raw > 0.5; }
bool isRestrictingPitchBend() {return *restrictPitchBend_raw > 0.5;}
bool isRestrictingAutoBend() {return *restrictAutoBend_raw > 0.5;}
PitchSequenceMode pitchSequenceMode() { return (PitchSequenceMode) ((int) (*pitchSequenceMode_raw)); } PitchSequenceMode pitchSequenceMode() { return (PitchSequenceMode) ((int) (*pitchSequenceMode_raw)); }
MonophonicBehavior monophonicBehavior() { return (MonophonicBehavior) ((int) (*monophonicBehavior_raw)); } MonophonicBehavior monophonicBehavior() { return (MonophonicBehavior) ((int) (*monophonicBehavior_raw)); }
ArpeggioIntervalType apreggioIntervalType() { return (ArpeggioIntervalType) ((int) (*arpeggioIntervalType_raw)); } ArpeggioIntervalType apreggioIntervalType() { return (ArpeggioIntervalType) ((int) (*arpeggioIntervalType_raw)); }
@ -226,6 +230,7 @@ struct SettingRefs
isDutySequenceEnabled_raw = (float*) parameters->getRawParameterValue ("isDutySequenceEnabled_raw"); isDutySequenceEnabled_raw = (float*) parameters->getRawParameterValue ("isDutySequenceEnabled_raw");
pitchSequenceMode_raw = (float*) parameters->getRawParameterValue ("pitchSequenceMode_raw"); pitchSequenceMode_raw = (float*) parameters->getRawParameterValue ("pitchSequenceMode_raw");
//Pitch resolution //Pitch resolution
bendResolution = (float*) parameters->getRawParameterValue("bendResolution"); restrictPitchBend_raw = (float*) parameters->getRawParameterValue("restrictPitchBend_raw");
restrictAutoBend_raw = (float*) parameters->getRawParameterValue("restrictAutoBend_raw");
} }
}; };

View File

@ -74,14 +74,18 @@ void TonalVoice::calculateAngleDelta()
double byWheel = settingRefs->vibratoIgnoresWheel() ? 1.0 : currentModWheelValue; double byWheel = settingRefs->vibratoIgnoresWheel() ? 1.0 : currentModWheelValue;
double vibratoAmount = * (settingRefs->vibratoDepth) * sin (getVibratoPhase()) * byWheel; double vibratoAmount = * (settingRefs->vibratoDepth) * sin (getVibratoPhase()) * byWheel;
double noteNoInDouble = noteNumber double noteNoInDouble = noteNumber
+ noteNumberMod + noteNumberMod
+ currentBendAmount + vibratoAmount
+ currentAutoBendAmount + finePitchInSeq;
+ vibratoAmount double restrictedValues = 0.0; //floor values together
+ finePitchInSeq;
if (settingRefs->isRestrictingAutoBend()) restrictedValues += currentAutoBendAmount;
else noteNoInDouble += currentAutoBendAmount;
if(settingRefs->isRestrictingPitchBend()) restrictedValues += currentBendAmount;
else noteNoInDouble += currentBendAmount;
if(restrictedValues != 0) noteNoInDouble += floor(restrictedValues);
auto cyclesPerSecond = noteNoToHeltzDouble (noteNoInDouble); auto cyclesPerSecond = noteNoToHeltzDouble (noteNoInDouble);
auto cyclesPerSample = cyclesPerSecond / getSampleRate(); auto cyclesPerSample = cyclesPerSecond / getSampleRate();
angleDelta = cyclesPerSample * 2.0 * MathConstants<double>::pi; angleDelta = cyclesPerSample * 2.0 * MathConstants<double>::pi;
} }
@ -202,8 +206,6 @@ void TonalVoice::shiftNoteBuffer(int index) {
double TonalVoice::noteNoToHeltzDouble (double noteNoInDouble, const double frequencyOfA) double TonalVoice::noteNoToHeltzDouble (double noteNoInDouble, const double frequencyOfA)
{ {
double resolution = 1.0 - (*settingRefs->bendResolution); //in the equation, 0 is max res and 1 is 1 semitone
noteNoInDouble = floor(noteNoInDouble/resolution)*resolution;
return frequencyOfA * std::pow (2.0, (noteNoInDouble - 69) / 12.0); return frequencyOfA * std::pow (2.0, (noteNoInDouble - 69) / 12.0);
} }