Add menu actions and logic to deal with playing only when the host plays. Also seek to stretch source active time range beginning when starting play.

This commit is contained in:
xenakios 2017-12-20 01:12:47 +02:00
parent b6e46bd293
commit 7d8616ec70
3 changed files with 24 additions and 3 deletions

View File

@ -223,9 +223,17 @@ void PaulstretchpluginAudioProcessorEditor::chooseFile()
void PaulstretchpluginAudioProcessorEditor::showSettingsMenu()
{
PopupMenu menu;
menu.addItem(1, "Foo 1", true, false);
menu.addItem(2, "Foo 2", true, false);
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);
int r = menu.show();
if (r == 1)
{
processor.m_play_when_host_plays = !processor.m_play_when_host_plays;
}
if (r == 2)
{
processor.m_capture_when_host_plays = !processor.m_capture_when_host_plays;
}
}
WaveformComponent::WaveformComponent(AudioFormatManager* afm)

View File

@ -381,6 +381,17 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
}
jassert(m_buffering_source != nullptr);
jassert(m_bufferingthread.isThreadRunning());
if (m_last_host_playing == false && m_playposinfo.isPlaying)
{
m_stretch_source->seekPercent(*getFloatParameter(cpi_soundstart));
m_last_host_playing = true;
}
else if (m_last_host_playing == true && m_playposinfo.isPlaying == false)
{
m_last_host_playing = false;
}
if (m_play_when_host_plays == true && m_playposinfo.isPlaying == false)
return;
m_stretch_source->setMainVolume(*getFloatParameter(cpi_main_volume));
m_stretch_source->setRate(*getFloatParameter(cpi_stretchamount));

View File

@ -136,6 +136,8 @@ public:
double getSampleRateChecked();
int m_abnormal_output_samples = 0;
AudioPlayHead::CurrentPositionInfo m_playposinfo;
bool m_play_when_host_plays = false;
bool m_capture_when_host_plays = false;
private:
@ -169,7 +171,7 @@ private:
AudioParameterInt* m_outchansparam = nullptr;
int m_curmaxblocksize = 0;
double m_cur_sr = 0.0;
bool m_last_host_playing = false;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
};