Clean up generateAntiAliasUserWaveTable function
Also, make it so that we actually call this function when necessary in TripleOscillator.
This commit is contained in:
@@ -104,6 +104,11 @@ public:
|
||||
m_userWave = _wave;
|
||||
}
|
||||
|
||||
inline void setUserAntiAliasWaveTable(std::shared_ptr<const OscillatorConstants::waveform_t> waveform)
|
||||
{
|
||||
m_userAntiAliasWaveTable = waveform;
|
||||
}
|
||||
|
||||
void update(sampleFrame* ab, const fpp_t frames, const ch_cnt_t chnl, bool modulator = false);
|
||||
|
||||
// now follow the wave-shape-routines...
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <QDomElement>
|
||||
|
||||
#include "SampleLoader.h"
|
||||
#include "TripleOscillator.h"
|
||||
#include "AudioEngine.h"
|
||||
#include "AutomatableButton.h"
|
||||
@@ -38,6 +37,7 @@
|
||||
#include "Oscillator.h"
|
||||
#include "PixmapButton.h"
|
||||
#include "SampleBuffer.h"
|
||||
#include "SampleLoader.h"
|
||||
|
||||
#include "embed.h"
|
||||
#include "plugin_export.h"
|
||||
@@ -134,20 +134,13 @@ OscillatorObject::OscillatorObject( Model * _parent, int _idx ) :
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void OscillatorObject::oscUserDefWaveDblClick()
|
||||
{
|
||||
QString af = gui::SampleLoader::openWaveformFile();
|
||||
if (af != "")
|
||||
auto af = gui::SampleLoader::openWaveformFile();
|
||||
if( af != "" )
|
||||
{
|
||||
m_sampleBuffer = gui::SampleLoader::createBufferFromFile(af);
|
||||
|
||||
m_userAntiAliasWaveTable = Oscillator::generateAntiAliasUserWaveTable(m_sampleBuffer.get());
|
||||
// TODO:
|
||||
//m_usrWaveBtn->setToolTip(m_sampleBuffer->audioFile());
|
||||
}
|
||||
@@ -260,7 +253,8 @@ void TripleOscillator::saveSettings( QDomDocument & _doc, QDomElement & _this )
|
||||
"modalgo" + QString::number( i+1 ) );
|
||||
m_osc[i]->m_useWaveTableModel.saveSettings( _doc, _this,
|
||||
"useWaveTable" + QString::number (i+1 ) );
|
||||
_this.setAttribute("userwavefile" + is, m_osc[i]->m_sampleBuffer->audioFile());
|
||||
_this.setAttribute( "userwavefile" + is,
|
||||
m_osc[i]->m_sampleBuffer->audioFile() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,6 +285,7 @@ void TripleOscillator::loadSettings( const QDomElement & _this )
|
||||
if (!_this.attribute("userwavefile" + is).isEmpty())
|
||||
{
|
||||
m_osc[i]->m_sampleBuffer = gui::SampleLoader::createBufferFromFile(_this.attribute("userwavefile" + is));
|
||||
m_osc[i]->m_userAntiAliasWaveTable = Oscillator::generateAntiAliasUserWaveTable(m_osc[i]->m_sampleBuffer.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -358,9 +353,11 @@ void TripleOscillator::playNote( NotePlayHandle * _n,
|
||||
oscs_r[i + 1] );
|
||||
oscs_r[i]->setUseWaveTable(m_osc[i]->m_useWaveTable);
|
||||
}
|
||||
oscs_l[i]->setUserWave(m_osc[i]->m_sampleBuffer);
|
||||
oscs_r[i]->setUserWave(m_osc[i]->m_sampleBuffer);
|
||||
|
||||
oscs_l[i]->setUserWave( m_osc[i]->m_sampleBuffer );
|
||||
oscs_r[i]->setUserWave( m_osc[i]->m_sampleBuffer );
|
||||
oscs_l[i]->setUserAntiAliasWaveTable(m_osc[i]->m_userAntiAliasWaveTable);
|
||||
oscs_r[i]->setUserAntiAliasWaveTable(m_osc[i]->m_userAntiAliasWaveTable);
|
||||
}
|
||||
|
||||
_n->m_pluginData = new oscPtr;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "Instrument.h"
|
||||
#include "InstrumentView.h"
|
||||
#include "AutomatableModel.h"
|
||||
#include "OscillatorConstants.h"
|
||||
#include "SampleBuffer.h"
|
||||
|
||||
namespace lmms
|
||||
@@ -72,6 +73,7 @@ private:
|
||||
IntModel m_modulationAlgoModel;
|
||||
BoolModel m_useWaveTableModel;
|
||||
std::shared_ptr<const SampleBuffer> m_sampleBuffer;
|
||||
std::shared_ptr<const OscillatorConstants::waveform_t> m_userAntiAliasWaveTable;
|
||||
|
||||
float m_volumeLeft;
|
||||
float m_volumeRight;
|
||||
|
||||
@@ -187,9 +187,12 @@ std::unique_ptr<OscillatorConstants::waveform_t> Oscillator::generateAntiAliasUs
|
||||
auto userAntiAliasWaveTable = std::make_unique<OscillatorConstants::waveform_t>();
|
||||
for (int i = 0; i < OscillatorConstants::WAVE_TABLES_PER_WAVEFORM_COUNT; ++i)
|
||||
{
|
||||
for (int i = 0; i < OscillatorConstants::WAVETABLE_LENGTH; ++i)
|
||||
// TODO: This loop seems to be doing the same thing for each iteration of the outer loop,
|
||||
// and could probably be moved out of it
|
||||
for (int j = 0; j < OscillatorConstants::WAVETABLE_LENGTH; ++j)
|
||||
{
|
||||
s_sampleBuffer[i] = Oscillator::userWaveSample(sampleBuffer, (float)i / (float)OscillatorConstants::WAVETABLE_LENGTH);
|
||||
s_sampleBuffer[j] = Oscillator::userWaveSample(
|
||||
sampleBuffer, static_cast<float>(j) / OscillatorConstants::WAVETABLE_LENGTH);
|
||||
}
|
||||
fftwf_execute(s_fftPlan);
|
||||
Oscillator::generateFromFFT(OscillatorConstants::MAX_FREQ / freqFromWaveTableBand(i), (*userAntiAliasWaveTable)[i].data());
|
||||
|
||||
Reference in New Issue
Block a user