| @@ -22,7 +22,6 @@ | |||||
| #include "../JuceLibraryCode/JuceHeader.h" | #include "../JuceLibraryCode/JuceHeader.h" | ||||
| //#include <audiofile.h> | |||||
| #include "InputS.h" | #include "InputS.h" | ||||
| inline double ramp(int64_t pos, int64_t totallen, int64_t rampinlen, int64_t rampoutlen) | inline double ramp(int64_t pos, int64_t totallen, int64_t rampinlen, int64_t rampoutlen) | ||||
| @@ -51,7 +50,8 @@ public: | |||||
| void setAudioBuffer(AudioBuffer<float>* buf, int samplerate, int len) | void setAudioBuffer(AudioBuffer<float>* buf, int samplerate, int len) | ||||
| { | { | ||||
| m_afreader = nullptr; | |||||
| std::lock_guard<std::mutex> locker(m_mutex); | |||||
| m_afreader = nullptr; | |||||
| m_using_memory_buffer = true; | m_using_memory_buffer = true; | ||||
| m_readbuf = *buf; | m_readbuf = *buf; | ||||
| info.nchannels = buf->getNumChannels(); | info.nchannels = buf->getNumChannels(); | ||||
| @@ -70,7 +70,8 @@ public: | |||||
| AudioFormatReader* reader = m_manager->createReaderFor(file); | AudioFormatReader* reader = m_manager->createReaderFor(file); | ||||
| if (reader) | if (reader) | ||||
| { | { | ||||
| m_using_memory_buffer = false; | |||||
| std::lock_guard<std::mutex> locker(m_mutex); | |||||
| m_using_memory_buffer = false; | |||||
| m_afreader = std::unique_ptr<AudioFormatReader>(reader); | m_afreader = std::unique_ptr<AudioFormatReader>(reader); | ||||
| m_currentsample = 0; | m_currentsample = 0; | ||||
| info.samplerate = (int)m_afreader->sampleRate; | info.samplerate = (int)m_afreader->sampleRate; | ||||
| @@ -96,8 +97,12 @@ public: | |||||
| } | } | ||||
| int readNextBlock(AudioBuffer<float>& abuf, int nsmps, int numchans) override | int readNextBlock(AudioBuffer<float>& abuf, int nsmps, int numchans) override | ||||
| { | { | ||||
| if (m_afreader == nullptr && m_using_memory_buffer == false) | |||||
| return 0; | |||||
| std::lock_guard<std::mutex> locker(m_mutex); | |||||
| if (m_afreader == nullptr && m_using_memory_buffer == false) | |||||
| { | |||||
| jassert(false); | |||||
| return 0; | |||||
| } | |||||
| int inchans = 0; | int inchans = 0; | ||||
| if (m_afreader) | if (m_afreader) | ||||
| inchans = m_afreader->numChannels; | inchans = m_afreader->numChannels; | ||||
| @@ -292,4 +297,5 @@ private: | |||||
| int64_t m_loopcount = 0; | int64_t m_loopcount = 0; | ||||
| bool m_using_memory_buffer = false; | bool m_using_memory_buffer = false; | ||||
| AudioFormatManager* m_manager = nullptr; | AudioFormatManager* m_manager = nullptr; | ||||
| std::mutex m_mutex; | |||||
| }; | }; | ||||
| @@ -81,7 +81,7 @@ public: | |||||
| } | } | ||||
| protected: | protected: | ||||
| int64_t m_currentsample = 0; | |||||
| volatile int64_t m_currentsample = 0; | |||||
| int m_silenceoutputted = 0; | int m_silenceoutputted = 0; | ||||
| bool m_loop_enabled = false; | bool m_loop_enabled = false; | ||||
| Range<double> m_activerange{ 0.0,1.0 }; | Range<double> m_activerange{ 0.0,1.0 }; | ||||
| @@ -65,7 +65,9 @@ Control::~Control() | |||||
| } | } | ||||
| void Control::processAudio(AudioBuffer<float>& buf) | void Control::processAudio(AudioBuffer<float>& buf) | ||||
| { | { | ||||
| if (m_buffering_source != nullptr) | |||||
| jassert(m_buffering_source!=nullptr); | |||||
| jassert(m_bufferingthread.isThreadRunning()); | |||||
| if (m_buffering_source != nullptr) | |||||
| { | { | ||||
| AudioSourceChannelInfo aif(buf); | AudioSourceChannelInfo aif(buf); | ||||
| m_buffering_source->getNextAudioBlock(aif); | m_buffering_source->getNextAudioBlock(aif); | ||||
| @@ -134,13 +134,15 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer | |||||
| if (m_stretchoutringbuf.available() > 0) | if (m_stretchoutringbuf.available() > 0) | ||||
| m_output_has_begun = true; | m_output_has_begun = true; | ||||
| bool freezing = m_freezing; | bool freezing = m_freezing; | ||||
| if (m_stretchers[0]->isFreezing() != freezing) | |||||
| /* | |||||
| if (m_stretchers[0]->isFreezing() != freezing) | |||||
| { | { | ||||
| if (freezing == true && m_inputfile!=nullptr) | if (freezing == true && m_inputfile!=nullptr) | ||||
| m_freeze_pos = 1.0/m_inputfile->info.nsamples*m_inputfile->getCurrentPosition(); | m_freeze_pos = 1.0/m_inputfile->info.nsamples*m_inputfile->getCurrentPosition(); | ||||
| 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 = 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); | ||||
| @@ -632,7 +632,7 @@ int WDL_Resampler::ResampleOut(WDL_ResampleSample *out, int nsamples_in, int nsa | |||||
| m_samples_in_rsinbuf -= isrcpos; | m_samples_in_rsinbuf -= isrcpos; | ||||
| if (m_samples_in_rsinbuf <= 0) m_samples_in_rsinbuf=0; | if (m_samples_in_rsinbuf <= 0) m_samples_in_rsinbuf=0; | ||||
| else | else | ||||
| memcpy(localin, localin + isrcpos*nch,m_samples_in_rsinbuf*sizeof(WDL_ResampleSample)*nch); | |||||
| memmove(localin, localin + isrcpos*nch,m_samples_in_rsinbuf*sizeof(WDL_ResampleSample)*nch); | |||||
| return ret; | return ret; | ||||
| @@ -5,7 +5,7 @@ | |||||
| version="1.0.0" bundleIdentifier="com.yourcompany.paulstretchplugin" | version="1.0.0" bundleIdentifier="com.yourcompany.paulstretchplugin" | ||||
| includeBinaryInAppConfig="1" cppLanguageStandard="latest" companyCopyright="" | includeBinaryInAppConfig="1" cppLanguageStandard="latest" companyCopyright="" | ||||
| buildVST="1" buildVST3="0" buildAU="0" buildAUv3="0" buildRTAS="0" | buildVST="1" buildVST3="0" buildAU="0" buildAUv3="0" buildRTAS="0" | ||||
| buildAAX="0" buildStandalone="0" enableIAA="0" pluginName="paulstretchplugin" | |||||
| buildAAX="0" buildStandalone="1" enableIAA="0" pluginName="paulstretchplugin" | |||||
| pluginDesc="paulstretchplugin" pluginManufacturer="Xenakios" | pluginDesc="paulstretchplugin" pluginManufacturer="Xenakios" | ||||
| pluginManufacturerCode="XenS" pluginCode="Fn1r" pluginChannelConfigs="{2,2},{4,4}, {8,8}" | pluginManufacturerCode="XenS" pluginCode="Fn1r" pluginChannelConfigs="{2,2},{4,4}, {8,8}" | ||||
| pluginIsSynth="0" pluginWantsMidiIn="0" pluginProducesMidiOut="0" | pluginIsSynth="0" pluginWantsMidiIn="0" pluginProducesMidiOut="0" | ||||