1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
#ifndef EFFECT_DELAY_H
#define EFFECT_DELAY_H
#include "engine/audio_effect.h"
class AudioEffectDelay : public AudioEffect {
int block_size;
int sampling_rate;
bool bpm_sync;
float bpm;
enum {
MAX_DELAY_UNITS = 48,
MAX_DELAY_MS = 4000,
MS_CUTOFF_MAX = 16000,
MAX_TAPS = 4
};
Vector<AudioFrame> ring_buffer;
unsigned int ring_buffer_pos;
unsigned int ring_buffer_mask;
struct Tap {
AudioFrame h;
Vector<AudioFrame> feedback_buffer;
unsigned int feedback_buffer_pos;
};
void _process_chunk(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count);
Tap taps[MAX_TAPS];
enum BeatSubdiv {
BEAT_SUBDIV_1,
BEAT_SUBDIV_2,
BEAT_SUBDIV_3,
BEAT_SUBDIV_4,
BEAT_SUBDIV_6,
BEAT_SUBDIV_8,
BEAT_SUBDIV_12,
BEAT_SUBDIV_16,
BEAT_SUBDIV_MAX
};
enum ControlPorts {
CONTROL_PORT_TAP1_ENABLED,
CONTROL_PORT_TAP1_BEAT_SUBDIV,
CONTROL_PORT_TAP1_DELAY_UNITS,
CONTROL_PORT_TAP1_VOLUME,
CONTROL_PORT_TAP1_FEEDBACK,
CONTROL_PORT_TAP1_FEEDBACK_STEREO_SWAP,
CONTROL_PORT_TAP1_LPF,
CONTROL_PORT_TAP1_PAN,
CONTROL_PORT_TAP2_ENABLED,
CONTROL_PORT_TAP2_BEAT_SUBDIV,
CONTROL_PORT_TAP2_DELAY_UNITS,
CONTROL_PORT_TAP2_VOLUME,
CONTROL_PORT_TAP2_FEEDBACK,
CONTROL_PORT_TAP2_FEEDBACK_STEREO_SWAP,
CONTROL_PORT_TAP2_LPF,
CONTROL_PORT_TAP2_PAN,
CONTROL_PORT_TAP3_ENABLED,
CONTROL_PORT_TAP3_BEAT_SUBDIV,
CONTROL_PORT_TAP3_DELAY_UNITS,
CONTROL_PORT_TAP3_VOLUME,
CONTROL_PORT_TAP3_FEEDBACK,
CONTROL_PORT_TAP3_FEEDBACK_STEREO_SWAP,
CONTROL_PORT_TAP3_LPF,
CONTROL_PORT_TAP3_PAN,
CONTROL_PORT_TAP4_ENABLED,
CONTROL_PORT_TAP4_BEAT_SUBDIV,
CONTROL_PORT_TAP4_DELAY_UNITS,
CONTROL_PORT_TAP4_VOLUME,
CONTROL_PORT_TAP4_FEEDBACK,
CONTROL_PORT_TAP4_FEEDBACK_STEREO_SWAP,
CONTROL_PORT_TAP4_LPF,
CONTROL_PORT_TAP4_PAN,
CONTROL_PORT_MAX
};
ControlPortDefault control_ports[CONTROL_PORT_MAX];
void _update_buffers();
public:
//process
virtual bool has_secondary_input() const;
virtual void process(const Event *p_events, int p_event_count, const AudioFrame *p_in, AudioFrame *p_out, bool p_prev_active);
virtual void process_with_secondary(const Event *p_events, int p_event_count, const AudioFrame *p_in, const AudioFrame *p_secondary, AudioFrame *p_out, bool p_prev_active);
virtual void set_process_block_size(int p_size);
virtual void set_sampling_rate(int p_hz);
//info
virtual String get_name() const;
virtual String get_unique_id() const;
virtual String get_provider_id() const;
virtual int get_control_port_count() const;
virtual ControlPort *get_control_port(int p_port);
virtual void reset();
/* Load/Save */
virtual JSON::Node to_json() const;
virtual Error from_json(const JSON::Node &node);
AudioEffectDelay(bool p_bpm_sync);
~AudioEffectDelay();
};
#endif // EFFECT_DELAY_H
|