Integrate changes into Oscillator
This commit is contained in:
@@ -86,7 +86,7 @@ protected:
|
||||
sample_t (*m_sampleFunction)( const float );
|
||||
|
||||
private:
|
||||
SampleBuffer * m_userDefSampleBuffer;
|
||||
std::shared_ptr<const SampleBuffer2> m_userDefSampleBuffer;
|
||||
|
||||
protected slots:
|
||||
void updatePhase();
|
||||
|
||||
@@ -29,13 +29,14 @@
|
||||
#include <cassert>
|
||||
#include <fftw3.h>
|
||||
#include <cstdlib>
|
||||
#include "interpolation.h"
|
||||
|
||||
#include "Engine.h"
|
||||
#include "lmms_constants.h"
|
||||
#include "lmmsconfig.h"
|
||||
#include "AudioEngine.h"
|
||||
#include "OscillatorConstants.h"
|
||||
#include "SampleBuffer.h"
|
||||
#include "SampleBuffer2.h"
|
||||
|
||||
namespace lmms
|
||||
{
|
||||
@@ -46,7 +47,6 @@ class IntModel;
|
||||
|
||||
class LMMS_EXPORT Oscillator
|
||||
{
|
||||
MM_OPERATORS
|
||||
public:
|
||||
enum class WaveShape
|
||||
{
|
||||
@@ -91,14 +91,14 @@ public:
|
||||
|
||||
static void waveTableInit();
|
||||
static void destroyFFTPlans();
|
||||
static void generateAntiAliasUserWaveTable(SampleBuffer* sampleBuffer);
|
||||
static std::unique_ptr<OscillatorConstants::waveform_t> generateAntiAliasUserWaveTable(const SampleBuffer2 *sampleBuffer);
|
||||
|
||||
inline void setUseWaveTable(bool n)
|
||||
{
|
||||
m_useWaveTable = n;
|
||||
}
|
||||
|
||||
inline void setUserWave( const SampleBuffer * _wave )
|
||||
inline void setUserWave(std::shared_ptr<const SampleBuffer2> _wave)
|
||||
{
|
||||
m_userWave = _wave;
|
||||
}
|
||||
@@ -164,9 +164,18 @@ public:
|
||||
return 1.0f - fast_rand() * 2.0f / FAST_RAND_MAX;
|
||||
}
|
||||
|
||||
inline sample_t userWaveSample( const float _sample ) const
|
||||
static inline sample_t userWaveSample(const SampleBuffer2* buffer, const float sample)
|
||||
{
|
||||
return m_userWave->userWaveSample( _sample );
|
||||
if (buffer == nullptr || buffer->size() == 0) { return 0; }
|
||||
const auto frames = buffer->size();
|
||||
const auto frame = sample * frames;
|
||||
auto f1 = static_cast<f_cnt_t>(frame) % frames;
|
||||
if (f1 < 0)
|
||||
{
|
||||
f1 += frames;
|
||||
}
|
||||
|
||||
return linearInterpolate(buffer->data()[f1][0], buffer->data()[(f1 + 1) % frames][0], fraction(frame));
|
||||
}
|
||||
|
||||
struct wtSampleControl {
|
||||
@@ -203,7 +212,7 @@ public:
|
||||
table[control.band][control.f2], fraction(control.frame));
|
||||
}
|
||||
|
||||
inline sample_t wtSample(const std::unique_ptr<OscillatorConstants::waveform_t>& table, const float sample) const
|
||||
inline sample_t wtSample(const OscillatorConstants::waveform_t* table, const float sample) const
|
||||
{
|
||||
assert(table != nullptr);
|
||||
wtSampleControl control = getWtSampleControl(sample);
|
||||
@@ -247,7 +256,8 @@ private:
|
||||
Oscillator * m_subOsc;
|
||||
float m_phaseOffset;
|
||||
float m_phase;
|
||||
const SampleBuffer * m_userWave;
|
||||
std::shared_ptr<const SampleBuffer2> m_userWave;
|
||||
std::shared_ptr<const OscillatorConstants::waveform_t> m_userAntiAliasWaveTable;
|
||||
bool m_useWaveTable;
|
||||
// There are many update*() variants; the modulator flag is stored as a member variable to avoid
|
||||
// adding more explicit parameters to all of them. Can be converted to a parameter if needed.
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LMMS_SAMPLE_BUFFER_H
|
||||
#define LMMS_SAMPLE_BUFFER_H
|
||||
#ifndef LMMS_SAMPLE_BUFFER2_H
|
||||
#define LMMS_SAMPLE_BUFFER2_H
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
@@ -80,4 +80,4 @@ private:
|
||||
|
||||
} // namespace lmms
|
||||
|
||||
#endif // LMMS_SAMPLE_BUFFER_H
|
||||
#endif // LMMS_SAMPLE_BUFFER2_H
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <QString>
|
||||
#include <memory>
|
||||
|
||||
#include "SampleBuffer.h"
|
||||
#include "SampleBuffer2.h"
|
||||
#include "lmms_export.h"
|
||||
|
||||
namespace lmms::gui {
|
||||
@@ -37,8 +37,8 @@ class LMMS_EXPORT SampleLoader
|
||||
public:
|
||||
static QString openAudioFile(const QString& previousFile = "");
|
||||
static QString openWaveformFile(const QString& previousFile = "");
|
||||
static std::unique_ptr<SampleBuffer> createBufferFromFile(const QString& filePath);
|
||||
static std::unique_ptr<SampleBuffer> createBufferFromBase64(const QString& base64, int sampleRate);
|
||||
static std::unique_ptr<SampleBuffer2> createBufferFromFile(const QString& filePath);
|
||||
static std::unique_ptr<SampleBuffer2> createBufferFromBase64(const QString& base64, int sampleRate);
|
||||
private:
|
||||
static void displayError(const QString& message);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user