Add more parameters including input capture enabled. A slightly nasty timer hack had to be implemented for that but can't be helped since the Juce provided bool parameter doesn't do callbacks...Small tweaks and fixes.

This commit is contained in:
xenakios 2017-12-13 18:30:09 +02:00
parent 3dc95b6f1d
commit bd1eabf3bf
5 changed files with 66 additions and 19 deletions

View File

@ -345,6 +345,12 @@ REALTYPE Stretch::process(REALTYPE *smps,int nsmps)
return onset; return onset;
}; };
void Stretch::set_onset_detection_sensitivity(REALTYPE detection_sensitivity)
{
onset_detection_sensitivity = detection_sensitivity;
if (detection_sensitivity<1e-3) extra_onset_time_credit = 0.0;
}
void Stretch::here_is_onset(REALTYPE onset){ void Stretch::here_is_onset(REALTYPE onset){
if (freezing) return; if (freezing) return;
if (onset>0.5){ if (onset>0.5){

View File

@ -129,7 +129,7 @@ class FFT
void applywindow(FFTWindow type); void applywindow(FFTWindow type);
std::vector<REALTYPE> smp;//size of samples/2 std::vector<REALTYPE> smp;//size of samples/2
std::vector<REALTYPE> freq;//size of samples std::vector<REALTYPE> freq;//size of samples
int nsamples; int nsamples=0;
private: private:
fftwf_plan planfftw,planifftw; fftwf_plan planfftw,planifftw;
@ -179,10 +179,7 @@ class Stretch
void set_rap(REALTYPE newrap);//set the current stretch value void set_rap(REALTYPE newrap);//set the current stretch value
void set_onset_detection_sensitivity(REALTYPE detection_sensitivity){ void set_onset_detection_sensitivity(REALTYPE detection_sensitivity);;
onset_detection_sensitivity=detection_sensitivity;
if (detection_sensitivity<1e-3) extra_onset_time_credit=0.0;
};
void here_is_onset(REALTYPE onset); void here_is_onset(REALTYPE onset);
virtual void setSampleRate(REALTYPE sr) { samplerate = jlimit(1000.0f, 38400.0f, sr); } virtual void setSampleRate(REALTYPE sr) { samplerate = jlimit(1000.0f, 38400.0f, sr); }
REALTYPE getSampleRate() { return samplerate; } REALTYPE getSampleRate() { return samplerate; }

View File

@ -498,12 +498,16 @@ void StretchAudioSource::setFFTWindowingType(int windowtype)
{ {
if (windowtype==m_fft_window_type) if (windowtype==m_fft_window_type)
return; return;
ScopedLock locker(m_cs); if (m_cs.tryEnter())
{
m_fft_window_type = windowtype; m_fft_window_type = windowtype;
for (int i = 0; i < m_stretchers.size(); ++i) for (int i = 0; i < m_stretchers.size(); ++i)
{ {
m_stretchers[i]->window_type = (FFTWindow)windowtype; m_stretchers[i]->window_type = (FFTWindow)windowtype;
} }
++m_param_change_count;
m_cs.exit();
}
} }
void StretchAudioSource::setFFTSize(int size) void StretchAudioSource::setFFTSize(int size)
@ -552,13 +556,18 @@ double StretchAudioSource::getOutputDurationSecondsForRange(Range<double> range,
void StretchAudioSource::setOnsetDetection(double x) void StretchAudioSource::setOnsetDetection(double x)
{ {
ScopedLock locker(m_cs); if (x == m_onsetdetection)
return;
if (m_cs.tryEnter())
{
m_onsetdetection = x; m_onsetdetection = x;
for (int i = 0; i < m_stretchers.size(); ++i) for (int i = 0; i < m_stretchers.size(); ++i)
{ {
m_stretchers[i]->set_onset_detection_sensitivity((float)x); m_stretchers[i]->set_onset_detection_sensitivity((float)x);
} }
++m_param_change_count; ++m_param_change_count;
m_cs.exit();
}
} }
void StretchAudioSource::setPlayRange(Range<double> playrange, bool isloop) void StretchAudioSource::setPlayRange(Range<double> playrange, bool isloop)

View File

@ -82,6 +82,7 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
setPreBufferAmount(2); setPreBufferAmount(2);
m_ppar.pitch_shift.enabled = true; m_ppar.pitch_shift.enabled = true;
m_ppar.freq_shift.enabled = true; m_ppar.freq_shift.enabled = true;
m_ppar.filter.enabled = true;
m_stretch_source->setOnsetDetection(0.0); m_stretch_source->setOnsetDetection(0.0);
m_stretch_source->setLoopingEnabled(true); m_stretch_source->setLoopingEnabled(true);
m_stretch_source->setFFTWindowingType(1); m_stretch_source->setFFTWindowingType(1);
@ -108,7 +109,13 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
addParameter(new AudioParameterFloat("octavemix1_0", "1 octave up level", 0.0f, 1.0f, 0.0f)); // 18 addParameter(new AudioParameterFloat("octavemix1_0", "1 octave up level", 0.0f, 1.0f, 0.0f)); // 18
addParameter(new AudioParameterFloat("octavemix15_0", "1 octave and fifth up level", 0.0f, 1.0f, 0.0f)); // 19 addParameter(new AudioParameterFloat("octavemix15_0", "1 octave and fifth up level", 0.0f, 1.0f, 0.0f)); // 19
addParameter(new AudioParameterFloat("octavemix2_0", "2 octaves up level", 0.0f, 1.0f, 0.0f)); // 20 addParameter(new AudioParameterFloat("octavemix2_0", "2 octaves up level", 0.0f, 1.0f, 0.0f)); // 20
addParameter(new AudioParameterFloat("tonalvsnoisebw_0", "Tonal vs Noise BW", 0.74f, 1.0f, 0.74f)); // 21
addParameter(new AudioParameterFloat("tonalvsnoisepreserve_0", "Tonal vs Noise preserve", -1.0f, 1.0f, 0.5f)); // 22
addParameter(new AudioParameterFloat("filter_low_0", "Filter low", 20.0f, 10000.0f, 20.0f)); // 23
addParameter(new AudioParameterFloat("filter_high_0", "Filter high", 20.0f, 20000.0f, 20000.0f)); // 24
addParameter(new AudioParameterFloat("onsetdetect_0", "Onset detection", 0.0f, 1.0f, 0.0f)); // 25
addParameter(new AudioParameterBool("capture_enabled0", "Capture", false)); // 26
startTimer(1, 50);
} }
PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor() PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor()
@ -342,6 +349,12 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
m_ppar.octave.o15 = *getFloatParameter(cpi_octaves15); m_ppar.octave.o15 = *getFloatParameter(cpi_octaves15);
m_ppar.octave.o2 = *getFloatParameter(cpi_octaves2); m_ppar.octave.o2 = *getFloatParameter(cpi_octaves2);
m_ppar.octave.enabled = true; m_ppar.octave.enabled = true;
m_ppar.filter.low = *getFloatParameter(cpi_filter_low);
m_ppar.filter.high = *getFloatParameter(cpi_filter_high);
m_ppar.tonal_vs_noise.enabled = (*getFloatParameter(cpi_tonalvsnoisebw)) > 0.75;
m_ppar.tonal_vs_noise.bandwidth = *getFloatParameter(cpi_tonalvsnoisebw);
m_ppar.tonal_vs_noise.preserve = *getFloatParameter(cpi_tonalvsnoisepreserve);
m_stretch_source->setOnsetDetection(*getFloatParameter(cpi_onsetdetection));
m_stretch_source->setLoopXFadeLength(*getFloatParameter(cpi_loopxfadelen)); m_stretch_source->setLoopXFadeLength(*getFloatParameter(cpi_loopxfadelen));
double t0 = *getFloatParameter(cpi_soundstart); double t0 = *getFloatParameter(cpi_soundstart);
double t1 = *getFloatParameter(cpi_soundend); double t1 = *getFloatParameter(cpi_soundend);
@ -422,7 +435,7 @@ 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(2, m_max_reclen*getSampleRate()+4096); m_recbuffer.setSize(2, m_max_reclen*getSampleRate()+4096,false,false,true);
m_recbuffer.clear(); m_recbuffer.clear();
m_rec_pos = 0; m_rec_pos = 0;
callGUI(this,[this,lenbufframes](PaulstretchpluginAudioProcessorEditor* ed) callGUI(this,[this,lenbufframes](PaulstretchpluginAudioProcessorEditor* ed)
@ -486,6 +499,25 @@ double PaulstretchpluginAudioProcessor::getPreBufferingPercent()
return m_buffering_source->getPercentReady(); return m_buffering_source->getPercentReady();
} }
void PaulstretchpluginAudioProcessor::timerCallback(int id)
{
if (id == 1)
{
bool capture = getParameter(cpi_capture_enabled);
if (capture == true && m_is_recording == false)
{
setRecordingEnabled(true);
return;
}
if (capture == false && m_is_recording == true)
{
setRecordingEnabled(false);
return;
}
}
}
void PaulstretchpluginAudioProcessor::finishRecording(int lenrecording) void PaulstretchpluginAudioProcessor::finishRecording(int lenrecording)
{ {
m_is_recording = false; m_is_recording = false;

View File

@ -40,8 +40,10 @@ const int cpi_tonalvsnoisebw = 21;
const int cpi_tonalvsnoisepreserve = 22; const int cpi_tonalvsnoisepreserve = 22;
const int cpi_filter_low = 23; const int cpi_filter_low = 23;
const int cpi_filter_high = 24; const int cpi_filter_high = 24;
const int cpi_onsetdetection = 25;
const int cpi_capture_enabled = 26;
class PaulstretchpluginAudioProcessor : public AudioProcessor class PaulstretchpluginAudioProcessor : public AudioProcessor, public MultiTimer
{ {
public: public:
//============================================================================== //==============================================================================
@ -93,6 +95,7 @@ public:
SharedResourcePointer<AudioFormatManager> m_afm; SharedResourcePointer<AudioFormatManager> m_afm;
StretchAudioSource* getStretchSource() { return m_stretch_source.get(); } StretchAudioSource* getStretchSource() { return m_stretch_source.get(); }
double getPreBufferingPercent(); double getPreBufferingPercent();
void timerCallback(int id) override;
private: private: