clap

CLAP Audio Plugin API
Log | Files | Refs | README | LICENSE

commit 867d6795cb0bc2a370009706ad3c88efe0909425
parent 88511bd968a25a078d5b574c30fa3187619c591b
Author: Alexandre Bique <bique.alexandre@gmail.com>
Date:   Thu, 23 Oct 2014 11:55:06 +0200

Micro modifications to example synth

Diffstat:
Mexamples/thyns/plugin.c | 1+
Mexamples/thyns/thyns.h | 17++++++++++++++---
Mexamples/thyns/voice.h | 2++
Minclude/clap/clap.h | 2+-
4 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/examples/thyns/plugin.c b/examples/thyns/plugin.c @@ -134,6 +134,7 @@ void thyns_plugin_process(struct clap_plugin *plugin, struct clap_process *process) { + thyns_process(plugin->plugin_data, process); } bool diff --git a/examples/thyns/thyns.h b/examples/thyns/thyns.h @@ -12,13 +12,15 @@ struct thyns uint32_t sr; // sample rate double pi_sr; // M_PI / sample_rate + uint64_t steady_time; + struct thyns_voice *running; struct thyns_voice *idle; struct thyns_voice buffer[THYNS_VOICE_COUNT]; }; -static void thyns_init(struct thyns *thyns, uint32_t sr) +static inline void thyns_init(struct thyns *thyns, uint32_t sr) { thyns->sr = sr; thyns->pi_sr = M_PI / sr; @@ -32,8 +34,8 @@ static void thyns_init(struct thyns *thyns, uint32_t sr) thyns->buffer[THYNS_VOICE_COUNT - 1].next = NULL; } -double thyns_step(struct thyns *thyns, - struct clap_process *process) +static double thyns_step(struct thyns *thyns, + struct clap_process *process) { double out = 0; struct thyns_voice *prev = NULL; @@ -63,4 +65,13 @@ double thyns_step(struct thyns *thyns, return out; } +static inline void thyns_process(struct thyns *thyns, + struct clap_process *process) +{ + thyns->steady_time = process->steady_time; + for (uint32_t i = 0; i < process->samples_count; ++i, ++thyns->steady_time) { + process->output[i] = thyns_step(thyns, process); + } +} + #endif /* !THYNS_H */ diff --git a/examples/thyns/voice.h b/examples/thyns/voice.h @@ -12,6 +12,8 @@ struct thyns_voice uint32_t sr; // sample rate double pi_sr; // M_PI / sample_rate + double pitch; + uint32_t note; uint32_t division; diff --git a/include/clap/clap.h b/include/clap/clap.h @@ -270,7 +270,7 @@ struct clap_process }; float **output; - uint32_t nb_samples; + uint32_t samples_count; /* feedback loops */ void (*feedback)(struct clap_process *process, uint32_t stream_id, uint32_t nb_samples);