Process main volume. Allow importing audio files directly. Tweaks etc
This commit is contained in:
parent
7dcbaedb8f
commit
6487880fb3
@ -119,7 +119,7 @@ public:
|
||||
int getPrebufferThreadPriority() { return m_prebufthreadprior; }
|
||||
private:
|
||||
REALTYPE volume;
|
||||
int m_prebufthreadprior = 5;
|
||||
int m_prebufthreadprior = 4;
|
||||
int get_optimized_updown(int n,bool up);
|
||||
int optimizebufsize(int bufsize);
|
||||
std::string getfftsizestr(int fftsize);
|
||||
|
@ -141,7 +141,7 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer
|
||||
for (auto& e : m_stretchers)
|
||||
e->set_freezing(m_freezing);
|
||||
}
|
||||
double maingain = 0.5; // Decibels::decibelsToGain((double)val_MainVolume.getValue());
|
||||
double maingain = Decibels::decibelsToGain((double)val_MainVolume.getValue());
|
||||
if (m_vol_smoother.getTargetValue() != maingain)
|
||||
m_vol_smoother.setValue(maingain);
|
||||
FloatVectorOperations::disableDenormalisedNumberSupport();
|
||||
|
@ -16,6 +16,9 @@
|
||||
PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor (PaulstretchpluginAudioProcessor& p)
|
||||
: AudioProcessorEditor (&p), processor (p), m_wavecomponent(p.m_afm.get())
|
||||
{
|
||||
addAndMakeVisible(&m_import_button);
|
||||
m_import_button.setButtonText("Import file...");
|
||||
m_import_button.addListener(this);
|
||||
addAndMakeVisible(&m_info_label);
|
||||
addAndMakeVisible(&m_wavecomponent);
|
||||
const auto& pars = processor.getParameters();
|
||||
@ -53,6 +56,20 @@ void PaulstretchpluginAudioProcessorEditor::buttonClicked(Button * but)
|
||||
{
|
||||
processor.setRecordingEnabled(but->getToggleState());
|
||||
}
|
||||
if (but == &m_import_button)
|
||||
{
|
||||
FileChooser myChooser("Please select audio file...",
|
||||
File("C:/MusicAudio/sourcesamples"),
|
||||
"*.wav");
|
||||
if (myChooser.browseForFileToOpen())
|
||||
{
|
||||
processor.setAudioFile(myChooser.getResult());
|
||||
if (processor.getAudioFile() != File())
|
||||
{
|
||||
m_wavecomponent.setAudioFile(processor.getAudioFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
@ -66,6 +83,8 @@ void PaulstretchpluginAudioProcessorEditor::resized()
|
||||
m_rec_enable.setBounds(1, m_parcomps.back()->getBottom()+1, 10, 24);
|
||||
m_rec_enable.changeWidthToFitText();
|
||||
m_info_label.setBounds(m_rec_enable.getRight() + 1, m_rec_enable.getY(), 60, 24);
|
||||
m_import_button.setBounds(m_info_label.getRight() + 1, m_rec_enable.getY(), 60, 24);
|
||||
m_import_button.changeWidthToFitText();
|
||||
m_wavecomponent.setBounds(1, m_info_label.getBottom()+1, getWidth()-2, getHeight()-1-m_info_label.getBottom());
|
||||
}
|
||||
|
||||
@ -206,6 +225,8 @@ void WaveformComponent::setAudioFile(File f)
|
||||
m_waveimage = Image();
|
||||
if (m_thumb != nullptr && f == m_curfile) // reloading same file, might happen that the overview needs to be redone...
|
||||
m_thumbcache.removeThumb(m_thumb->getHashCode());
|
||||
if (m_thumb != nullptr)
|
||||
m_thumb->reset(0, 0.0);
|
||||
m_thumb->setSource(new FileInputSource(f));
|
||||
m_curfile = f;
|
||||
}
|
||||
@ -213,7 +234,7 @@ void WaveformComponent::setAudioFile(File f)
|
||||
{
|
||||
m_thumb->setSource(nullptr);
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
void WaveformComponent::setAudioBuffer(AudioBuffer<float>* buf, int samplerate, int len)
|
||||
|
@ -144,6 +144,7 @@ private:
|
||||
PaulstretchpluginAudioProcessor& processor;
|
||||
std::vector<std::shared_ptr<ParameterComponent>> m_parcomps;
|
||||
ToggleButton m_rec_enable;
|
||||
TextButton m_import_button;
|
||||
Label m_info_label;
|
||||
WaveformComponent m_wavecomponent;
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessorEditor)
|
||||
|
@ -30,6 +30,7 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
|
||||
m_afm = std::make_unique<AudioFormatManager>();
|
||||
m_afm->registerBasicFormats();
|
||||
m_control = std::make_unique<Control>(m_afm.get());
|
||||
m_control->setPreBufferAmount(3);
|
||||
m_control->ppar.pitch_shift.enabled = true;
|
||||
m_control->ppar.freq_shift.enabled = true;
|
||||
m_control->setOnsetDetection(0.0);
|
||||
@ -121,11 +122,7 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl
|
||||
m_control->getStretchAudioSource()->setAudioBufferAsInputSource(&m_recbuffer,
|
||||
getSampleRate(),
|
||||
len);
|
||||
auto ed = dynamic_cast<PaulstretchpluginAudioProcessorEditor*>(getActiveEditor());
|
||||
if (ed)
|
||||
{
|
||||
ed->setAudioBuffer(&m_recbuffer, getSampleRate(), len);
|
||||
}
|
||||
callGUI([this,len](auto ed) { ed->setAudioBuffer(&m_recbuffer, getSampleRate(), len); },false);
|
||||
}
|
||||
if (m_ready_to_play == false)
|
||||
{
|
||||
@ -136,7 +133,7 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl
|
||||
String err;
|
||||
m_control->startplay(false, true,
|
||||
{ *getFloatParameter(5),*getFloatParameter(6) },
|
||||
this->getNumOutputChannels(), err);
|
||||
2, err);
|
||||
m_cur_num_out_chans = getNumOutputChannels();
|
||||
m_ready_to_play = true;
|
||||
}
|
||||
@ -197,6 +194,7 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
|
||||
}
|
||||
return;
|
||||
}
|
||||
m_control->getStretchAudioSource()->val_MainVolume = (float)*getFloatParameter(0);
|
||||
m_control->getStretchAudioSource()->setRate(*getFloatParameter(1));
|
||||
m_control->getStretchAudioSource()->val_XFadeLen = 0.1;
|
||||
//m_control->setFFTSize(*getFloatParameter(2));
|
||||
@ -264,6 +262,17 @@ double PaulstretchpluginAudioProcessor::getRecordingPositionPercent()
|
||||
return 1.0 / m_recbuffer.getNumSamples()*m_rec_pos;
|
||||
}
|
||||
|
||||
String PaulstretchpluginAudioProcessor::setAudioFile(File f)
|
||||
{
|
||||
std::lock_guard<std::mutex> locker(m_mutex);
|
||||
m_control->set_input_file(f, [this,f](String)
|
||||
{
|
||||
|
||||
});
|
||||
m_current_file = f;
|
||||
return String();
|
||||
}
|
||||
|
||||
void PaulstretchpluginAudioProcessor::finishRecording(int lenrecording)
|
||||
{
|
||||
m_is_recording = false;
|
||||
|
@ -62,6 +62,8 @@ public:
|
||||
void setRecordingEnabled(bool b);
|
||||
bool isRecordingEnabled() { return m_is_recording; }
|
||||
double getRecordingPositionPercent();
|
||||
String setAudioFile(File f);
|
||||
File getAudioFile() { return m_current_file; }
|
||||
std::unique_ptr<AudioFormatManager> m_afm;
|
||||
std::unique_ptr<Control> m_control;
|
||||
private:
|
||||
@ -76,6 +78,19 @@ private:
|
||||
bool m_using_memory_buffer = true;
|
||||
int m_cur_num_out_chans = 2;
|
||||
std::mutex m_mutex;
|
||||
File m_current_file;
|
||||
template<typename F>
|
||||
void callGUI(F&& f, bool async)
|
||||
{
|
||||
auto ed = dynamic_cast<PaulstretchpluginAudioProcessorEditor*>(getActiveEditor());
|
||||
if (ed)
|
||||
{
|
||||
if (async == false)
|
||||
f(ed);
|
||||
else
|
||||
MessageManager::callAsync([ed,f]() { f(ed); });
|
||||
}
|
||||
}
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
|
||||
};
|
||||
|
@ -81,11 +81,11 @@
|
||||
<CONFIGURATION name="Debug" winWarningLevel="4" generateManifest="1" winArchitecture="x64"
|
||||
debugInformationFormat="ProgramDatabase" enablePluginBinaryCopyStep="1"
|
||||
linkTimeOptimisation="0" isDebug="1" optimisation="1" targetName="paulstretchplugin"
|
||||
headerPath="Source/PS_Source Source/WDL " vstBinaryLocation="C:\Program Files\VSTPlugins"/>
|
||||
headerPath="Source/PS_Source Source/WDL " vstBinaryLocation="C:\VSTPlugins"/>
|
||||
<CONFIGURATION name="Release" winWarningLevel="4" generateManifest="1" winArchitecture="x64"
|
||||
debugInformationFormat="ProgramDatabase" enablePluginBinaryCopyStep="1"
|
||||
linkTimeOptimisation="1" isDebug="0" optimisation="3" targetName="paulstretchplugin"
|
||||
headerPath="Source/PS_Source Source/WDL " vstBinaryLocation="C:\Program Files\VSTPlugins"/>
|
||||
linkTimeOptimisation="0" isDebug="0" optimisation="3" targetName="paulstretchplugin"
|
||||
headerPath="Source/PS_Source Source/WDL " vstBinaryLocation="C:\VSTPlugins"/>
|
||||
</CONFIGURATIONS>
|
||||
<MODULEPATHS>
|
||||
<MODULEPATH id="juce_core" path="../JUCE/modules"/>
|
||||
|
Loading…
Reference in New Issue
Block a user