mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 23:05:04 +01:00
remove c99'ness from rsynth.c - should fix #5751
This commit is contained in:
parent
f52cfdd639
commit
e451411719
3 changed files with 21 additions and 16 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue