argh
This commit is contained in:
xenakios 2018-02-13 23:59:51 +02:00
commit 7095396322
7 changed files with 51 additions and 22 deletions

View File

@ -28,11 +28,14 @@ FFT::FFT(int nsamples_, bool no_inverse)
printf("WARNING: Odd sample size on FFT::FFT() (%d)",nsamples); printf("WARNING: Odd sample size on FFT::FFT() (%d)",nsamples);
}; };
smp.resize(nsamples); smp.resize(nsamples);
for (int i = 0; i < nsamples; i++) smp[i] = 0.0; for (int i = 0; i < nsamples; i++)
smp[i] = 0.0;
freq.resize(nsamples/2+1); freq.resize(nsamples/2+1);
for (int i=0;i<nsamples/2+1;i++) freq[i]=0.0; for (int i=0;i<nsamples/2+1;i++)
freq[i]=0.0;
window.data.resize(nsamples); window.data.resize(nsamples);
for (int i=0;i<nsamples;i++) window.data[i]=0.707f; for (int i=0;i<nsamples;i++)
window.data[i]=0.707f;
window.type=W_RECTANGULAR; window.type=W_RECTANGULAR;

View File

@ -529,7 +529,7 @@ void StretchAudioSource::setFFTSize(int size)
{ {
m_xfadetask.state = 1; m_xfadetask.state = 1;
m_xfadetask.counter = 0; m_xfadetask.counter = 0;
m_xfadetask.xfade_len = 44100; m_xfadetask.xfade_len = 16384;
m_xfadetask.requested_fft_size = size; m_xfadetask.requested_fft_size = size;
} }
else else

View File

@ -240,4 +240,14 @@ inline String secondsToString(double seconds)
timestring = String(durintdays) + " days " + String(durinthours % 24) + " hours " + timestring = String(durintdays) + " days " + String(durinthours % 24) + " hours " +
String(durintminutes % 60) + " mins "; String(durintminutes % 60) + " mins ";
return timestring; return timestring;
} }
inline void toggleBool(bool& b)
{
b = !b;
}
inline void toggleBool(AudioParameterBool* b)
{
*b = !(*b);
}

View File

