mirror of
https://github.com/yokemura/Magical8bitPlug2.git
synced 2025-05-24 23:00:21 -04:00
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:
parent
09d21d5c90
commit
4fbb8d28c6
@ -21,7 +21,7 @@
|
||||
//[/Headers]
|
||||
|
||||
#include "AdvancedParamsComponent.h"
|
||||
|
||||
#include "CheckBoxComponent.h"
|
||||
|
||||
//[MiscUserDefs] You can add your own user definitions and misc code here...
|
||||
//[/MiscUserDefs]
|
||||
@ -60,9 +60,23 @@ AdvancedParamsComponent::AdvancedParamsComponent (Magical8bitPlug2AudioProcessor
|
||||
addAndMakeVisible (coarseOrFineChoice.get());
|
||||
coarseOrFineChoice->setName ("Coarse or fine");
|
||||
|
||||
bendResolutionSlider.reset(new SliderComponent(p, "bendResolution", "Bend Reso"));
|
||||
addAndMakeVisible(bendResolutionSlider.get());
|
||||
bendResolutionSlider->setName("bend resolution component");
|
||||
restrictionLabel.reset (new juce::Label ("new label2",
|
||||
"Pitch Restriction")); //no translation on the pitch restriction stuff
|
||||
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]
|
||||
@ -112,7 +126,8 @@ void AdvancedParamsComponent::resized()
|
||||
pitchCompo->setBounds (0, 82, getWidth() - 204, 56);
|
||||
dutyCompo->setBounds (0, 138, getWidth() - 160, 56);
|
||||
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]
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "CustomEnvelopeComponent.h"
|
||||
#include "ChoiceComponent.h"
|
||||
#include "SliderComponent.h"
|
||||
#include "CheckBoxComponent.h"
|
||||
//[/Headers]
|
||||
|
||||
|
||||
@ -63,7 +64,9 @@ private:
|
||||
std::unique_ptr<CustomEnvelopeComponent> pitchCompo;
|
||||
std::unique_ptr<CustomEnvelopeComponent> dutyCompo;
|
||||
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;
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
@ -114,17 +114,17 @@ Magical8bitPlug2AudioProcessor::Magical8bitPlug2AudioProcessor()
|
||||
// For Noise
|
||||
//
|
||||
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
|
||||
//
|
||||
std::make_unique<AudioParameterBool> ("isVolumeSequenceEnabled_raw", "Enabled", false),
|
||||
std::make_unique<AudioParameterBool> ("isPitchSequenceEnabled_raw", "Enabled", false),
|
||||
std::make_unique<AudioParameterBool> ("isVolumeSequenceEnabled_raw", "Enabled", false),
|
||||
std::make_unique<AudioParameterBool> ("isPitchSequenceEnabled_raw", "Enabled", false),
|
||||
std::make_unique<AudioParameterBool> ("isDutySequenceEnabled_raw", "Enabled", false),
|
||||
std::make_unique<AudioParameterChoice> ("pitchSequenceMode_raw", "Mode", StringArray ({"Coarse", "Fine"}), 0),
|
||||
//Pitch steps
|
||||
//0 is max resolution, 1 will cause pitch bend to only work in semitones
|
||||
std::make_unique<AudioParameterFloat> ("bendResolution", "Bend Resolution", 0.0f, 1.0f, 1.0f)
|
||||
//Restrict pitch modifications to semitones
|
||||
std::make_unique<AudioParameterBool> ("restrictPitchBend_raw", "Restrict Pitchbend", false),
|
||||
std::make_unique<AudioParameterBool>("restrictAutoBend_raw", "Restrict Auto Bend + Portamento", false)
|
||||
}
|
||||
)
|
||||
, settingRefs (¶meters)
|
||||
|
@ -147,7 +147,8 @@ struct SettingRefs
|
||||
float* isDutySequenceEnabled_raw = nullptr;
|
||||
float* pitchSequenceMode_raw = nullptr;
|
||||
//pitch resolution
|
||||
float* bendResolution = nullptr;
|
||||
float* restrictPitchBend_raw = nullptr;
|
||||
float* restrictAutoBend_raw = nullptr;
|
||||
|
||||
FrameSequence volumeSequence;
|
||||
FrameSequence pitchSequence;
|
||||
@ -179,6 +180,9 @@ struct SettingRefs
|
||||
bool isVolumeSequenceEnabled() { return *isVolumeSequenceEnabled_raw > 0.5; }
|
||||
bool isPitchSequenceEnabled() { return *isPitchSequenceEnabled_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)); }
|
||||
MonophonicBehavior monophonicBehavior() { return (MonophonicBehavior) ((int) (*monophonicBehavior_raw)); }
|
||||
ArpeggioIntervalType apreggioIntervalType() { return (ArpeggioIntervalType) ((int) (*arpeggioIntervalType_raw)); }
|
||||
@ -226,6 +230,7 @@ struct SettingRefs
|
||||
isDutySequenceEnabled_raw = (float*) parameters->getRawParameterValue ("isDutySequenceEnabled_raw");
|
||||
pitchSequenceMode_raw = (float*) parameters->getRawParameterValue ("pitchSequenceMode_raw");
|
||||
//Pitch resolution
|
||||
bendResolution = (float*) parameters->getRawParameterValue("bendResolution");
|
||||
restrictPitchBend_raw = (float*) parameters->getRawParameterValue("restrictPitchBend_raw");
|
||||
restrictAutoBend_raw = (float*) parameters->getRawParameterValue("restrictAutoBend_raw");
|
||||
}
|
||||
};
|
||||
|
@ -74,14 +74,18 @@ void TonalVoice::calculateAngleDelta()
|
||||
double byWheel = settingRefs->vibratoIgnoresWheel() ? 1.0 : currentModWheelValue;
|
||||
double vibratoAmount = * (settingRefs->vibratoDepth) * sin (getVibratoPhase()) * byWheel;
|
||||
double noteNoInDouble = noteNumber
|
||||
+ noteNumberMod
|
||||
+ currentBendAmount
|
||||
+ currentAutoBendAmount
|
||||
+ vibratoAmount
|
||||
+ finePitchInSeq;
|
||||
+ noteNumberMod
|
||||
+ vibratoAmount
|
||||
+ finePitchInSeq;
|
||||
double restrictedValues = 0.0; //floor values together
|
||||
|
||||
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 cyclesPerSample = cyclesPerSecond / getSampleRate();
|
||||
|
||||
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 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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user