diff --git a/Source/CustomLookAndFeel.cpp b/Source/CustomLookAndFeel.cpp index 3d2e8ac..ea5c915 100644 --- a/Source/CustomLookAndFeel.cpp +++ b/Source/CustomLookAndFeel.cpp @@ -41,7 +41,7 @@ CustomLookAndFeel::CustomLookAndFeel() //setColour (ComboBox::backgroundColourId, Colour (0xff161616)); setColour (ComboBox::backgroundColourId, Colour::fromFloatRGBA(0.15, 0.15, 0.15, 0.7)); - setColour (ComboBox::textColourId, Colour (0xffe9e9e9)); + setColour (ComboBox::textColourId, Colour (0xdde9e9e9)); setColour (ComboBox::outlineColourId, Colour::fromFloatRGBA(0.3, 0.3, 0.3, 0.5)); setColour (TextEditor::backgroundColourId, Colour (0xff050505)); diff --git a/Source/PS_Source/BinauralBeats.h b/Source/PS_Source/BinauralBeats.h index 1b0fd48..7e9373b 100644 --- a/Source/PS_Source/BinauralBeats.h +++ b/Source/PS_Source/BinauralBeats.h @@ -95,6 +95,18 @@ struct BinauralBeatsParameters{ FreeEdit free_edit; //void add2XML(XMLwrapper *xml); //void getfromXML(XMLwrapper *xml); + + bool operator == (const BinauralBeatsParameters& other) const noexcept + { + return stereo_mode == other.stereo_mode && + mono == other.mono && + free_edit.get_enabled() == other.free_edit.get_enabled() && + // todo proper equality test for filter + free_edit.get_posy(0) == other.free_edit.get_posy(0) && + free_edit.get_posy(1) == other.free_edit.get_posy(1) + + ; + } }; class BinauralBeats{ diff --git a/Source/PS_Source/FreeEdit.cpp b/Source/PS_Source/FreeEdit.cpp index 1d5b2c5..24295ad 100644 --- a/Source/PS_Source/FreeEdit.cpp +++ b/Source/PS_Source/FreeEdit.cpp @@ -40,6 +40,7 @@ FreeEdit::FreeEdit(){ curve.data=NULL; curve.size=0; + curve.allocsize = 0; }; void FreeEdit::deep_copy_from(const FreeEdit &other){ @@ -55,9 +56,14 @@ void FreeEdit::deep_copy_from(const FreeEdit &other){ }; curve.size=other.curve.size; if (other.curve.data&&other.curve.size){ - curve.data=new REALTYPE[curve.size]; + if (curve.data) delete [] curve.data; + curve.data=new REALTYPE[curve.size]; + curve.allocsize = curve.size; for (int i=0;i curve.allocsize || !curve.data) { + if (curve.data) delete []curve.data; + curve.data = new REALTYPE[size]; + curve.allocsize = size; + } + + curve.size = size; + get_curve(curve.size,curve.data,true); diff --git a/Source/PS_Source/FreeEdit.h b/Source/PS_Source/FreeEdit.h index 06f3250..5edf2e5 100644 --- a/Source/PS_Source/FreeEdit.h +++ b/Source/PS_Source/FreeEdit.h @@ -152,10 +152,10 @@ class FreeEdit{ //void getfromXML(XMLwrapper *xml); //Enabled functions - bool get_enabled(){ + bool get_enabled() const{ return enabled; }; - void set_enabled(bool val){ + void set_enabled(bool val){ enabled=val; }; @@ -164,7 +164,7 @@ class FreeEdit{ }; //manipulation functions - inline bool is_enabled(int n){ + inline bool is_enabled(int n) const{ if ((n<0)||(n>=npos)) return false; return pos[n].enabled; }; @@ -174,11 +174,11 @@ class FreeEdit{ }; - inline REALTYPE get_posx(int n){ + inline REALTYPE get_posx(int n) const{ if ((n<0)||(n>=npos)) return 0.0; return pos[n].x; }; - inline REALTYPE get_posy(int n){ + inline REALTYPE get_posy(int n) const{ if ((n<0)||(n>=npos)) return 0.0; return pos[n].y; }; @@ -198,7 +198,7 @@ class FreeEdit{ }; //interpolation mode - INTERP_MODE get_interp_mode(){ + INTERP_MODE get_interp_mode() const{ return interp_mode; }; void set_interp_mode(INTERP_MODE interp_mode_){ @@ -206,7 +206,7 @@ class FreeEdit{ }; //smooth - REALTYPE get_smooth(){ + REALTYPE get_smooth() const{ return smooth; }; void set_smooth(REALTYPE smooth_){ @@ -230,6 +230,7 @@ class FreeEdit{ struct{ REALTYPE *data; int size; + int allocsize; }curve; private: inline REALTYPE clamp1(REALTYPE m){ diff --git a/Source/PS_Source/StretchSource.cpp b/Source/PS_Source/StretchSource.cpp index 2c60a25..d700886 100644 --- a/Source/PS_Source/StretchSource.cpp +++ b/Source/PS_Source/StretchSource.cpp @@ -34,6 +34,7 @@ StretchAudioSource::StretchAudioSource(int initialnumoutchans, setNumOutChannels(initialnumoutchans); m_xfadetask.buffer.setSize(8, 65536); m_xfadetask.buffer.clear(); + } StretchAudioSource::~StretchAudioSource() @@ -333,7 +334,9 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer { int readsize = 0; double in_pos = (double)m_inputfile->getCurrentPosition() / (double)m_inputfile->info.nsamples; - if (m_firstbuffer) + float in_pos_100 = in_pos*100.0; + + if (m_firstbuffer) { readsize = m_stretchers[0]->get_nsamples_for_fill(); m_firstbuffer = false; @@ -375,6 +378,12 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer for (int i = 0; i < m_stretchers.size(); ++i) m_stretchers[i]->here_is_onset(onset_max); int outbufsize = m_stretchers[0]->get_bufsize(); + + if (m_stretchers.size() > 1) { + m_binaural_beats->process(m_stretchers[0]->out_buf.data(),m_stretchers[1]->out_buf.data(), + outbufsize, in_pos_100); + } + int nskip = m_stretchers[0]->get_skip_nsamples(); if (nskip > 0) m_inputfile->skip(nskip); @@ -578,6 +587,9 @@ void StretchAudioSource::initObjects() fill_container(m_stretchers[i]->out_buf, 0.0f); m_stretchers[i]->m_spectrum_processes = m_specproc_order; } + m_binaural_beats = std::make_unique(m_inputfile->info.samplerate); + m_binaural_beats->pars = m_bbpar; + m_file_inbuf.setSize(m_num_outchans, 3 * inbufsize); } @@ -652,13 +664,18 @@ void StretchAudioSource::setRate(double rate) } } -void StretchAudioSource::setProcessParameters(ProcessParameters * pars) +void StretchAudioSource::setProcessParameters(ProcessParameters * pars, BinauralBeatsParameters * bbpars) { - if (*pars == m_ppar) + if (*pars == m_ppar && (!bbpars || m_bbpar == *bbpars)) return; if (m_cs.tryEnter()) { m_ppar = *pars; + if (bbpars) { + m_bbpar = *bbpars; + m_binaural_beats->pars = m_bbpar; + } + for (int i = 0; i < m_stretchers.size(); ++i) { m_stretchers[i]->set_parameters(pars); diff --git a/Source/PS_Source/StretchSource.h b/Source/PS_Source/StretchSource.h index bc57cfd..69ed379 100644 --- a/Source/PS_Source/StretchSource.h +++ b/Source/PS_Source/StretchSource.h @@ -7,6 +7,7 @@ #include "../JuceLibraryCode/JuceHeader.h" #include "Input/AInputS.h" #include "ProcessedStretch.h" +#include "BinauralBeats.h" #include #include #include "../WDL/resample.h" @@ -49,7 +50,7 @@ public: return m_playrate; } double getOutputSamplerate() const { return m_outsr; } - void setProcessParameters(ProcessParameters* pars); + void setProcessParameters(ProcessParameters* pars, BinauralBeatsParameters * bbpars=0); const ProcessParameters& getProcessParameters(); void setFFTSize(int size, bool force=false); int getFFTSize() { return m_process_fftsize; } @@ -111,7 +112,9 @@ private: LinearSmoothedValue m_vol_smoother; std::unique_ptr m_inputfile; std::vector> m_stretchers; - + + std::unique_ptr m_binaural_beats; + std::function SourceEndedCallback; bool m_firstbuffer = false; bool m_output_has_begun = false; @@ -122,7 +125,8 @@ private: double m_main_volume = 0.0; double m_loopxfadelen = 0.0; ProcessParameters m_ppar; - + BinauralBeatsParameters m_bbpar; + double m_playrate = 1.0; double m_lastplayrate = 0.0; double m_onsetdetection = 0.0; diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 82d5f81..087e38f 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -240,7 +240,9 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau addAndMakeVisible(m_groupviewport.get()); m_stretchgroup = std::make_unique("", -1, &processor, true); - m_stretchgroup->setBackgroundColor(Colour(0xff332244)); + m_stretchgroup->setBackgroundColor(Colour(0xcc332244)); + m_stretchgroup->setSelectedBackgroundColor(Colour(0xff332244)); + m_stretchgroup->allowDisableFade = false; m_stretchgroup->setToggleEnabled( ! *processor.getBoolParameter(cpi_bypass_stretch)); if (*processor.getBoolParameter(cpi_bypass_stretch)) { m_stretchgroup->addParameterComponent(m_parcomps[cpi_dryplayrate].get()); @@ -253,11 +255,30 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau m_stretchgroup->EnabledChangedCallback = [this]() { toggleBool(processor.getBoolParameter(cpi_bypass_stretch)); m_stretchgroup->setToggleEnabled( ! *processor.getBoolParameter(cpi_bypass_stretch)); + m_stretchgroup->updateParameterComponents(); }; addAndMakeVisible(m_stretchgroup.get()); + m_binauralgroup = std::make_unique("", -1, &processor, true); + //m_binauralgroup->setBackgroundColor(Colour(0xff332244)); + m_binauralgroup->setToggleEnabled( *processor.getBoolParameter(cpi_binauralbeats)); + m_binauralgroup->addParameterComponent(m_parcomps[cpi_binauralbeats_mono].get()); + m_binauralgroup->addParameterComponent(m_parcomps[cpi_binauralbeats_mode].get()); + m_binauralgroup->addParameterComponent(m_parcomps[cpi_binauralbeats_freq].get()); + m_parcomps[cpi_binauralbeats_freq]->getSlider()->setNumDecimalPlacesToDisplay(2); + m_binauralgroup->EnabledChangedCallback = [this]() { + toggleBool(processor.getBoolParameter(cpi_binauralbeats)); + m_binauralgroup->setToggleEnabled( *processor.getBoolParameter(cpi_binauralbeats)); + m_binauralgroup->updateParameterComponents(); + }; + + m_groupcontainer->addAndMakeVisible(m_binauralgroup.get()); + removeChildComponent(m_parcomps[cpi_binauralbeats].get()); + + + m_posgroup = std::make_unique("", -1, &processor, false); m_posgroup->addParameterComponent(m_parcomps[cpi_loopxfadelen].get()); m_posgroup->addParameterComponent(m_parcomps[cpi_onsetdetection].get()); @@ -837,6 +858,10 @@ void PaulstretchpluginAudioProcessorEditor::resized() groupsbox.items.add(FlexItem(minw, minh, *m_pargroups[FilterGroup]).withMargin(groupmargin)); gheight += minh + 2*groupmargin; + minh = m_binauralgroup->getMinimumHeight(groupw); + groupsbox.items.add(FlexItem(minw, minh, *m_binauralgroup).withMargin(groupmargin)); + gheight += minh + 2*groupmargin; + minh = m_posgroup->getMinimumHeight(groupw); groupsbox.items.add(FlexItem(minw, minh, *m_posgroup).withMargin(groupmargin)); gheight += minh + 2*groupmargin; @@ -1111,6 +1136,9 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id) m_stretchgroup->setToggleEnabled(!*processor.getBoolParameter(cpi_bypass_stretch)); + m_binauralgroup->setToggleEnabled(*processor.getBoolParameter(cpi_binauralbeats)); + m_binauralgroup->updateParameterComponents(); + if (AudioParameterBool* enablepar = dynamic_cast(processor.getBoolParameter(cpi_pause_enabled))) { m_perfmeter.enabled = !enablepar->get(); } @@ -1195,6 +1223,8 @@ bool PaulstretchpluginAudioProcessorEditor::keyPressed(const KeyPress & press) std::function action; if (press == 'I') action = [this]() { m_import_button.onClick(); ; return true; }; + else if (press == KeyPress::spaceKey) + action = [this]() { toggleBool(processor.getBoolParameter(cpi_pause_enabled)); ; return true; }; return action && action(); } @@ -2110,8 +2140,11 @@ ParameterComponent::ParameterComponent(AudioProcessorParameter * par, bool notif AudioParameterChoice* choicepar = dynamic_cast(par); if (choicepar) { - - } + m_combobox = XenUtils::makeAddAndMakeVisible(*this); + m_combobox->addItemList(choicepar->getAllValueStrings(), 1); + m_combobox->setTitle(choicepar->getName(50)); + m_combobox->addListener(this); + } AudioParameterBool* boolpar = dynamic_cast(par); if (boolpar) { @@ -2174,6 +2207,9 @@ void ParameterComponent::resized() else if (m_drawtogglebut) { m_drawtogglebut->setBounds(1, 0, getWidth() - 1, h); } + else if (m_combobox) { + m_combobox->setBounds(1, 0, getWidth() - 1, h); + } } @@ -2207,6 +2243,15 @@ void ParameterComponent::sliderDragEnded(Slider * slid) *intpar = slid->getValue(); } +void ParameterComponent::comboBoxChanged (ComboBox* comboBoxThatHasChanged) +{ + AudioParameterChoice* choicepar = dynamic_cast(m_par); + if (choicepar) { + choicepar->setValueNotifyingHost(choicepar->convertTo0to1(m_combobox->getSelectedItemIndex())); + } +} + + void ParameterComponent::buttonClicked(Button * but) { AudioParameterBool* boolpar = dynamic_cast(m_par); @@ -2234,7 +2279,13 @@ void ParameterComponent::updateComponent() { m_slider->setValue(*intpar, dontSendNotification); } - AudioParameterBool* boolpar = dynamic_cast(m_par); + AudioParameterChoice* choicepar = dynamic_cast(m_par); + if (choicepar != nullptr && m_combobox != nullptr && m_combobox->getSelectedItemIndex() != choicepar->getIndex()) + { + m_combobox->setSelectedItemIndex(choicepar->getIndex(), dontSendNotification); + } + + AudioParameterBool* boolpar = dynamic_cast(m_par); if (boolpar!=nullptr) { if ( m_togglebut != nullptr) { @@ -2849,6 +2900,7 @@ int ParameterGroupComponent::doLayout(Rectangle bounds) int enablew = m_enableButton ? 40 : 0; int enablemaxh = 34; int minitemw = 260; + int choiceminitemw = 110; int minitemh = 26; int margin = 1; int outsidemargin = 4; @@ -2887,7 +2939,12 @@ int ParameterGroupComponent::doLayout(Rectangle bounds) for (int i = 0; i < m_parcomps.size(); ++i) { - contentbox.items.add(FlexItem(minitemw, minitemh, *m_parcomps[i]).withMargin(margin).withFlex(1)); + if (m_parcomps[i]->getComboBox()) { + contentbox.items.add(FlexItem(choiceminitemw, minitemh, *m_parcomps[i]).withMargin(margin).withFlex(0.1)); + } + else { + contentbox.items.add(FlexItem(minitemw, minitemh, *m_parcomps[i]).withMargin(margin).withFlex(1)); + } } mainbox.items.add(FlexItem(minitemw, minitemh, contentbox).withFlex(1).withMargin(outsidemargin)); @@ -2908,7 +2965,7 @@ void ParameterGroupComponent::resized() void ParameterGroupComponent::paint(Graphics & g) { - if (m_enableButton && groupId >= 0 && m_enableButton->getToggleState()) { + if (m_enableButton && m_enableButton->getToggleState()) { g.setColour(m_selbgcolor); } else { g.setColour(m_bgcolor); @@ -2932,10 +2989,13 @@ void ParameterGroupComponent::updateParameterComponents() } } } + else if (m_enableButton) { + enabled = m_enableButton->getToggleState(); + } for (auto& e : m_parcomps) { e->updateComponent(); - e->setAlpha(enabled ? 1.0f : 0.5f); + e->setAlpha((enabled || !allowDisableFade) ? 1.0f : 0.5f); } repaint(); } diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index fdc51eb..91caa72 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -71,7 +71,7 @@ private: }; class ParameterComponent : public Component, - public Slider::Listener, public Button::Listener +public Slider::Listener, public Button::Listener, public ComboBox::Listener { public: ParameterComponent(AudioProcessorParameter* par, bool notifyOnlyOnRelease, bool useDrawableToggle=false); @@ -80,6 +80,7 @@ public: void sliderDragStarted(Slider* slid) override; void sliderDragEnded(Slider* slid) override; void buttonClicked(Button* but) override; + void comboBoxChanged (ComboBox* comboBoxThatHasChanged); void updateComponent(); void setHighLighted(bool b); int m_group_id = -1; @@ -87,6 +88,7 @@ public: DrawableButton* getDrawableButton() const { return m_drawtogglebut.get(); } ToggleButton* getToggleButton() const { return m_togglebut.get(); } + ComboBox* getComboBox() const { return m_combobox.get(); } private: Label m_label; @@ -117,11 +119,15 @@ public: void setBackgroundColor(Colour col) { m_bgcolor = col; } Colour getBackgroundColor() const { return m_bgcolor; } + void setSelectedBackgroundColor(Colour col) { m_selbgcolor = col; } + Colour getSelectedBBackgroundColor() const { return m_selbgcolor; } + void setToggleEnabled(bool flag){ if (m_enableButton) m_enableButton->setToggleState(flag, dontSendNotification); } bool getToggleEnabled() const { if (m_enableButton) return m_enableButton->getToggleState(); return false; } String name; int groupId = -1; + bool allowDisableFade = true; int getMinimumHeight(int forWidth); @@ -558,6 +564,7 @@ private: std::map > m_pargroups; std::unique_ptr m_posgroup; std::unique_ptr m_stretchgroup; + std::unique_ptr m_binauralgroup; std::unique_ptr m_groupviewport; std::unique_ptr m_groupcontainer; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 051341f..605e41c 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -149,8 +149,8 @@ m_bufferingthread("pspluginprebufferthread"), m_is_stand_alone_offline(is_stand_ m_sm_enab_pars[3] = new AudioParameterBool("enab_specmodule3", "Enable pitch shift", true); m_sm_enab_pars[4] = new AudioParameterBool("enab_specmodule4", "Enable ratios", false); m_sm_enab_pars[5] = new AudioParameterBool("enab_specmodule5", "Enable spread", false); - m_sm_enab_pars[6] = new AudioParameterBool("enab_specmodule6", "Enable filter", true); - m_sm_enab_pars[7] = new AudioParameterBool("enab_specmodule7", "Enable free filter", true); + m_sm_enab_pars[6] = new AudioParameterBool("enab_specmodule6", "Enable filter", false); + m_sm_enab_pars[7] = new AudioParameterBool("enab_specmodule7", "Enable free filter", false); m_sm_enab_pars[8] = new AudioParameterBool("enab_specmodule8", "Enable compressor", false); DBG("making stretch source"); @@ -274,7 +274,17 @@ m_bufferingthread("pspluginprebufferthread"), m_is_stand_alone_offline(is_stand_ addParameter(new AudioParameterFloat("dryplayrate0", "Dry playrate", NormalisableRange(0.1f, 8.0f, dprate_convertFrom0To1Func, dprate_convertTo0To1Func), 1.0f)); // 62 - + + addParameter(new AudioParameterBool("binauralbeats", "BinauralBeats Enable", false)); // 63 + addParameter(new AudioParameterFloat("binauralbeatsmono", "Binaural Beats Power", 0.0, 1.0, 0.5)); // 64 + //addParameter(new AudioParameterFloat("binauralbeatsfreq", "BinauralBeats Freq", 0.0, 1.0, 0.5)); // 65 + addParameter(new AudioParameterFloat("binauralbeatsfreq", "Binaural Beats Freq", + NormalisableRange(0.05f, 50.0f, 0.0f, 0.25f), 4.0f)); // 65 + addParameter(new AudioParameterChoice ("binauralbeatsmode", "BinauralBeats Mode", { "Left-Right", "Right-Left", "Symmetric" }, 0)); // 66 + + m_bbpar.free_edit.extreme_y.set_min(0.05f); + m_bbpar.free_edit.extreme_y.set_max(50.0f); + auto& pars = getParameters(); for (const auto& p : pars) m_reset_pars.push_back(p->getValue()); @@ -586,7 +596,7 @@ void PaulstretchpluginAudioProcessor::startplay(Range playrange, int num } m_stretch_source->setNumOutChannels(numoutchans); m_stretch_source->setFFTSize(m_fft_size_to_use, true); - m_stretch_source->setProcessParameters(&m_ppar); + m_stretch_source->setProcessParameters(&m_ppar, &m_bbpar); m_stretch_source->m_prebuffersize = bufamt; m_last_outpos_pos = 0.0; @@ -604,7 +614,7 @@ void PaulstretchpluginAudioProcessor::setParameters(const std::vector& p } } -void PaulstretchpluginAudioProcessor::updateStretchParametersFromPluginParameters(ProcessParameters & pars) +void PaulstretchpluginAudioProcessor::updateStretchParametersFromPluginParameters(ProcessParameters & pars, BinauralBeatsParameters & bbpar) { pars.pitch_shift.cents = *getFloatParameter(cpi_pitchshift) * 100.0; pars.freq_shift.Hz = *getFloatParameter(cpi_frequencyshift); @@ -642,6 +652,21 @@ void PaulstretchpluginAudioProcessor::updateStretchParametersFromPluginParameter pars.tonal_vs_noise.bandwidth = *getFloatParameter(cpi_tonalvsnoisebw); pars.tonal_vs_noise.preserve = *getFloatParameter(cpi_tonalvsnoisepreserve); + + bbpar.stereo_mode = (BB_STEREO_MODE) getChoiceParameter(cpi_binauralbeats_mode)->getIndex(); + bbpar.mono = *getFloatParameter(cpi_binauralbeats_mono); + //bbpar.free_edit.set_all_values( *getFloatParameter(cpi_binauralbeats_freq)); + auto * bbfreqp = getFloatParameter(cpi_binauralbeats_freq); + float bbfreq = *bbfreqp; + float bbratio = (bbfreq - bbfreqp->getNormalisableRange().getRange().getStart()) / bbfreqp->getNormalisableRange().getRange().getLength(); + if (bbpar.free_edit.get_posy(0) != bbratio) { + bbpar.free_edit.set_posy(0, bbratio); + bbpar.free_edit.set_posy(1, bbratio); + bbpar.free_edit.update_curve(2); + } + //bbpar.mono = 0.5f; + bbpar.free_edit.set_enabled(*getBoolParameter(cpi_binauralbeats)); + } void PaulstretchpluginAudioProcessor::saveCaptureBuffer() @@ -746,7 +771,7 @@ String PaulstretchpluginAudioProcessor::offlineRender(OfflineRenderParams render sc->setPaused(false); processor->setFFTSize(*processor->getFloatParameter(cpi_fftsize), true); - processor->updateStretchParametersFromPluginParameters(processor->m_ppar); + processor->updateStretchParametersFromPluginParameters(processor->m_ppar, processor->m_bbpar); processor->setPlayConfigDetails(2, numoutchans, outsr, blocksize); processor->prepareToPlay(outsr, blocksize); @@ -865,7 +890,7 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl if (m_prebuffering_inited == false) { setFFTSize(*getFloatParameter(cpi_fftsize), true); - m_stretch_source->setProcessParameters(&m_ppar); + m_stretch_source->setProcessParameters(&m_ppar, &m_bbpar); m_stretch_source->setFFTWindowingType(1); String err; startplay({ *getFloatParameter(cpi_soundstart),*getFloatParameter(cpi_soundend) }, @@ -1144,7 +1169,7 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M m_stretch_source->setDryPlayrate(*getFloatParameter(cpi_dryplayrate)); setFFTSize(*getFloatParameter(cpi_fftsize)); - updateStretchParametersFromPluginParameters(m_ppar); + updateStretchParametersFromPluginParameters(m_ppar, m_bbpar); m_stretch_source->setOnsetDetection(*getFloatParameter(cpi_onsetdetection)); m_stretch_source->setLoopXFadeLength(*getFloatParameter(cpi_loopxfadelen)); @@ -1183,7 +1208,7 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M m_ppar.pitch_shift.cents += 100.0*note_offset; } - m_stretch_source->setProcessParameters(&m_ppar); + m_stretch_source->setProcessParameters(&m_ppar, &m_bbpar); AudioSourceChannelInfo aif(buffer); if (isNonRealtime() || m_use_backgroundbuffering == false) { diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 00d572f..48f176c 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -76,6 +76,10 @@ const int cpi_octaves_ratio7 = 59; const int cpi_looping_enabled = 60; const int cpi_rewind = 61; const int cpi_dryplayrate = 62; +const int cpi_binauralbeats = 63; +const int cpi_binauralbeats_mono = 64; +const int cpi_binauralbeats_freq = 65; +const int cpi_binauralbeats_mode = 66; class MyThreadPool : public ThreadPool { @@ -179,6 +183,11 @@ public: { return dynamic_cast(getParameters()[index]); } + AudioParameterChoice* getChoiceParameter(int index) + { + return dynamic_cast(getParameters()[index]); + } + void setLastPluginBounds(juce::Rectangle bounds) { mPluginWindowWidth = bounds.getWidth(); mPluginWindowHeight = bounds.getHeight();} juce::Rectangle getLastPluginBounds() const { return juce::Rectangle(0,0,mPluginWindowWidth, mPluginWindowHeight); } @@ -281,8 +290,9 @@ private: double m_last_in_pos = 0.0; std::vector m_bufamounts{ 4096,8192,16384,32768,65536,262144 }; ProcessParameters m_ppar; - int mPluginWindowWidth = 820; - int mPluginWindowHeight = 710; + BinauralBeatsParameters m_bbpar; + int mPluginWindowWidth = 810; + int mPluginWindowHeight = 745; void setFFTSize(float size, bool force=false); void startplay(Range playrange, int numoutchans, int maxBlockSize, String& err); @@ -297,7 +307,7 @@ private: int m_cur_program = 0; void setParameters(const std::vector& pars); float m_cur_playrangeoffset = 0.0; - void updateStretchParametersFromPluginParameters(ProcessParameters& pars); + void updateStretchParametersFromPluginParameters(ProcessParameters& pars,BinauralBeatsParameters & bbpar); std::array m_sm_enab_pars; bool m_lastrewind = false; AudioFilePreviewComponent* m_previewcomponent = nullptr;