Integrate changes into Oscillator

This commit is contained in:
sakertooth
2023-08-27 19:34:16 -04:00
parent e01b1fca45
commit 7245b1abc4
12 changed files with 67 additions and 47 deletions

View File

@@ -26,6 +26,7 @@
#include <QDomElement>
#include "SampleLoader.h"
#include "TripleOscillator.h"
#include "AudioEngine.h"
#include "AutomatableButton.h"
@@ -92,7 +93,7 @@ OscillatorObject::OscillatorObject( Model * _parent, int _idx ) :
tr( "Modulation type %1" ).arg( _idx+1 ) ),
m_useWaveTableModel(true),
m_sampleBuffer( new SampleBuffer ),
m_sampleBuffer( new SampleBuffer2 ),
m_volumeLeft( 0.0f ),
m_volumeRight( 0.0f ),
m_detuningLeft( 0.0f ),
@@ -136,17 +137,17 @@ OscillatorObject::OscillatorObject( Model * _parent, int _idx ) :
OscillatorObject::~OscillatorObject()
{
sharedObject::unref( m_sampleBuffer );
}
void OscillatorObject::oscUserDefWaveDblClick()
{
QString af = m_sampleBuffer->openAndSetWaveformFile();
QString af = gui::SampleLoader::openWaveformFile();
auto buffer = gui::SampleLoader::createBufferFromFile(af);
// TODO C++20: Deprecated, use std::atomic<std::shared_ptr> instead
std::atomic_store(&m_sampleBuffer, std::shared_ptr<const SampleBuffer2>(std::move(buffer)));
if( af != "" )
{
// TODO:
@@ -289,8 +290,10 @@ void TripleOscillator::loadSettings( const QDomElement & _this )
"modalgo" + QString::number( i+1 ) );
m_osc[i]->m_useWaveTableModel.loadSettings( _this,
"useWaveTable" + QString::number (i+1 ) );
m_osc[i]->m_sampleBuffer->setAudioFile( _this.attribute(
"userwavefile" + is ) );
auto buffer = gui::SampleLoader::createBufferFromFile(_this.attribute("userwavefile" + is));
// TODO C++20: Deprecated, use std::atomic<std::shared_ptr> instead
std::atomic_store(&m_osc[i]->m_sampleBuffer, std::shared_ptr<const SampleBuffer2>(std::move(buffer)));
}
}

View File

@@ -29,6 +29,7 @@
#include "Instrument.h"
#include "InstrumentView.h"
#include "AutomatableModel.h"
#include "SampleBuffer2.h"
namespace lmms
{
@@ -57,9 +58,6 @@ class OscillatorObject : public Model
Q_OBJECT
public:
OscillatorObject( Model * _parent, int _idx );
~OscillatorObject() override;
private:
FloatModel m_volumeModel;
FloatModel m_panModel;
@@ -71,7 +69,7 @@ private:
IntModel m_waveShapeModel;
IntModel m_modulationAlgoModel;
BoolModel m_useWaveTableModel;
SampleBuffer* m_sampleBuffer;
std::shared_ptr<const SampleBuffer2> m_sampleBuffer;
float m_volumeLeft;
float m_volumeRight;