Integrate changes into Patman

This commit is contained in:
sakertooth
2023-08-27 20:33:42 -04:00
parent 6bf4483b95
commit 25bb7abbb7
2 changed files with 13 additions and 22 deletions

View File

@@ -153,8 +153,8 @@ void PatmanInstrument::playNote( NotePlayHandle * _n,
float play_freq = hdata->tuned ? _n->frequency() :
hdata->sample->frequency();
if( hdata->sample->play( _working_buffer + offset, hdata->state, frames,
play_freq, m_loopedModel.value() ? SampleBuffer::LoopMode::On : SampleBuffer::LoopMode::Off ) )
if (hdata->sample->play(_working_buffer + offset, hdata->state, frames,
play_freq, m_loopedModel.value() ? Sample::Loop::On : Sample::Loop::Off))
{
applyRelease( _working_buffer, _n );
instrumentTrack()->processAudioBuffer( _working_buffer,
@@ -172,7 +172,6 @@ void PatmanInstrument::playNote( NotePlayHandle * _n,
void PatmanInstrument::deleteNotePluginData( NotePlayHandle * _n )
{
auto hdata = (handle_data*)_n->m_pluginData;
sharedObject::unref( hdata->sample );
delete hdata->state;
delete hdata;
}
@@ -358,9 +357,8 @@ PatmanInstrument::LoadError PatmanInstrument::loadPatch(
}
}
auto psample = new SampleBuffer(data, frames);
psample->setFrequency( root_freq / 1000.0f );
psample->setSampleRate( sample_rate );
auto psample = std::make_shared<Sample>(data, frames, sample_rate);
psample->setFrequency(root_freq / 1000.0f);
if( modes & MODES_LOOPING )
{
@@ -368,7 +366,7 @@ PatmanInstrument::LoadError PatmanInstrument::loadPatch(
psample->setLoopEndFrame( loop_end );
}
m_patchSamples.push_back( psample );
m_patchSamples.push_back(psample);
delete[] wave_samples;
delete[] data;
@@ -384,7 +382,6 @@ void PatmanInstrument::unloadCurrentPatch()
{
while( !m_patchSamples.empty() )
{
sharedObject::unref( m_patchSamples.back() );
m_patchSamples.pop_back();
}
}
@@ -397,7 +394,7 @@ void PatmanInstrument::selectSample( NotePlayHandle * _n )
const float freq = _n->frequency();
float min_dist = HUGE_VALF;
SampleBuffer* sample = nullptr;
std::shared_ptr<Sample> sample = nullptr;
for (const auto& patchSample : m_patchSamples)
{
@@ -414,15 +411,8 @@ void PatmanInstrument::selectSample( NotePlayHandle * _n )
auto hdata = new handle_data;
hdata->tuned = m_tunedModel.value();
if( sample )
{
hdata->sample = sharedObject::ref( sample );
}
else
{
hdata->sample = new SampleBuffer( nullptr, 0 );
}
hdata->state = new SampleBuffer::handleState( _n->hasDetuningInfo() );
hdata->sample = sample ? sample : std::make_shared<Sample>();
hdata->state = new Sample::PlaybackState(_n->hasDetuningInfo());
_n->m_pluginData = hdata;
}

View File

@@ -28,7 +28,8 @@
#include "Instrument.h"
#include "InstrumentView.h"
#include "SampleBuffer.h"
#include "Sample.h"
#include "SampleBuffer2.h"
#include "AutomatableModel.h"
#include "MemoryManager.h"
@@ -87,13 +88,13 @@ private:
struct handle_data
{
MM_OPERATORS
SampleBuffer::handleState* state;
Sample::PlaybackState* state;
bool tuned;
SampleBuffer* sample;
std::shared_ptr<Sample> sample;
};
QString m_patchFile;
QVector<SampleBuffer *> m_patchSamples;
QVector<std::shared_ptr<Sample>> m_patchSamples;
BoolModel m_loopedModel;
BoolModel m_tunedModel;