Keep track of captured length and set sound play range when stopped according to that

This commit is contained in:
xenakios 2018-06-05 21:11:17 +03:00
parent 857c2adf2a
commit c010a4d48f
3 changed files with 11 additions and 2 deletions

View File

@ -504,7 +504,7 @@ String PaulstretchpluginAudioProcessor::offlineRender(File outputfile)
auto rendertask = [ss,writer,blocksize,numoutchans, outsr, this]()
{
AudioBuffer<float> renderbuffer(numoutchans, blocksize);
int64_t outlen = 250 * outsr;
int64_t outlen = 10 * outsr;
int64_t outcounter = 0;
AudioSourceChannelInfo asci(renderbuffer);
m_offline_render_state = 0;
@ -661,6 +661,9 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
copyAudioBufferWrappingPosition(buffer, m_recbuffer, m_rec_pos, recbuflenframes);
m_thumb->addBlock(m_rec_pos, buffer, 0, buffer.getNumSamples());
m_rec_pos = (m_rec_pos + buffer.getNumSamples()) % recbuflenframes;
m_rec_count += buffer.getNumSamples();
if (m_rec_count<recbuflenframes)
m_recorded_range = { 0, m_rec_count };
if (m_mute_while_capturing == true)
buffer.clear();
return;
@ -791,6 +794,8 @@ void PaulstretchpluginAudioProcessor::setRecordingEnabled(bool b)
m_rec_pos = 0;
m_thumb->reset(m_recbuffer.getNumChannels(), getSampleRateChecked(), lenbufframes);
m_is_recording = true;
m_recorded_range = Range<int>();
m_rec_count = 0;
}
else
{
@ -918,7 +923,8 @@ void PaulstretchpluginAudioProcessor::finishRecording(int lenrecording)
{
m_is_recording = false;
m_stretch_source->setAudioBufferAsInputSource(&m_recbuffer, getSampleRateChecked(), lenrecording);
m_stretch_source->setPlayRange({ *getFloatParameter(cpi_soundstart),*getFloatParameter(cpi_soundend) });
*getFloatParameter(cpi_soundstart) = 0.0f;
*getFloatParameter(cpi_soundend) = jlimit<double>(0.01, 1.0, 1.0 / lenrecording * m_rec_count);
}
AudioProcessor* JUCE_CALLTYPE createPluginFilter()

View File

@ -222,6 +222,8 @@ private:
double m_max_reclen = 10.0;
bool m_is_recording = false;
int m_rec_pos = 0;
int m_rec_count = 0;
Range<int> m_recorded_range;
void finishRecording(int lenrecorded);
bool m_using_memory_buffer = true;
int m_cur_num_out_chans = 2;

View File

@ -167,6 +167,7 @@ void RenderSettingsComponent::buttonClicked (Button* buttonThatWasClicked)
sampleRate = 0;
double maxrenderlen = m_editorMaxOutDuration.getText().getDoubleValue()*3600.0;
maxrenderlen = jlimit(1.0, 1000000.0, maxrenderlen);
m_proc->offlineRender(File(outfileNameEditor.getText()));
//m_main->renderToFile(File(outfileNameEditor.getText()),numLoops,
// comboBoxBitDepth.getSelectedId()-1,sampleRate,m_toggleFloatClip.getToggleState(),maxrenderlen);
auto pardlg = dynamic_cast<DialogWindow*>(getParentComponent());