Browse Source

OK, it plays some crappy audio but crashes on quit and all that kind of great stuff

tags/v100_p5
xenakios 7 years ago
parent
commit
d97975f27a
7 changed files with 61 additions and 54 deletions
  1. +15
    -4
      Source/PS_Source/PaulStretchControl.cpp
  2. +2
    -1
      Source/PS_Source/PaulStretchControl.h
  3. +1
    -3
      Source/PS_Source/Stretch.cpp
  4. +4
    -26
      Source/PS_Source/StretchSource.cpp
  5. +34
    -16
      Source/PluginProcessor.cpp
  6. +1
    -0
      Source/PluginProcessor.h
  7. +4
    -4
      paulstretchplugin.jucer

+ 15
- 4
Source/PS_Source/PaulStretchControl.cpp View File

@@ -61,8 +61,17 @@ Control::Control(AudioFormatManager* afm) : m_afm(afm), m_bufferingthread("stret

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)
@@ -274,7 +283,9 @@ void Control::startplay(bool /*bypass*/, bool /*realtime*/, Range<double> playra
m_bufferingthread, false, bufamt, numoutchans, 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->setFFTSize(m_fft_size_to_use);
update_process_parameters();
@@ -289,7 +300,7 @@ void Control::startplay(bool /*bypass*/, bool /*realtime*/, Range<double> playra
void Control::stopplay()
{
//m_adm->removeAudioCallback(&m_test_callback);
m_bufferingthread.stopThread(1000);
};

void Control::set_seek_pos(REALTYPE x)


+ 2
- 1
Source/PS_Source/PaulStretchControl.h View File

@@ -90,7 +90,8 @@ class Control
public:
Control(AudioFormatManager* afm);
~Control();
void startplay(bool bypass, bool realtime, Range<double> playrange, int numoutchans, String& err);
void processAudio(AudioBuffer<float>& buf);
void startplay(bool bypass, bool realtime, Range<double> playrange, int numoutchans, String& err);
void stopplay();
void set_seek_pos(REALTYPE x);
REALTYPE get_seek_pos();


+ 1
- 3
Source/PS_Source/Stretch.cpp View File

@@ -20,8 +20,6 @@
#include <stdlib.h>
#include <math.h>

extern std::unique_ptr<PropertiesFile> g_propsfile;

FFT::FFT(int nsamples_)
{
nsamples=nsamples_;
@@ -39,7 +37,7 @@ FFT::FFT(int nsamples_)


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();
if (allow_long_planning)
{


+ 4
- 26
Source/PS_Source/StretchSource.cpp View File

@@ -7,38 +7,18 @@
#undef max
#endif

extern std::unique_ptr<PropertiesFile> g_propsfile;

StretchAudioSource::StretchAudioSource(int initialnumoutchans, AudioFormatManager* afm) : m_afm(afm)
{
m_resampler = std::make_unique<WDL_Resampler>();
m_resampler_outbuf.resize(1024*1024);
m_inputfile = std::make_unique<AInputS>(m_afm);
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);
}

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)
@@ -59,6 +39,7 @@ void StretchAudioSource::prepareToPlay(int /*samplesPerBlockExpected*/, double s

void StretchAudioSource::releaseResources()
{
}

bool StretchAudioSource::isResampling()
@@ -149,7 +130,7 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer
for (auto& e : m_stretchers)
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)
m_vol_smoother.setValue(maingain);
FloatVectorOperations::disableDenormalisedNumberSupport();
@@ -532,10 +513,7 @@ MultiStretchAudioSource::MultiStretchAudioSource(int initialnumoutchans, AudioFo

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)


+ 34
- 16
Source/PluginProcessor.cpp View File

@@ -28,6 +28,11 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
m_afm = std::make_unique<AudioFormatManager>();
m_afm->registerBasicFormats();
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()
@@ -97,16 +102,27 @@ void PaulstretchpluginAudioProcessor::changeProgramName (int index, const String
}

//==============================================================================
void PaulstretchpluginAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
// Use this method as the place to do any pre-playback
// initialisation that you need..
void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
{
m_ready_to_play = false;
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()
{
// When playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
m_control->stopplay();
}

#ifndef JucePlugin_PreferredChannelConfigurations
@@ -147,15 +163,16 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
// this code if your algorithm always overwrites all the output channels.
for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());

// This is the place where you'd normally do the guts of your plugin's
// audio processing...
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
float* channelData = buffer.getWritePointer (channel);

// ..do something to the data...
}
if (m_ready_to_play == false)
return;
auto& params = getParameters();
AudioParameterFloat* par = (AudioParameterFloat*)params[1];
m_control->getStretchAudioSource()->setRate(*par);
par = (AudioParameterFloat*)params[2];
m_control->ppar.pitch_shift.enabled = true;
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()
{
return new PaulstretchpluginAudioProcessorEditor (*this);
return new GenericAudioProcessorEditor(this);
//return new PaulstretchpluginAudioProcessorEditor (*this);
}

//==============================================================================


+ 1
- 0
Source/PluginProcessor.h View File

@@ -59,6 +59,7 @@ public:
private:
std::unique_ptr<Control> m_control;
std::unique_ptr<AudioFormatManager> m_afm;
bool m_ready_to_play = false;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
};

+ 4
- 4
paulstretchplugin.jucer View File

@@ -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">
<CONFIGURATIONS>
<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"
headerPath="Source/PS_Source&#10;Source/WDL&#10;"/>
headerPath="Source/PS_Source&#10;Source/WDL&#10;" vstBinaryLocation="C:\Program Files\VSTPlugins"/>
<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"
headerPath="Source/PS_Source&#10;Source/WDL&#10;"/>
headerPath="Source/PS_Source&#10;Source/WDL&#10;" vstBinaryLocation="C:\Program Files\VSTPlugins"/>
</CONFIGURATIONS>
<MODULEPATHS>
<MODULEPATH id="juce_core" path="../JUCE/modules"/>


Loading…
Cancel
Save