Made input capture buffer circular and update waveform thumbnail while capturing audio.

This commit is contained in:
xenakios
2017-11-15 17:52:47 +02:00
parent c34961995d
commit f4c8d2891b
4 changed files with 76 additions and 18 deletions

View File

@ -97,9 +97,11 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id)
if (processor.isRecordingEnabled() != m_rec_enable.getToggleState())
m_rec_enable.setToggleState(processor.isRecordingEnabled(), dontSendNotification);
if (processor.isRecordingEnabled())
m_info_label.setText(String(processor.getRecordingPositionPercent()*100.0, 1),dontSendNotification);
else
m_info_label.setText(String(processor.m_control->getStretchAudioSource()->m_param_change_count), dontSendNotification);
{
m_wavecomponent.setRecordingPosition(processor.getRecordingPositionPercent());
} else
m_wavecomponent.setRecordingPosition(-1.0);
m_info_label.setText(String(processor.m_control->getStretchAudioSource()->m_param_change_count), dontSendNotification);
}
}
@ -116,6 +118,16 @@ void PaulstretchpluginAudioProcessorEditor::setAudioBuffer(AudioBuffer<float>* b
});
}
void PaulstretchpluginAudioProcessorEditor::beginAddingAudioBlocks(int channels, int samplerate, int totalllen)
{
m_wavecomponent.beginAddingAudioBlocks(channels, samplerate, totalllen);
}
void PaulstretchpluginAudioProcessorEditor::addAudioBlock(AudioBuffer<float>& buf, int samplerate, int pos)
{
m_wavecomponent.addAudioBlock(buf, samplerate, pos);
}
WaveformComponent::WaveformComponent(AudioFormatManager* afm) : m_thumbcache(100)
{
TimeSelectionChangedCallback = [](Range<double>, int) {};
@ -217,6 +229,12 @@ void WaveformComponent::paint(Graphics & g)
double pos = jmap<double>(CursorPosCallback(), m_view_range.getStart(), m_view_range.getEnd(), 0, getWidth());
g.fillRect((int)pos, m_topmargin, 1, getHeight() - m_topmargin);
}
if (m_rec_pos >= 0.0)
{
g.setColour(Colours::lightpink);
double pos = jmap<double>(m_rec_pos, m_view_range.getStart(), m_view_range.getEnd(), 0, getWidth());
g.fillRect((int)pos, m_topmargin, 1, getHeight() - m_topmargin);
}
g.setColour(Colours::aqua.darker());
g.drawText(m_curfile.getFullPathName(), 2, m_topmargin + 2, getWidth(), 20, Justification::topLeft);
}
@ -248,6 +266,18 @@ void WaveformComponent::setAudioBuffer(AudioBuffer<float>* buf, int samplerate,
m_thumb->addBlock(0, *buf, 0, len);
}
void WaveformComponent::beginAddingAudioBlocks(int channels, int samplerate, int totalllen)
{
m_waveimage = Image();
m_curfile = File();
m_thumb->reset(channels, samplerate, totalllen);
}
void WaveformComponent::addAudioBlock(AudioBuffer<float>& buf, int samplerate, int pos)
{
m_thumb->addBlock(pos, buf, 0, buf.getNumSamples());
}
void WaveformComponent::timerCallback()
{
repaint();