templated sample data type
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace trnr {
|
namespace trnr {
|
||||||
|
template <typename t_sample>
|
||||||
// Bandpass filter based on YBandpass by Chris Johnson
|
// Bandpass filter based on YBandpass by Chris Johnson
|
||||||
class ybandpass {
|
class ybandpass {
|
||||||
public:
|
public:
|
||||||
@@ -70,7 +71,7 @@ public:
|
|||||||
{
|
{
|
||||||
F = value;
|
F = value;
|
||||||
}
|
}
|
||||||
void processblock(double** inputs, double** outputs, int blockSize)
|
void processblock(t_sample** inputs, t_sample** outputs, int blockSize)
|
||||||
{
|
{
|
||||||
double* in1 = inputs[0];
|
double* in1 = inputs[0];
|
||||||
double* in2 = inputs[1];
|
double* in2 = inputs[1];
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace trnr {
|
namespace trnr {
|
||||||
|
template <typename t_sample>
|
||||||
// Highpass filter based on YHighpass by Chris Johnson
|
// Highpass filter based on YHighpass by Chris Johnson
|
||||||
class yhighpass {
|
class yhighpass {
|
||||||
public:
|
public:
|
||||||
@@ -70,7 +71,7 @@ public:
|
|||||||
{
|
{
|
||||||
F = value;
|
F = value;
|
||||||
}
|
}
|
||||||
void processblock(double** inputs, double** outputs, int blockSize)
|
void processblock(t_sample** inputs, t_sample** outputs, int blockSize)
|
||||||
{
|
{
|
||||||
double* in1 = inputs[0];
|
double* in1 = inputs[0];
|
||||||
double* in2 = inputs[1];
|
double* in2 = inputs[1];
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace trnr {
|
namespace trnr {
|
||||||
|
template <typename t_sample>
|
||||||
// Lowpass filter based on YLowpass by Chris Johnson
|
// Lowpass filter based on YLowpass by Chris Johnson
|
||||||
class ylowpass {
|
class ylowpass {
|
||||||
public:
|
public:
|
||||||
@@ -70,12 +71,12 @@ public:
|
|||||||
{
|
{
|
||||||
F = value;
|
F = value;
|
||||||
}
|
}
|
||||||
void processblock(double** inputs, double** outputs, int blockSize)
|
void processblock(t_sample** inputs, t_sample** outputs, int blockSize)
|
||||||
{
|
{
|
||||||
double* in1 = inputs[0];
|
t_sample* in1 = inputs[0];
|
||||||
double* in2 = inputs[1];
|
t_sample* in2 = inputs[1];
|
||||||
double* out1 = outputs[0];
|
t_sample* out1 = outputs[0];
|
||||||
double* out2 = outputs[1];
|
t_sample* out2 = outputs[1];
|
||||||
|
|
||||||
int inFramesToProcess = blockSize;
|
int inFramesToProcess = blockSize;
|
||||||
double overallscale = 1.0;
|
double overallscale = 1.0;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
template <typename t_sample>
|
||||||
namespace trnr {
|
namespace trnr {
|
||||||
// Notch filter based on YNotch by Chris Johnson
|
// Notch filter based on YNotch by Chris Johnson
|
||||||
class ynotch {
|
class ynotch {
|
||||||
@@ -70,7 +71,7 @@ public:
|
|||||||
{
|
{
|
||||||
F = value;
|
F = value;
|
||||||
}
|
}
|
||||||
void processblock(double** inputs, double** outputs, int blockSize)
|
void processblock(t_sample** inputs, t_sample** outputs, int blockSize)
|
||||||
{
|
{
|
||||||
double* in1 = inputs[0];
|
double* in1 = inputs[0];
|
||||||
double* in2 = inputs[1];
|
double* in2 = inputs[1];
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "ynotch.h"
|
#include "ynotch.h"
|
||||||
|
|
||||||
namespace trnr {
|
namespace trnr {
|
||||||
|
template <typename t_sample>
|
||||||
|
|
||||||
enum filter_types {
|
enum filter_types {
|
||||||
lowpass = 0,
|
lowpass = 0,
|
||||||
@@ -75,7 +76,7 @@ public:
|
|||||||
notch.set_mix(value);
|
notch.set_mix(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_block(double** inputs, double** outputs, int block_size) {
|
void process_block(t_sample** inputs, t_sample** outputs, int block_size) {
|
||||||
|
|
||||||
switch (filter_type) {
|
switch (filter_type) {
|
||||||
case filter_types::lowpass:
|
case filter_types::lowpass:
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ namespace trnr {
|
|||||||
|
|
||||||
// a generic midi synth base class with sample accurate event handling.
|
// a generic midi synth base class with sample accurate event handling.
|
||||||
// the templated type t_voice must derive from ivoice
|
// the templated type t_voice must derive from ivoice
|
||||||
template <typename t_voice>
|
template <typename t_voice, typename t_sample>
|
||||||
class midi_synth : public voice_allocator<t_voice> {
|
class midi_synth : public voice_allocator<t_voice, t_sample> {
|
||||||
public:
|
public:
|
||||||
midi_synth(int _n_voices)
|
midi_synth(int _n_voices)
|
||||||
: m_voices_active { false }
|
: m_voices_active { false }
|
||||||
@@ -22,10 +22,10 @@ public:
|
|||||||
void set_samplerate_blocksize(double _samplerate, int _block_size)
|
void set_samplerate_blocksize(double _samplerate, int _block_size)
|
||||||
{
|
{
|
||||||
m_block_size = _block_size;
|
m_block_size = _block_size;
|
||||||
voice_allocator<t_voice>::set_samplerate(_samplerate);
|
voice_allocator<t_voice, t_sample>::set_samplerate(_samplerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_block(double** _outputs, int _n_frames)
|
void process_block(t_sample** _outputs, int _n_frames)
|
||||||
{
|
{
|
||||||
// sample accurate event handling based on the iPlug2 synth by Oli Larkin
|
// sample accurate event handling based on the iPlug2 synth by Oli Larkin
|
||||||
if (m_voices_active || !m_event_queue.empty()) {
|
if (m_voices_active || !m_event_queue.empty()) {
|
||||||
@@ -48,18 +48,18 @@ public:
|
|||||||
// send performance messages to the voice allocator
|
// send performance messages to the voice allocator
|
||||||
// message offset is relative to the start of this process_samples() block
|
// message offset is relative to the start of this process_samples() block
|
||||||
event.offset -= start_index;
|
event.offset -= start_index;
|
||||||
voice_allocator<t_voice>::add_event(event);
|
voice_allocator<t_voice, t_sample>::add_event(event);
|
||||||
|
|
||||||
m_event_queue.erase(m_event_queue.begin());
|
m_event_queue.erase(m_event_queue.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
voice_allocator<t_voice>::process_samples(_outputs, start_index, block_size);
|
voice_allocator<t_voice, t_sample>::process_samples(_outputs, start_index, block_size);
|
||||||
|
|
||||||
samples_remaining -= block_size;
|
samples_remaining -= block_size;
|
||||||
start_index += block_size;
|
start_index += block_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_voices_active = voice_allocator<t_voice>::voices_active();
|
m_voices_active = voice_allocator<t_voice, t_sample>::voices_active();
|
||||||
|
|
||||||
flush_event_queue(_n_frames);
|
flush_event_queue(_n_frames);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
namespace trnr {
|
namespace trnr {
|
||||||
|
|
||||||
template <typename t_voice>
|
template <typename t_voice, typename t_sample>
|
||||||
class voice_allocator {
|
class voice_allocator {
|
||||||
public:
|
public:
|
||||||
std::vector<t_voice> voices;
|
std::vector<t_voice> voices;
|
||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
std::for_each(voices.begin(), voices.end(), f);
|
std::for_each(voices.begin(), voices.end(), f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_samples(double** _outputs, int _start_index, int _block_size)
|
void process_samples(t_sample** _outputs, int _start_index, int _block_size)
|
||||||
{
|
{
|
||||||
for (int s = _start_index; s < _start_index + _block_size; s++) {
|
for (int s = _start_index; s < _start_index + _block_size; s++) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user