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/reasonablesynth.lv2/rsynth.c | |
parent | f52cfdd6399ea4b1baab65ab2aae1b0086e9f9b3 (diff) |
remove c99'ness from rsynth.c - should fix #5751
Diffstat (limited to 'libs/plugins/reasonablesynth.lv2/rsynth.c')
-rw-r--r-- | libs/plugins/reasonablesynth.lv2/rsynth.c | 24 |
1 files changed, 15 insertions, 9 deletions
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); } } |