add binaural beats to processing and UI
This commit is contained in:
parent
313de42d6c
commit
57b62141f5
@ -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));
|
||||
|
@ -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{
|
||||
|
@ -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.size;i++) curve.data[i]=other.curve.data[i];
|
||||
}else curve.data=NULL;
|
||||
} else {
|
||||
if (curve.data) delete [] curve.data;
|
||||
curve.data=NULL;
|
||||
}
|
||||
extreme_x=other.extreme_x;
|
||||
extreme_y=other.extreme_y;
|
||||
};
|
||||
@ -140,10 +146,16 @@ void FreeEdit::get_curve(int datasize,REALTYPE *data,bool real_values){
|
||||
};
|
||||
|
||||
void FreeEdit::update_curve(int size){
|
||||
if (curve.data) delete []curve.data;
|
||||
if (size<2) size=2;
|
||||
curve.size=size;
|
||||
curve.data=new REALTYPE[size];
|
||||
|
||||
if (size > 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);
|
||||
|
||||
|
@ -152,7 +152,7 @@ class FreeEdit{
|
||||
//void getfromXML(XMLwrapper *xml);
|
||||
|
||||
//Enabled functions
|
||||
bool get_enabled(){
|
||||
bool get_enabled() const{
|
||||
return enabled;
|
||||
};
|
||||
void set_enabled(bool 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){
|
||||
|
@ -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<BinauralBeats>(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);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "../JuceLibraryCode/JuceHeader.h"
|
||||
#include "Input/AInputS.h"
|
||||
#include "ProcessedStretch.h"
|
||||
#include "BinauralBeats.h"
|
||||
#include <mutex>
|
||||
#include <array>
|
||||
#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; }
|
||||
@ -112,6 +113,8 @@ private:
|
||||
std::unique_ptr<AInputS> m_inputfile;
|
||||
std::vector<std::shared_ptr<ProcessedStretch>> m_stretchers;
|
||||
|
||||
std::unique_ptr<BinauralBeats> m_binaural_beats;
|
||||
|
||||
std::function<void(StretchAudioSource*)> SourceEndedCallback;
|
||||
bool m_firstbuffer = false;
|
||||
bool m_output_has_begun = false;
|
||||
@ -122,6 +125,7 @@ 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;
|
||||
|
@ -240,7 +240,9 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau
|
||||
addAndMakeVisible(m_groupviewport.get());
|
||||
|
||||
m_stretchgroup = std::make_unique<ParameterGroupComponent>("", -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<ParameterGroupComponent>("", -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<ParameterGroupComponent>("", -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<AudioParameterBool*>(processor.getBoolParameter(cpi_pause_enabled))) {
|
||||
m_perfmeter.enabled = !enablepar->get();
|
||||
}
|
||||
@ -1195,6 +1223,8 @@ bool PaulstretchpluginAudioProcessorEditor::keyPressed(const KeyPress & press)
|
||||
std::function<bool(void)> 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<AudioParameterChoice*>(par);
|
||||
if (choicepar)
|
||||
{
|
||||
|
||||
}
|
||||
m_combobox = XenUtils::makeAddAndMakeVisible<ComboBox>(*this);
|
||||
m_combobox->addItemList(choicepar->getAllValueStrings(), 1);
|
||||
m_combobox->setTitle(choicepar->getName(50));
|
||||
m_combobox->addListener(this);
|
||||
}
|
||||
AudioParameterBool* boolpar = dynamic_cast<AudioParameterBool*>(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<AudioParameterChoice*>(m_par);
|
||||
if (choicepar) {
|
||||
choicepar->setValueNotifyingHost(choicepar->convertTo0to1(m_combobox->getSelectedItemIndex()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ParameterComponent::buttonClicked(Button * but)
|
||||
{
|
||||
AudioParameterBool* boolpar = dynamic_cast<AudioParameterBool*>(m_par);
|
||||
@ -2234,7 +2279,13 @@ void ParameterComponent::updateComponent()
|
||||
{
|
||||
m_slider->setValue(*intpar, dontSendNotification);
|
||||
}
|
||||
AudioParameterBool* boolpar = dynamic_cast<AudioParameterBool*>(m_par);
|
||||
AudioParameterChoice* choicepar = dynamic_cast<AudioParameterChoice*>(m_par);
|
||||
if (choicepar != nullptr && m_combobox != nullptr && m_combobox->getSelectedItemIndex() != choicepar->getIndex())
|
||||
{
|
||||
m_combobox->setSelectedItemIndex(choicepar->getIndex(), dontSendNotification);
|
||||
}
|
||||
|
||||
AudioParameterBool* boolpar = dynamic_cast<AudioParameterBool*>(m_par);
|
||||
if (boolpar!=nullptr) {
|
||||
if ( m_togglebut != nullptr)
|
||||
{
|
||||
@ -2849,6 +2900,7 @@ int ParameterGroupComponent::doLayout(Rectangle<int> 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<int> 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();
|
||||
}
|
||||
|
@ -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<int, std::unique_ptr<ParameterGroupComponent> > m_pargroups;
|
||||
std::unique_ptr<ParameterGroupComponent> m_posgroup;
|
||||
std::unique_ptr<ParameterGroupComponent> m_stretchgroup;
|
||||
std::unique_ptr<ParameterGroupComponent> m_binauralgroup;
|
||||
|
||||
std::unique_ptr<Viewport> m_groupviewport;
|
||||
std::unique_ptr<Component> m_groupcontainer;
|
||||
|
@ -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");
|
||||
@ -275,6 +275,16 @@ m_bufferingthread("pspluginprebufferthread"), m_is_stand_alone_offline(is_stand_
|
||||
NormalisableRange<float>(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<float>(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<double> 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<double>& 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)
|
||||
{
|
||||
|
@ -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<AudioParameterBool*>(getParameters()[index]);
|
||||
}
|
||||
AudioParameterChoice* getChoiceParameter(int index)
|
||||
{
|
||||
return dynamic_cast<AudioParameterChoice*>(getParameters()[index]);
|
||||
}
|
||||
|
||||
void setLastPluginBounds(juce::Rectangle<int> bounds) { mPluginWindowWidth = bounds.getWidth(); mPluginWindowHeight = bounds.getHeight();}
|
||||
juce::Rectangle<int> getLastPluginBounds() const { return juce::Rectangle<int>(0,0,mPluginWindowWidth, mPluginWindowHeight); }
|
||||
|
||||
@ -281,8 +290,9 @@ private:
|
||||
double m_last_in_pos = 0.0;
|
||||
std::vector<int> 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<double> playrange, int numoutchans, int maxBlockSize, String& err);
|
||||
@ -297,7 +307,7 @@ private:
|
||||
int m_cur_program = 0;
|
||||
void setParameters(const std::vector<double>& pars);
|
||||
float m_cur_playrangeoffset = 0.0;
|
||||
void updateStretchParametersFromPluginParameters(ProcessParameters& pars);
|
||||
void updateStretchParametersFromPluginParameters(ProcessParameters& pars,BinauralBeatsParameters & bbpar);
|
||||
std::array<AudioParameterBool*, 9> m_sm_enab_pars;
|
||||
bool m_lastrewind = false;
|
||||
AudioFilePreviewComponent* m_previewcomponent = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user