@ -139,6 +139,9 @@ void PaulstretchpluginAudioProcessorEditor::resized()
int xoffs = 1; int xoffs = 1;
int yoffs = 30; int yoffs = 30;
int div = w / 4; int div = w / 4;
//std::vector<std::vector<int>> layout;
//layout.emplace_back(cpi_capture_enabled, cpi_passthrough, cpi_pause_enabled, cpi_freeze);
//layout.emplace_back(cpi_main_volume, cpi_num_inchans, cpi_num_outchans);
m_parcomps[cpi_capture_enabled]->setBounds(xoffs, yoffs, div-1, 24); m_parcomps[cpi_capture_enabled]->setBounds(xoffs, yoffs, div-1, 24);
//xoffs += div; //xoffs += div;
//m_parcomps[cpi_max_capture_len]->setBounds(xoffs, yoffs, div - 1, 24); //m_parcomps[cpi_max_capture_len]->setBounds(xoffs, yoffs, div - 1, 24);
@ -235,7 +238,13 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id)
m_wavecomponent.setRecordingPosition(processor.getRecordingPositionPercent()); m_wavecomponent.setRecordingPosition(processor.getRecordingPositionPercent());
} else } else
m_wavecomponent.setRecordingPosition(-1.0); m_wavecomponent.setRecordingPosition(-1.0);
String infotext = String(processor.getStretchSource()->m_param_change_count)+" param changes "+m_last_err+" FFT size "+ String infotext;
if (processor.m_show_technical_info)
{
infotext += String(processor.getStretchSource()->m_param_change_count);
infotext += " param changes ";
}
infotext += m_last_err + " FFT size " +
String(processor.getStretchSource()->getFFTSize()); String(processor.getStretchSource()->getFFTSize());
if (processor.m_abnormal_output_samples > 0) if (processor.m_abnormal_output_samples > 0)
infotext += " " + String(processor.m_abnormal_output_samples) + " invalid sample values"; infotext += " " + String(processor.m_abnormal_output_samples) + " invalid sample values";
@ -243,7 +252,8 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id)
infotext += " (offline rendering)"; infotext += " (offline rendering)";
if (processor.m_playposinfo.isPlaying) if (processor.m_playposinfo.isPlaying)
infotext += " "+String(processor.m_playposinfo.timeInSeconds,1); infotext += " "+String(processor.m_playposinfo.timeInSeconds,1);
infotext += " " + String(m_wavecomponent.m_image_init_count) + " " + String(m_wavecomponent.m_image_update_count); if (processor.m_show_technical_info)
infotext += " " + String(m_wavecomponent.m_image_init_count) + " " + String(m_wavecomponent.m_image_update_count);
m_info_label.setText(infotext, dontSendNotification); m_info_label.setText(infotext, dontSendNotification);
m_perfmeter.repaint(); m_perfmeter.repaint();
} }
@ -326,6 +336,7 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu()
#ifdef JUCE_DEBUG #ifdef JUCE_DEBUG
menu.addItem(6, "Dump preset to clipboard", true, false); menu.addItem(6, "Dump preset to clipboard", true, false);
#endif #endif
menu.addItem(7, "Show technical info", true, processor.m_show_technical_info);
int r = menu.show(); int r = menu.show();
if (r >= 200 && r < 210) if (r >= 200 && r < 210)
{ {
@ -334,11 +345,11 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu()
} }
if (r == 1) if (r == 1)
{ {
processor.m_play_when_host_plays = !processor.m_play_when_host_plays; toggleBool(processor.m_play_when_host_plays);
} }
if (r == 2) if (r == 2)
{ {
processor.m_capture_when_host_plays = !processor.m_capture_when_host_plays; toggleBool(processor.m_capture_when_host_plays);
} }
if (r == 4) if (r == 4)
{ {
@ -346,7 +357,7 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu()
} }
if (r == 5) if (r == 5)
{ {
processor.m_load_file_with_state = !processor.m_load_file_with_state; toggleBool(processor.m_load_file_with_state);
} }
if (r == 3) if (r == 3)
{ {
@ -374,6 +385,11 @@ String juceversiontxt = String("JUCE ") + String(JUCE_MAJOR_VERSION) + "." + Str
String txt = Base64::toBase64(destData.getData(), destData.getSize()); String txt = Base64::toBase64(destData.getData(), destData.getSize());
SystemClipboard::copyTextToClipboard(txt); SystemClipboard::copyTextToClipboard(txt);
} }
if (r == 7)
{
toggleBool(processor.m_show_technical_info);
processor.m_propsfile->m_props_file->setValue("showtechnicalinfo", processor.m_show_technical_info);
}
} }
WaveformComponent::WaveformComponent(AudioFormatManager* afm, AudioThumbnail* thumb) WaveformComponent::WaveformComponent(AudioFormatManager* afm, AudioThumbnail* thumb)
@ -442,7 +458,6 @@ void WaveformComponent::paint(Graphics & g)
if (m_image_dirty == true || m_waveimage.getWidth() != getWidth() if (m_image_dirty == true || m_waveimage.getWidth() != getWidth()
|| m_waveimage.getHeight() != getHeight() - m_topmargin) || m_waveimage.getHeight() != getHeight() - m_topmargin)
{ {
//Logger::writeToLog("updating cached waveform image");
if (m_waveimage.getWidth() != getWidth() if (m_waveimage.getWidth() != getWidth()
|| m_waveimage.getHeight() != getHeight() - m_topmargin) || m_waveimage.getHeight() != getHeight() - m_topmargin)
{ {
@ -456,15 +471,11 @@ void WaveformComponent::paint(Graphics & g)
} }
else else
{ {
//g.fillAll(Colours::black);
g.setColour(Colours::darkgrey); g.setColour(Colours::darkgrey);
m_thumbnail->drawChannels(g, { 0,m_topmargin,getWidth(),getHeight() - m_topmargin }, m_thumbnail->drawChannels(g, { 0,m_topmargin,getWidth(),getHeight() - m_topmargin },
thumblen*m_view_range.getStart(), thumblen*m_view_range.getEnd(), 1.0f); thumblen*m_view_range.getStart(), thumblen*m_view_range.getEnd(), 1.0f);
} }
//g.setColour(Colours::darkgrey);
//m_thumb->drawChannels(g, { 0,m_topmargin,getWidth(),getHeight()-m_topmargin },
// 0.0, thumblen, 1.0f);
g.setColour(Colours::white.withAlpha(0.5f)); g.setColour(Colours::white.withAlpha(0.5f));
double sel_len = m_time_sel_end - m_time_sel_start; double sel_len = m_time_sel_end - m_time_sel_start;
//if (sel_len > 0.0 && sel_len < 1.0) //if (sel_len > 0.0 && sel_len < 1.0)
@ -514,7 +525,6 @@ void WaveformComponent::timerCallback()
void WaveformComponent::setFileCachedRange(std::pair<Range<double>, Range<double>> rng) void WaveformComponent::setFileCachedRange(std::pair<Range<double>, Range<double>> rng)
{ {
m_file_cached = rng; m_file_cached = rng;
//repaint();
} }
void WaveformComponent::setTimerEnabled(bool b) void WaveformComponent::setTimerEnabled(bool b)
@ -898,7 +908,10 @@ void ParameterComponent::resized()
{ {
if (m_slider) if (m_slider)
{ {
m_label.setBounds(0, 0, 200, 24); int labw = 200;
if (getWidth() < 400)
labw = 100;
m_label.setBounds(0, 0, labw, 24);
m_slider->setBounds(m_label.getRight() + 1, 0, getWidth() - 2 - m_label.getWidth(), 24); m_slider->setBounds(m_label.getRight() + 1, 0, getWidth() - 2 - m_label.getWidth(), 24);
} }
if (m_togglebut) if (m_togglebut)

View File

@ -134,19 +134,20 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
filt_convertFrom0To1Func,filt_convertTo0To1Func), 20000.0f));; // 24 filt_convertFrom0To1Func,filt_convertTo0To1Func), 20000.0f));; // 24
addParameter(make_floatpar("onsetdetect_0", "Onset detection", 0.0f, 1.0f, 0.0f, 0.01, 1.0)); // 25 addParameter(make_floatpar("onsetdetect_0", "Onset detection", 0.0f, 1.0f, 0.0f, 0.01, 1.0)); // 25
addParameter(new AudioParameterBool("capture_enabled0", "Capture", false)); // 26 addParameter(new AudioParameterBool("capture_enabled0", "Capture", false)); // 26
m_outchansparam = new AudioParameterInt("numoutchans0", "Num output channels", 2, 8, 2); // 27 m_outchansparam = new AudioParameterInt("numoutchans0", "Num outs", 2, 8, 2); // 27
addParameter(m_outchansparam); // 27 addParameter(m_outchansparam); // 27
addParameter(new AudioParameterBool("pause_enabled0", "Pause", false)); // 28 addParameter(new AudioParameterBool("pause_enabled0", "Pause", false)); // 28
addParameter(new AudioParameterFloat("maxcapturelen_0", "Max capture length", 1.0f, 120.0f, 10.0f)); // 29 addParameter(new AudioParameterFloat("maxcapturelen_0", "Max capture length", 1.0f, 120.0f, 10.0f)); // 29
addParameter(new AudioParameterBool("passthrough0", "Pass input through", false)); // 30 addParameter(new AudioParameterBool("passthrough0", "Pass input through", false)); // 30
addParameter(new AudioParameterBool("markdirty0", "Internal (don't use)", false)); // 31 addParameter(new AudioParameterBool("markdirty0", "Internal (don't use)", false)); // 31
m_inchansparam = new AudioParameterInt("numinchans0", "Num input channels", 2, 8, 2); // 32 m_inchansparam = new AudioParameterInt("numinchans0", "Num ins", 2, 8, 2); // 32
addParameter(m_inchansparam); // 32 addParameter(m_inchansparam); // 32
auto& pars = getParameters(); auto& pars = getParameters();
for (const auto& p : pars) for (const auto& p : pars)
m_reset_pars.push_back(p->getValue()); m_reset_pars.push_back(p->getValue());
setPreBufferAmount(2); setPreBufferAmount(2);
startTimer(1, 50); startTimer(1, 50);
m_show_technical_info = m_propsfile->m_props_file->getBoolValue("showtechnicalinfo", false);
} }
PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor() PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor()
@ -614,7 +615,7 @@ void PaulstretchpluginAudioProcessor::setStateInformation (const void* data, int
void PaulstretchpluginAudioProcessor::setDirty() void PaulstretchpluginAudioProcessor::setDirty()
{ {
*getBoolParameter(cpi_markdirty) = !(*getBoolParameter(cpi_markdirty)); toggleBool(getBoolParameter(cpi_markdirty));
} }
void PaulstretchpluginAudioProcessor::setRecordingEnabled(bool b) void PaulstretchpluginAudioProcessor::setRecordingEnabled(bool b)
@ -625,7 +626,8 @@ void PaulstretchpluginAudioProcessor::setRecordingEnabled(bool b)
{ {
m_using_memory_buffer = true; m_using_memory_buffer = true;
m_current_file = File(); m_current_file = File();
m_recbuffer.setSize(getMainBusNumInputChannels(), m_max_reclen*getSampleRateChecked()+4096,false,false,true); int numchans = *m_inchansparam;
m_recbuffer.setSize(numchans, m_max_reclen*getSampleRateChecked()+4096,false,false,true);
m_recbuffer.clear(); m_recbuffer.clear();
m_rec_pos = 0; m_rec_pos = 0;
m_thumb->reset(m_recbuffer.getNumChannels(), getSampleRateChecked(), lenbufframes); m_thumb->reset(m_recbuffer.getNumChannels(), getSampleRateChecked(), lenbufframes);

View File

@ -162,6 +162,7 @@ public:
void setStateFromTree(ValueTree tree); void setStateFromTree(ValueTree tree);
bool m_state_dirty = false; bool m_state_dirty = false;
std::unique_ptr<AudioThumbnail> m_thumb; std::unique_ptr<AudioThumbnail> m_thumb;
bool m_show_technical_info = false;
private: private:

View File

@ -8,7 +8,7 @@ Released under GNU General Public License v.2 license.
History : History :
02-12-2018 1.0.1 02-13-2018 1.0.1
-Increased maximum number of input channels to 8 -Increased maximum number of input channels to 8
-GUI performance improvement/bug fix during capture mode -GUI performance improvement/bug fix during capture mode
02-09-2018 1.0.0 02-09-2018 1.0.0