Added ADSR envelope
This commit is contained in:
parent
aa740528f5
commit
2ac85fac1f
@ -585,6 +585,7 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl
|
|||||||
{
|
{
|
||||||
++m_prepare_count;
|
++m_prepare_count;
|
||||||
ScopedLock locker(m_cs);
|
ScopedLock locker(m_cs);
|
||||||
|
m_adsr.setSampleRate(sampleRate);
|
||||||
m_cur_sr = sampleRate;
|
m_cur_sr = sampleRate;
|
||||||
m_curmaxblocksize = samplesPerBlock;
|
m_curmaxblocksize = samplesPerBlock;
|
||||||
m_input_buffer.setSize(getMainBusNumInputChannels(), samplesPerBlock);
|
m_input_buffer.setSize(getMainBusNumInputChannels(), samplesPerBlock);
|
||||||
@ -787,16 +788,19 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
|
|||||||
if (midi_msg.isNoteOff() && midi_msg.getNoteNumber()==m_midinote_to_use)
|
if (midi_msg.isNoteOff() && midi_msg.getNoteNumber()==m_midinote_to_use)
|
||||||
{
|
{
|
||||||
m_midinote_to_use = -1;
|
m_midinote_to_use = -1;
|
||||||
|
m_adsr.noteOff();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (midi_msg.isNoteOn())
|
if (midi_msg.isNoteOn())
|
||||||
{
|
{
|
||||||
m_midinote_to_use = midi_msg.getNoteNumber();
|
m_midinote_to_use = midi_msg.getNoteNumber();
|
||||||
|
m_adsr.setParameters({1.0,0.5,0.5,1.0});
|
||||||
|
m_adsr.noteOn();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (m_midinote_to_use >= 0)
|
if (m_midinote_control == true && m_midinote_to_use >= 0)
|
||||||
{
|
{
|
||||||
int note_offset = m_midinote_to_use - 60;
|
int note_offset = m_midinote_to_use - 60;
|
||||||
m_ppar.pitch_shift.cents += 100.0*note_offset;
|
m_ppar.pitch_shift.cents += 100.0*note_offset;
|
||||||
@ -836,6 +840,13 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
|
|||||||
{
|
{
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (m_midinote_control == true)
|
||||||
|
{
|
||||||
|
m_adsr.applyEnvelopeToBuffer(buffer, 0, buffer.getNumSamples());
|
||||||
|
}
|
||||||
|
}
|
||||||
auto ed = dynamic_cast<PaulstretchpluginAudioProcessorEditor*>(getActiveEditor());
|
auto ed = dynamic_cast<PaulstretchpluginAudioProcessorEditor*>(getActiveEditor());
|
||||||
if (ed != nullptr)
|
if (ed != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -227,6 +227,7 @@ public:
|
|||||||
bool m_is_recording = false;
|
bool m_is_recording = false;
|
||||||
bool m_save_captured_audio = true;
|
bool m_save_captured_audio = true;
|
||||||
String m_capture_location;
|
String m_capture_location;
|
||||||
|
bool m_midinote_control = true;
|
||||||
private:
|
private:
|
||||||
bool m_prebuffering_inited = false;
|
bool m_prebuffering_inited = false;
|
||||||
AudioBuffer<float> m_recbuffer;
|
AudioBuffer<float> m_recbuffer;
|
||||||
@ -274,6 +275,8 @@ private:
|
|||||||
void saveCaptureBuffer();
|
void saveCaptureBuffer();
|
||||||
SharedResourcePointer<MyThreadPool> m_threadpool;
|
SharedResourcePointer<MyThreadPool> m_threadpool;
|
||||||
int m_midinote_to_use = -1;
|
int m_midinote_to_use = -1;
|
||||||
|
ADSR m_adsr;
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user