Skip to content

Commit

Permalink
better example for debugging #135
Browse files Browse the repository at this point in the history
  • Loading branch information
bwhitman committed Jul 14, 2024
1 parent 86689af commit f3ff260
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
23 changes: 17 additions & 6 deletions src/amy-example.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ int main(int argc, char ** argv) {
}
amy_external_render_hook = render;

uint32_t start = amy_sysclock();

#if AMY_HAS_CUSTOM == 1
example_init_custom();
Expand All @@ -78,21 +77,33 @@ int main(int argc, char ** argv) {
}


example_voice_chord(0, 0);


// Now just spin for 5s
uint32_t start = amy_sysclock();
while(amy_sysclock() - start < 5000) {
if (output_filename) {
int16_t * frames = amy_simple_fill_buffer();
int num_frames = AMY_BLOCK_SIZE;
ma_encoder_write_pcm_frames(&encoder, frames, num_frames, NULL);
}
usleep(THREAD_USLEEP);
}

amy_reset_oscs();
//example_voice_chord(0, 128);
//example_drums(0, 4);
example_fm(0);

// Now just spin for 10s
while(amy_sysclock() - start < 5000) {
// Now just spin for 1s
while(amy_sysclock() - start < 6000) {
if (output_filename) {
int16_t * frames = amy_simple_fill_buffer();
int num_frames = AMY_BLOCK_SIZE;
ma_encoder_write_pcm_frames(&encoder, frames, num_frames, NULL);
}
usleep(THREAD_USLEEP);
}
show_debug(9);


if (output_filename) {
ma_encoder_uninit(&encoder);
Expand Down
10 changes: 6 additions & 4 deletions src/amy.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ void config_reverb(float level, float liveness, float damping, float xover_hz) {
if (level > 0) {
//printf("config_reverb: level %f liveness %f xover %f damping %f\n",
// level, liveness, xover_hz, damping);
if (reverb.level == 0) init_stereo_reverb(); // In case it's the first time
if (reverb.level == 0) {
init_stereo_reverb(); // In case it's the first time
}
config_stereo_reverb(liveness, xover_hz, damping);
}
reverb.level = F2S(level);
Expand Down Expand Up @@ -899,7 +901,7 @@ void play_event(struct delta d) {
AMY_UNSET(synth[d.osc].chained_osc);
}
if(d.param == CLONE_OSC) { clone_osc(d.osc, *(int16_t *)&d.data); }
if(d.param == RESET_OSC) { if(*(int16_t *)&d.data>AMY_OSCS) { amy_reset_oscs(); } else { reset_osc(*(int16_t *)&d.data); } }
if(d.param == RESET_OSC) { if(*(int16_t *)&d.data>(AMY_OSCS+1)) { amy_reset_oscs(); } else { reset_osc(*(int16_t *)&d.data); } }
// todo: event-only side effect, remove
if(d.param == MOD_SOURCE) { synth[d.osc].mod_source = *(uint16_t *)&d.data; synth[*(uint16_t *)&d.data].status = IS_MOD_SOURCE; }

Expand Down Expand Up @@ -1622,7 +1624,7 @@ struct event amy_parse_message(char * message) {
/* T unused */
/* U used by Alles for sync */
case 'u': patches_store_patch(message+start); AMY_PROFILE_STOP(AMY_PARSE_MESSAGE) return amy_default_event();
case 'v': e.osc=((atoi(message + start)) % AMY_OSCS); break; // allow osc wraparound
case 'v': e.osc=((atoi(message + start)) % (AMY_OSCS+1)); break; // allow osc wraparound
case 'V': e.volume = atoff(message + start); break;
case 'w': e.wave=atoi(message + start); break;
/* W used by Tulip for CV, external_channel */
Expand Down Expand Up @@ -1697,5 +1699,5 @@ void amy_start(uint8_t cores, uint8_t reverb, uint8_t chorus) {
amy_global.has_chorus = chorus;
amy_global.has_reverb = reverb;
oscs_init();
amy_reset_oscs();
//amy_reset_oscs();
}
14 changes: 7 additions & 7 deletions src/examples.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void example_fm(uint32_t start) {
// Output oscillator (op 1)
e = amy_default_event();
e.time = start;
e.osc = 0;
e.osc = 7;
e.wave = SINE;
e.ratio = 0.2f;
e.amp_coefs[COEF_CONST] = 0.1f;
Expand All @@ -296,7 +296,7 @@ void example_fm(uint32_t start) {
// Modulating oscillator (op 2)
e = amy_default_event();
e.time = start;
e.osc = 1;
e.osc = 8;
e.wave = SINE;
e.ratio = 1.0f;
e.amp_coefs[COEF_CONST] = 1.0f;
Expand All @@ -307,18 +307,18 @@ void example_fm(uint32_t start) {
// ALGO control oscillator
e = amy_default_event();
e.time = start;
e.osc = 2;
e.osc = 9;
e.wave = ALGO;
e.algorithm = 1; // algo 1 has op 2 driving op 1 driving output (plus a second chain for ops 6,5,4,3).
strcpy(e.algo_source, ",,,,1,0");
strcpy(e.algo_source, ",,,,8,7");
amy_add_event(e);

// Add a note on event.
e = amy_default_event();
e.time = start + 100;
e.osc = 2;
e.osc = 9;
e.midi_note = 60;
e.velocity = 1.0f;
e.velocity = 25.0f; // this is very quiet as constructed -- just two ops
amy_add_event(e);
}

Expand All @@ -328,7 +328,7 @@ void example_fm(uint32_t start) {
#if AMY_HAS_CUSTOM == 1

void beeper_init(void) {
printf("Beeper init\n");
//printf("Beeper init\n");
}

void beeper_note_on(uint16_t osc, float freq) {
Expand Down

0 comments on commit f3ff260

Please sign in to comment.