diff options
author | Robin Gareus <robin@gareus.org> | 2013-10-26 16:42:27 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2013-10-26 16:42:27 +0200 |
commit | e4514117190f398a0a672e25ecb48bc53cf9414b (patch) | |
tree | be305486e22446f5d4af3a50b64fbec966f42886 /libs/plugins | |
parent | f52cfdd6399ea4b1baab65ab2aae1b0086e9f9b3 (diff) |
remove c99'ness from rsynth.c - should fix #5751
Diffstat (limited to 'libs/plugins')
-rw-r--r-- | libs/plugins/reasonablesynth.lv2/lv2.c | 12 | ||||
-rw-r--r-- | libs/plugins/reasonablesynth.lv2/rsynth.c | 24 | ||||
-rw-r--r-- | libs/plugins/reasonablesynth.lv2/wscript | 1 |
3 files changed, 21 insertions, 16 deletions
diff --git a/libs/plugins/reasonablesynth.lv2/lv2.c b/libs/plugins/reasonablesynth.lv2/lv2.c index 159f422c85..a32fe200ce 100644 --- a/libs/plugins/reasonablesynth.lv2/lv2.c +++ b/libs/plugins/reasonablesynth.lv2/lv2.c @@ -25,7 +25,7 @@ /* LV2 */ #include "lv2/lv2plug.in/ns/lv2core/lv2.h" -#include "lv2/lv2plug.in/ns/ext/atom/util.h" +#include "lv2/lv2plug.in/ns/ext/atom/atom.h" #include "lv2/lv2plug.in/ns/ext/urid/urid.h" #include "lv2/lv2plug.in/ns/ext/midi/midi.h" @@ -35,7 +35,7 @@ static void * synth_alloc (void); static void synth_init (void *, double rate); static void synth_free (void *); -static void synth_parse_midi (void *, uint8_t *data, size_t size); +static void synth_parse_midi (void *, const uint8_t *data, const size_t size); static uint32_t synth_sound (void *, uint32_t written, uint32_t nframes, float **out); #include "rsynth.c" @@ -131,8 +131,8 @@ run(LV2_Handle handle, uint32_t n_samples) /* Process incoming MIDI events */ if (self->midiin) { - LV2_Atom_Event* ev = lv2_atom_sequence_begin(&(self->midiin)->body); - while(!lv2_atom_sequence_is_end(&(self->midiin)->body, (self->midiin)->atom.size, ev)) { + LV2_Atom_Event const* ev = (LV2_Atom_Event const*) ((&(self->midiin)->body) + 1); // lv2_atom_sequence_begin + while( (const uint8_t*)ev < ((const uint8_t*) &(self->midiin)->body + (self->midiin)->atom.size) ) { if (ev->body.type == self->midi_MidiEvent) { if (written + BUFFER_SIZE_SAMPLES < ev->time.frames && ev->time.frames < n_samples) { @@ -140,9 +140,9 @@ run(LV2_Handle handle, uint32_t n_samples) written = synth_sound(self->synth, written, ev->time.frames, audio); } /* send midi message to synth */ - synth_parse_midi(self->synth, (uint8_t*)(ev+1), ev->body.size); + synth_parse_midi(self->synth, (const uint8_t*)(ev+1), ev->body.size); } - ev = lv2_atom_sequence_next(ev); + ev = (LV2_Atom_Event const*)((const uint8_t*)ev + sizeof(LV2_Atom_Event) + ((ev->body.size + 7) & ~7)); } } diff --git a/libs/plugins/reasonablesynth.lv2/rsynth.c b/libs/plugins/reasonablesynth.lv2/rsynth.c index b89f0fb45f..c876c5b067 100644 --- a/libs/plugins/reasonablesynth.lv2/rsynth.c +++ b/libs/plugins/reasonablesynth.lv2/rsynth.c @@ -175,9 +175,10 @@ static void synthesize_sineP (RSSynthChannel* sc, const uint8_t note, const float vol, const float fq, const size_t n_samples, float* left, float* right) { + size_t i; float phase = sc->phase[note]; - for (size_t i=0; i < n_samples; ++i) { + for (i=0; i < n_samples; ++i) { float env = adsr_env(sc, note); if (sc->adsr_cnt[note] == 0) break; const float amp = vol * env; @@ -272,9 +273,11 @@ static void synth_fragment (void *synth, const size_t n_samples, float *left, fl memset (left, 0, n_samples * sizeof(float)); memset (right, 0, n_samples * sizeof(float)); uint8_t keycomp = 0; + int c,k; + size_t i; - for (int c=0; c < 16; ++c) { - for (int k=0; k < 128; ++k) { + for (c=0; c < 16; ++c) { + for (k=0; k < 128; ++k) { if (rs->sc[c].miditable[k] == 0) continue; process_key(synth, c, k, n_samples, left, right); } @@ -286,7 +289,7 @@ static void synth_fragment (void *synth, const size_t n_samples, float *left, fl if (kctgt < .5) kctgt = .5; if (kctgt > 1.0) kctgt = 1.0; const float _w = rs->kcfilt; - for (unsigned int i=0; i < n_samples; ++i) { + for (i=0; i < n_samples; ++i) { rs->kcgain += _w * (kctgt - rs->kcgain); left[i] *= rs->kcgain; right[i] *= rs->kcgain; @@ -296,7 +299,8 @@ static void synth_fragment (void *synth, const size_t n_samples, float *left, fl } static void synth_reset_channel(RSSynthChannel* sc) { - for (int k=0; k < 128; ++k) { + int k; + for (k=0; k < 128; ++k) { sc->adsr_cnt[k] = 0; sc->adsr_amp[k] = 0; sc->phase[k] = -10; @@ -307,7 +311,8 @@ static void synth_reset_channel(RSSynthChannel* sc) { static void synth_reset(void *synth) { RSSynthesizer* rs = (RSSynthesizer*)synth; - for (int c=0; c < 16; ++c) { + int c; + for (c=0; c < 16; ++c) { synth_reset_channel(&(rs->sc[c])); } rs->kcgain = 0; @@ -407,7 +412,7 @@ static uint32_t synth_sound (void *synth, uint32_t written, const uint32_t nfram * @param data 8bit midi message * @param size number of bytes in the midi-message */ -static void synth_parse_midi(void *synth, uint8_t *data, size_t size) { +static void synth_parse_midi(void *synth, const uint8_t *data, const size_t size) { if (size < 2 || size > 3) return; // All messages need to be 3 bytes; except program-changes: 2bytes. if (size == 2 && (data[0] & 0xf0) != 0xC0) return; @@ -454,14 +459,15 @@ static void synth_init(void *synth, double rate) { rs->rate = rate; rs->boffset = BUFFER_SIZE_SAMPLES; const float tuning = 440; - for (int k=0; k < 128; k++) { + int c,k; + for (k=0; k < 128; k++) { rs->freqs[k] = (2.0 * tuning / 32.0f) * powf(2, (k - 9.0) / 12.0) / rate; assert(rs->freqs[k] < M_PI/2); // otherwise spatialization may phase out.. } rs->kcfilt = 12.0 / rate; synth_reset(synth); - for (int c=0; c < 16; c++) { + for (c=0; c < 16; c++) { synth_load(&rs->sc[c], rate, &synthesize_sineP, &piano_adsr); } } diff --git a/libs/plugins/reasonablesynth.lv2/wscript b/libs/plugins/reasonablesynth.lv2/wscript index 37a11a4228..db0bf0af8a 100644 --- a/libs/plugins/reasonablesynth.lv2/wscript +++ b/libs/plugins/reasonablesynth.lv2/wscript @@ -15,7 +15,6 @@ def options(opt): def configure(conf): conf.load('compiler_c') autowaf.configure(conf) - autowaf.set_c99_mode(conf) if Options.options.lv2: autowaf.check_pkg(conf, 'lv2', atleast_version='1.0.0', uselib_store='LV2_1_0_0') |