void initADSR(struct ADSR* adsr, unsigned a, unsigned d, float s, unsigned r){ setSustain(adsr, s); setAttack(adsr, a); setDecay(adsr, d); setRelease(adsr, r); adsr->index = 0; adsr->level = 0.00000000001f; }
QAGC::QAGC(QObject *parent, int size) : QObject(parent) , set(Settings::instance()) , m_size(size) , m_mask(size * 2) , m_index(0) , m_sndex(0) , m_hangIndex(0) , m_fastIndex(FASTLEAD) , m_fastHang(0) , m_samplerate(set->getSampleRate()) //, m_agcMode(agcMED) , m_gainTop(qPow(10.0f, 120.0f/20.0f)) , m_gainNow(1.0f) , m_gainFastNow(1.0f) , m_gainBottom(.001f) , m_gainLimit(1.0f) //, m_gainFix(pow(10.0, 60.0/20.0)) , m_gainFix(qPow(10.0f, 80.0f/20.0f)) , m_attack(0.0f) , m_oneMAttack(0.0f) , m_decay(0.0f) , m_oneMDecay(0.0f) , m_slope(1.0f) , m_fastAttack(0.0f) , m_oneMFastAttack(0.0f) , m_fastDecay(0.0f) , m_oneMFastDecay(0.0f) , m_hangTime(480.0f * 0.001f) , m_hangThresh(0.001f) , m_fastHangTime(48.0f * 0.001f) { setAttack(1.0); setDecay(1.0); setMode(agcMED); m_fastAttack = 1.0 - qExp(-1000.0 / (0.2f * m_samplerate)); m_oneMFastAttack = qExp(-1000.0 / (0.2 * m_samplerate)); m_fastDecay = 1.0 - qExp(-1000.0 / (3.0 * m_samplerate)); m_oneMFastDecay = qExp(-1000.0 / (3.0 * m_samplerate)); InitCPX(G, m_mask, 0.0f); m_mask -= 1; }
//============================================================================== ADSRComponent::ADSRComponent () { addAndMakeVisible (attackSlider = new Slider ("Attack slider")); attackSlider->setTooltip (TRANS("Attack")); attackSlider->setRange (5, 15000, 0); attackSlider->setSliderStyle (Slider::LinearVertical); attackSlider->setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20); attackSlider->addListener (this); attackSlider->setSkewFactor (0.4); addAndMakeVisible (decaySlider = new Slider (String::empty)); decaySlider->setTooltip (TRANS("Decay")); decaySlider->setRange (5, 15000, 0); decaySlider->setSliderStyle (Slider::LinearVertical); decaySlider->setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20); decaySlider->addListener (this); decaySlider->setSkewFactor (0.4); addAndMakeVisible (sustainSlider = new Slider (String::empty)); sustainSlider->setTooltip (TRANS("Sustain")); sustainSlider->setRange (0, 1, 0); sustainSlider->setSliderStyle (Slider::LinearVertical); sustainSlider->setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20); sustainSlider->addListener (this); addAndMakeVisible (releaseSlider = new Slider (String::empty)); releaseSlider->setTooltip (TRANS("Release")); releaseSlider->setRange (5, 15000, 0); releaseSlider->setSliderStyle (Slider::LinearVertical); releaseSlider->setTextBoxStyle (Slider::TextBoxBelow, false, 80, 20); releaseSlider->addListener (this); releaseSlider->setSkewFactor (0.4); addAndMakeVisible (attackLabel = new Label (String::empty, TRANS("A"))); attackLabel->setFont (Font (15.00f, Font::bold)); attackLabel->setJustificationType (Justification::centred); attackLabel->setEditable (false, false, false); attackLabel->setColour (TextEditor::textColourId, Colours::black); attackLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); addAndMakeVisible (decayLabel = new Label (String::empty, TRANS("D"))); decayLabel->setFont (Font (15.00f, Font::bold)); decayLabel->setJustificationType (Justification::centred); decayLabel->setEditable (false, false, false); decayLabel->setColour (TextEditor::textColourId, Colours::black); decayLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); addAndMakeVisible (sustainLabel = new Label (String::empty, TRANS("S"))); sustainLabel->setFont (Font (15.00f, Font::bold)); sustainLabel->setJustificationType (Justification::centred); sustainLabel->setEditable (false, false, false); sustainLabel->setColour (TextEditor::textColourId, Colours::black); sustainLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); addAndMakeVisible (releaseLabel = new Label (String::empty, TRANS("R"))); releaseLabel->setFont (Font (15.00f, Font::bold)); releaseLabel->setJustificationType (Justification::centred); releaseLabel->setEditable (false, false, false); releaseLabel->setColour (TextEditor::textColourId, Colours::black); releaseLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); //[UserPreSize] //[/UserPreSize] setSize (600, 400); //[Constructor] You can add your own custom stuff here.. setAttack(5); setDecay(5); setSustain(1); setRelease(5); //[/Constructor] }