OK, it plays some crappy audio but crashes on quit and all that kind of great stuff
This commit is contained in:
parent
d7ca59b90a
commit
d97975f27a
@ -61,8 +61,17 @@ Control::Control(AudioFormatManager* afm) : m_afm(afm), m_bufferingthread("stret
|
|||||||
|
|
||||||
Control::~Control()
|
Control::~Control()
|
||||||
{
|
{
|
||||||
|
m_bufferingthread.stopThread(1000);
|
||||||
|
}
|
||||||
|
void Control::processAudio(AudioBuffer<float>& buf)
|
||||||
|
{
|
||||||
|
if (m_buffering_source != nullptr)
|
||||||
|
{
|
||||||
|
AudioSourceChannelInfo aif(buf);
|
||||||
|
m_buffering_source->getNextAudioBlock(aif);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void Control::setStretchAmount(double rate)
|
void Control::setStretchAmount(double rate)
|
||||||
@ -274,7 +283,9 @@ void Control::startplay(bool /*bypass*/, bool /*realtime*/, Range<double> playra
|
|||||||
m_bufferingthread, false, bufamt, numoutchans, false);
|
m_bufferingthread, false, bufamt, numoutchans, false);
|
||||||
m_recreate_buffering_source = false;
|
m_recreate_buffering_source = false;
|
||||||
}
|
}
|
||||||
|
if (m_bufferingthread.isThreadRunning() == false)
|
||||||
|
m_bufferingthread.startThread();
|
||||||
|
m_buffering_source->prepareToPlay(1024, 44100.0);
|
||||||
m_stretch_source->setNumOutChannels(numoutchans);
|
m_stretch_source->setNumOutChannels(numoutchans);
|
||||||
m_stretch_source->setFFTSize(m_fft_size_to_use);
|
m_stretch_source->setFFTSize(m_fft_size_to_use);
|
||||||
update_process_parameters();
|
update_process_parameters();
|
||||||
@ -289,7 +300,7 @@ void Control::startplay(bool /*bypass*/, bool /*realtime*/, Range<double> playra
|
|||||||
void Control::stopplay()
|
void Control::stopplay()
|
||||||
{
|
{
|
||||||
//m_adm->removeAudioCallback(&m_test_callback);
|
//m_adm->removeAudioCallback(&m_test_callback);
|
||||||
|
m_bufferingthread.stopThread(1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
void Control::set_seek_pos(REALTYPE x)
|
void Control::set_seek_pos(REALTYPE x)
|
||||||
|
@ -90,6 +90,7 @@ class Control
|
|||||||
public:
|
public:
|
||||||
Control(AudioFormatManager* afm);
|
Control(AudioFormatManager* afm);
|
||||||
~Control();
|
~Control();
|
||||||
|
void processAudio(AudioBuffer<float>& buf);
|
||||||
void startplay(bool bypass, bool realtime, Range<double> playrange, int numoutchans, String& err);
|
void startplay(bool bypass, bool realtime, Range<double> playrange, int numoutchans, String& err);
|
||||||
void stopplay();
|
void stopplay();
|
||||||
void set_seek_pos(REALTYPE x);
|
void set_seek_pos(REALTYPE x);
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
extern std::unique_ptr<PropertiesFile> g_propsfile;
|
|
||||||
|
|
||||||
FFT::FFT(int nsamples_)
|
FFT::FFT(int nsamples_)
|
||||||
{
|
{
|
||||||
nsamples=nsamples_;
|
nsamples=nsamples_;
|
||||||
@ -39,7 +37,7 @@ FFT::FFT(int nsamples_)
|
|||||||
|
|
||||||
|
|
||||||
data.resize(nsamples,true);
|
data.resize(nsamples,true);
|
||||||
bool allow_long_planning = g_propsfile->getBoolValue("fftw_allow_long_planning",false);
|
bool allow_long_planning = false; // g_propsfile->getBoolValue("fftw_allow_long_planning", false);
|
||||||
//double t0 = Time::getMillisecondCounterHiRes();
|
//double t0 = Time::getMillisecondCounterHiRes();
|
||||||
if (allow_long_planning)
|
if (allow_long_planning)
|
||||||
{
|
{
|
||||||
|
@ -7,38 +7,18 @@
|
|||||||
#undef max
|
#undef max
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern std::unique_ptr<PropertiesFile> g_propsfile;
|
|
||||||
|
|
||||||
StretchAudioSource::StretchAudioSource(int initialnumoutchans, AudioFormatManager* afm) : m_afm(afm)
|
StretchAudioSource::StretchAudioSource(int initialnumoutchans, AudioFormatManager* afm) : m_afm(afm)
|
||||||
{
|
{
|
||||||
m_resampler = std::make_unique<WDL_Resampler>();
|
m_resampler = std::make_unique<WDL_Resampler>();
|
||||||
m_resampler_outbuf.resize(1024*1024);
|
m_resampler_outbuf.resize(1024*1024);
|
||||||
m_inputfile = std::make_unique<AInputS>(m_afm);
|
m_inputfile = std::make_unique<AInputS>(m_afm);
|
||||||
m_specproc_order = { 0,1,2,3,4,5,6,7 };
|
m_specproc_order = { 0,1,2,3,4,5,6,7 };
|
||||||
String order = g_propsfile->getValue("spectral_order", "01234567");
|
|
||||||
if (order.isNotEmpty())
|
|
||||||
{
|
|
||||||
std::vector<int> temp;
|
|
||||||
for (int i = 0; i<order.length(); ++i)
|
|
||||||
{
|
|
||||||
int index = order[i] - 48;
|
|
||||||
if (index >= 0 && index<8)
|
|
||||||
{
|
|
||||||
temp.push_back(index);
|
|
||||||
//Logger::writeToLog(temp.back().m_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_specproc_order = temp;
|
|
||||||
}
|
|
||||||
setNumOutChannels(initialnumoutchans);
|
setNumOutChannels(initialnumoutchans);
|
||||||
}
|
}
|
||||||
|
|
||||||
StretchAudioSource::~StretchAudioSource()
|
StretchAudioSource::~StretchAudioSource()
|
||||||
{
|
{
|
||||||
String temp;
|
|
||||||
for (auto& e : m_specproc_order)
|
|
||||||
temp.append(String(e),1);
|
|
||||||
g_propsfile->setValue("spectral_order", temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StretchAudioSource::prepareToPlay(int /*samplesPerBlockExpected*/, double sampleRate)
|
void StretchAudioSource::prepareToPlay(int /*samplesPerBlockExpected*/, double sampleRate)
|
||||||
@ -59,6 +39,7 @@ void StretchAudioSource::prepareToPlay(int /*samplesPerBlockExpected*/, double s
|
|||||||
|
|
||||||
void StretchAudioSource::releaseResources()
|
void StretchAudioSource::releaseResources()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StretchAudioSource::isResampling()
|
bool StretchAudioSource::isResampling()
|
||||||
@ -149,7 +130,7 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer
|
|||||||
for (auto& e : m_stretchers)
|
for (auto& e : m_stretchers)
|
||||||
e->set_freezing(m_freezing);
|
e->set_freezing(m_freezing);
|
||||||
}
|
}
|
||||||
double maingain = Decibels::decibelsToGain((double)val_MainVolume.getValue());
|
double maingain = 0.5; // Decibels::decibelsToGain((double)val_MainVolume.getValue());
|
||||||
if (m_vol_smoother.getTargetValue() != maingain)
|
if (m_vol_smoother.getTargetValue() != maingain)
|
||||||
m_vol_smoother.setValue(maingain);
|
m_vol_smoother.setValue(maingain);
|
||||||
FloatVectorOperations::disableDenormalisedNumberSupport();
|
FloatVectorOperations::disableDenormalisedNumberSupport();
|
||||||
@ -532,10 +513,7 @@ MultiStretchAudioSource::MultiStretchAudioSource(int initialnumoutchans, AudioFo
|
|||||||
|
|
||||||
MultiStretchAudioSource::~MultiStretchAudioSource()
|
MultiStretchAudioSource::~MultiStretchAudioSource()
|
||||||
{
|
{
|
||||||
String temp;
|
|
||||||
for (auto& e : getActiveStretchSource()->getSpectrumProcessOrder())
|
|
||||||
temp.append(String(e), 1);
|
|
||||||
g_propsfile->setValue("spectral_order", temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiStretchAudioSource::prepareToPlay(int samplesPerBlockExpected, double sampleRate)
|
void MultiStretchAudioSource::prepareToPlay(int samplesPerBlockExpected, double sampleRate)
|
||||||
|
@ -28,6 +28,11 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
|
|||||||
m_afm = std::make_unique<AudioFormatManager>();
|
m_afm = std::make_unique<AudioFormatManager>();
|
||||||
m_afm->registerBasicFormats();
|
m_afm->registerBasicFormats();
|
||||||
m_control = std::make_unique<Control>(m_afm.get());
|
m_control = std::make_unique<Control>(m_afm.get());
|
||||||
|
m_control->getStretchAudioSource()->setLoopingEnabled(true);
|
||||||
|
addParameter(new AudioParameterFloat("mainvolume0", "Main volume", -24.0f, 12.0f, -3.0f));
|
||||||
|
addParameter(new AudioParameterFloat("stretchamount0", "Stretch amount", 0.1f, 128.0f, 1.0f));
|
||||||
|
addParameter(new AudioParameterFloat("pitchshift0", "Pitch shift", -24.0f, 24.0f, 0.0f));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor()
|
PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor()
|
||||||
@ -99,14 +104,25 @@ void PaulstretchpluginAudioProcessor::changeProgramName (int index, const String
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
|
void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
|
||||||
{
|
{
|
||||||
// Use this method as the place to do any pre-playback
|
m_ready_to_play = false;
|
||||||
// initialisation that you need..
|
m_control->set_input_file(File("C:/MusicAudio/sourcesamples/sheila.wav"), [this](String cberr)
|
||||||
|
{
|
||||||
|
if (cberr.isEmpty())
|
||||||
|
{
|
||||||
|
m_ready_to_play = true;
|
||||||
|
String err;
|
||||||
|
m_control->update_player_stretch();
|
||||||
|
m_control->update_process_parameters();
|
||||||
|
m_control->startplay(false, true, { 0.0,1.0 }, 2, err);
|
||||||
|
}
|
||||||
|
else m_ready_to_play = false;
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaulstretchpluginAudioProcessor::releaseResources()
|
void PaulstretchpluginAudioProcessor::releaseResources()
|
||||||
{
|
{
|
||||||
// When playback stops, you can use this as an opportunity to free up any
|
m_control->stopplay();
|
||||||
// spare memory, etc.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef JucePlugin_PreferredChannelConfigurations
|
#ifndef JucePlugin_PreferredChannelConfigurations
|
||||||
@ -147,15 +163,16 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
|
|||||||
// this code if your algorithm always overwrites all the output channels.
|
// this code if your algorithm always overwrites all the output channels.
|
||||||
for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
|
for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
|
||||||
buffer.clear (i, 0, buffer.getNumSamples());
|
buffer.clear (i, 0, buffer.getNumSamples());
|
||||||
|
if (m_ready_to_play == false)
|
||||||
// This is the place where you'd normally do the guts of your plugin's
|
return;
|
||||||
// audio processing...
|
auto& params = getParameters();
|
||||||
for (int channel = 0; channel < totalNumInputChannels; ++channel)
|
AudioParameterFloat* par = (AudioParameterFloat*)params[1];
|
||||||
{
|
m_control->getStretchAudioSource()->setRate(*par);
|
||||||
float* channelData = buffer.getWritePointer (channel);
|
par = (AudioParameterFloat*)params[2];
|
||||||
|
m_control->ppar.pitch_shift.enabled = true;
|
||||||
// ..do something to the data...
|
m_control->ppar.pitch_shift.cents = *par * 100.0;
|
||||||
}
|
m_control->update_process_parameters();
|
||||||
|
m_control->processAudio(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
@ -166,7 +183,8 @@ bool PaulstretchpluginAudioProcessor::hasEditor() const
|
|||||||
|
|
||||||
AudioProcessorEditor* PaulstretchpluginAudioProcessor::createEditor()
|
AudioProcessorEditor* PaulstretchpluginAudioProcessor::createEditor()
|
||||||
{
|
{
|
||||||
return new PaulstretchpluginAudioProcessorEditor (*this);
|
return new GenericAudioProcessorEditor(this);
|
||||||
|
//return new PaulstretchpluginAudioProcessorEditor (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
@ -59,6 +59,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
std::unique_ptr<Control> m_control;
|
std::unique_ptr<Control> m_control;
|
||||||
std::unique_ptr<AudioFormatManager> m_afm;
|
std::unique_ptr<AudioFormatManager> m_afm;
|
||||||
|
bool m_ready_to_play = false;
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
|
||||||
};
|
};
|
||||||
|
@ -79,13 +79,13 @@
|
|||||||
<VS2017 targetFolder="Builds/VisualStudio2017" externalLibraries="C:\ProgrammingProjects\gitrepos\fftw-3.3.6\fftw-3.3-libs\x64\Static-Release\libfftwf-3.3.lib">
|
<VS2017 targetFolder="Builds/VisualStudio2017" externalLibraries="C:\ProgrammingProjects\gitrepos\fftw-3.3.6\fftw-3.3-libs\x64\Static-Release\libfftwf-3.3.lib">
|
||||||
<CONFIGURATIONS>
|
<CONFIGURATIONS>
|
||||||
<CONFIGURATION name="Debug" winWarningLevel="4" generateManifest="1" winArchitecture="x64"
|
<CONFIGURATION name="Debug" winWarningLevel="4" generateManifest="1" winArchitecture="x64"
|
||||||
debugInformationFormat="ProgramDatabase" enablePluginBinaryCopyStep="0"
|
debugInformationFormat="ProgramDatabase" enablePluginBinaryCopyStep="1"
|
||||||
linkTimeOptimisation="0" isDebug="1" optimisation="1" targetName="paulstretchplugin"
|
linkTimeOptimisation="0" isDebug="1" optimisation="1" targetName="paulstretchplugin"
|
||||||
headerPath="Source/PS_Source Source/WDL "/>
|
headerPath="Source/PS_Source Source/WDL " vstBinaryLocation="C:\Program Files\VSTPlugins"/>
|
||||||
<CONFIGURATION name="Release" winWarningLevel="4" generateManifest="1" winArchitecture="x64"
|
<CONFIGURATION name="Release" winWarningLevel="4" generateManifest="1" winArchitecture="x64"
|
||||||
debugInformationFormat="ProgramDatabase" enablePluginBinaryCopyStep="0"
|
debugInformationFormat="ProgramDatabase" enablePluginBinaryCopyStep="1"
|
||||||
linkTimeOptimisation="1" isDebug="0" optimisation="3" targetName="paulstretchplugin"
|
linkTimeOptimisation="1" isDebug="0" optimisation="3" targetName="paulstretchplugin"
|
||||||
headerPath="Source/PS_Source Source/WDL "/>
|
headerPath="Source/PS_Source Source/WDL " vstBinaryLocation="C:\Program Files\VSTPlugins"/>
|
||||||
</CONFIGURATIONS>
|
</CONFIGURATIONS>
|
||||||
<MODULEPATHS>
|
<MODULEPATHS>
|
||||||
<MODULEPATH id="juce_core" path="../JUCE/modules"/>
|
<MODULEPATH id="juce_core" path="../JUCE/modules"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user