Added 'bend resolution' slider

This allows for pitch bend to be quantized into semitones (or smaller increments) for a more 'chipped' feel.
This commit is contained in:
Archonic 2023-06-20 22:59:03 -04:00
parent b2f6f4f1b8
commit 09d21d5c90
7 changed files with 19 additions and 6 deletions

View File

@ -59,7 +59,10 @@ AdvancedParamsComponent::AdvancedParamsComponent (Magical8bitPlug2AudioProcessor
coarseOrFineChoice.reset (new ChoiceComponent (p, "pitchSequenceMode_raw", "Resolution"));
addAndMakeVisible (coarseOrFineChoice.get());
coarseOrFineChoice->setName ("Coarse or fine");
bendResolutionSlider.reset(new SliderComponent(p, "bendResolution", "Bend Reso"));
addAndMakeVisible(bendResolutionSlider.get());
bendResolutionSlider->setName("bend resolution component");
//[UserPreSize]
//[/UserPreSize]
@ -109,6 +112,7 @@ 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);
//[UserResized] Add your own custom resize handling here..
//[/UserResized]
}

View File

@ -23,6 +23,7 @@
#include "../JuceLibraryCode/JuceHeader.h"
#include "CustomEnvelopeComponent.h"
#include "ChoiceComponent.h"
#include "SliderComponent.h"
//[/Headers]
@ -62,6 +63,7 @@ private:
std::unique_ptr<CustomEnvelopeComponent> pitchCompo;
std::unique_ptr<CustomEnvelopeComponent> dutyCompo;
std::unique_ptr<ChoiceComponent> coarseOrFineChoice;
std::unique_ptr<SliderComponent> bendResolutionSlider;
//==============================================================================

View File

@ -156,7 +156,7 @@ struct
+ genericControlHeight * 4;
const int advCompoHeight = componentMargin * 2
+ indexHeight
+ customEnvelopeHeight * 3;
+ customEnvelopeHeight * 4;
const int totalHeight (bool isAdvOptOn, bool isMono)
{
int retHeight = topMargin

View File

@ -121,7 +121,10 @@ Magical8bitPlug2AudioProcessor::Magical8bitPlug2AudioProcessor()
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)
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)
}
)
, settingRefs (&parameters)

View File

@ -7,7 +7,7 @@
==============================================================================
*/
#pragma once
#include "TonalVoice.h"

View File

@ -146,6 +146,8 @@ struct SettingRefs
float* isPitchSequenceEnabled_raw = nullptr;
float* isDutySequenceEnabled_raw = nullptr;
float* pitchSequenceMode_raw = nullptr;
//pitch resolution
float* bendResolution = nullptr;
FrameSequence volumeSequence;
FrameSequence pitchSequence;
@ -223,6 +225,7 @@ struct SettingRefs
isPitchSequenceEnabled_raw = (float*) parameters->getRawParameterValue ("isPitchSequenceEnabled_raw");
isDutySequenceEnabled_raw = (float*) parameters->getRawParameterValue ("isDutySequenceEnabled_raw");
pitchSequenceMode_raw = (float*) parameters->getRawParameterValue ("pitchSequenceMode_raw");
//Pitch resolution
bendResolution = (float*) parameters->getRawParameterValue("bendResolution");
}
};

View File

@ -79,7 +79,6 @@ void TonalVoice::calculateAngleDelta()
+ currentAutoBendAmount
+ vibratoAmount
+ finePitchInSeq;
auto cyclesPerSecond = noteNoToHeltzDouble (noteNoInDouble);
auto cyclesPerSample = cyclesPerSecond / getSampleRate();
@ -203,6 +202,8 @@ 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);
}