Add option to capture only when host transport active. Add option to always pass input audio through. That should probably be a plugin parameter though...

This commit is contained in:
xenakios 2017-12-20 20:33:34 +02:00
parent 8c57fcce0d
commit 0052c77bbb
3 changed files with 21 additions and 2 deletions

View File

@ -225,6 +225,7 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu()
PopupMenu menu; PopupMenu menu;
menu.addItem(1, "Play when host transport running", true, processor.m_play_when_host_plays); menu.addItem(1, "Play when host transport running", true, processor.m_play_when_host_plays);
menu.addItem(2, "Capture when host transport running", true, processor.m_capture_when_host_plays); menu.addItem(2, "Capture when host transport running", true, processor.m_capture_when_host_plays);
menu.addItem(3, "Always pass audio input through", true, processor.m_pass_input_through);
//menu.addItem(3, "Prebuffering", true, processor.m_use_backgroundbuffering); //menu.addItem(3, "Prebuffering", true, processor.m_use_backgroundbuffering);
PopupMenu bufferingmenu; PopupMenu bufferingmenu;
int curbufamount = processor.getPreBufferAmount(); int curbufamount = processor.getPreBufferAmount();
@ -244,6 +245,10 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu()
{ {
processor.m_capture_when_host_plays = !processor.m_capture_when_host_plays; processor.m_capture_when_host_plays = !processor.m_capture_when_host_plays;
} }
if (r == 3)
{
processor.m_pass_input_through = !processor.m_pass_input_through;
}
if (r >= 100 && r < 200) if (r >= 100 && r < 200)
{ {
if (r == 100) if (r == 100)

View File

@ -285,12 +285,14 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl
ScopedLock locker(m_cs); ScopedLock locker(m_cs);
m_cur_sr = sampleRate; m_cur_sr = sampleRate;
m_curmaxblocksize = samplesPerBlock; m_curmaxblocksize = samplesPerBlock;
m_input_buffer.setSize(2, samplesPerBlock);
int numoutchans = *m_outchansparam; int numoutchans = *m_outchansparam;
if (numoutchans != m_cur_num_out_chans) if (numoutchans != m_cur_num_out_chans)
m_ready_to_play = false; m_ready_to_play = false;
if (m_using_memory_buffer == true) if (m_using_memory_buffer == true)
{ {
int len = jlimit(100,m_recbuffer.getNumSamples(), m_rec_pos); int len = jlimit(100,m_recbuffer.getNumSamples(),
int(getSampleRateChecked()*(*getFloatParameter(cpi_max_capture_len))));
m_stretch_source->setAudioBufferAsInputSource(&m_recbuffer, m_stretch_source->setAudioBufferAsInputSource(&m_recbuffer,
getSampleRateChecked(), getSampleRateChecked(),
len); len);
@ -373,13 +375,16 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
m_cur_sr = srtemp; m_cur_sr = srtemp;
const int totalNumInputChannels = getTotalNumInputChannels(); const int totalNumInputChannels = getTotalNumInputChannels();
const int totalNumOutputChannels = getTotalNumOutputChannels(); const int totalNumOutputChannels = getTotalNumOutputChannels();
for (int i = 0; i < totalNumInputChannels; ++i)
m_input_buffer.copyFrom(i, 0, buffer, i, 0, buffer.getNumSamples());
for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i) for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples()); buffer.clear (i, 0, buffer.getNumSamples());
if (m_ready_to_play == false) if (m_ready_to_play == false)
return; return;
if (m_is_recording == true) if (m_is_recording == true)
{ {
if (m_playposinfo.isPlaying == false && m_capture_when_host_plays == true)
return;
int recbuflenframes = m_max_reclen * getSampleRate(); int recbuflenframes = m_max_reclen * getSampleRate();
copyAudioBufferWrappingPosition(buffer, m_recbuffer, m_rec_pos, recbuflenframes); copyAudioBufferWrappingPosition(buffer, m_recbuffer, m_rec_pos, recbuflenframes);
callGUI(this,[this, &buffer](PaulstretchpluginAudioProcessorEditor*ed) callGUI(this,[this, &buffer](PaulstretchpluginAudioProcessorEditor*ed)
@ -450,6 +455,13 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
{ {
m_buffering_source->getNextAudioBlock(aif); m_buffering_source->getNextAudioBlock(aif);
} }
if (m_pass_input_through == true)
{
for (int i = 0; i < totalNumInputChannels; ++i)
{
buffer.addFrom(i, 0, m_input_buffer, i, 0, buffer.getNumSamples());
}
}
for (int i = 0; i < buffer.getNumChannels(); ++i) for (int i = 0; i < buffer.getNumChannels(); ++i)
{ {
for (int j = 0; j < buffer.getNumSamples(); ++j) for (int j = 0; j < buffer.getNumSamples(); ++j)

View File

@ -139,6 +139,7 @@ public:
bool m_play_when_host_plays = false; bool m_play_when_host_plays = false;
bool m_capture_when_host_plays = false; bool m_capture_when_host_plays = false;
bool m_use_backgroundbuffering = true; bool m_use_backgroundbuffering = true;
bool m_pass_input_through = false;
void setPreBufferAmount(int x); void setPreBufferAmount(int x);
int getPreBufferAmount() int getPreBufferAmount()
{ {
@ -180,6 +181,7 @@ private:
int m_curmaxblocksize = 0; int m_curmaxblocksize = 0;
double m_cur_sr = 0.0; double m_cur_sr = 0.0;
bool m_last_host_playing = false; bool m_last_host_playing = false;
AudioBuffer<float> m_input_buffer;
//============================================================================== //==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
}; };