diff --git a/src/amy-example.c b/src/amy-example.c index 26afeb5..2452ce1 100644 --- a/src/amy-example.c +++ b/src/amy-example.c @@ -70,8 +70,9 @@ int main(int argc, char ** argv) { amy_reset_oscs(); - example_voice_chord(0, 128); + //example_voice_chord(0, 128); //example_drums(0, 4); + example_fm(0); // Now just spin for 10s while(amy_sysclock() - start < 5000) { @@ -82,7 +83,7 @@ int main(int argc, char ** argv) { } usleep(THREAD_USLEEP); } - show_debug(3); + show_debug(9); if (output_filename) { ma_encoder_uninit(&encoder); diff --git a/src/amy.c b/src/amy.c index 07b476f..c2edfc8 100644 --- a/src/amy.c +++ b/src/amy.c @@ -468,8 +468,9 @@ void amy_add_event_internal(struct event e, uint16_t base_osc) { char * bps[MAX_BREAKPOINT_SETS] = {e.bp0, e.bp1}; for(uint8_t i=0;i0) { e.velocity = 0.5 * volume; e.midi_note = bassline[i] - 12; - //last_bass_was_on = 1; - //actually_send_the_bass = 1; } else { - //actually_send_the_bass = last_bass_was_on; e.velocity = 0; - //last_bass_was_on = 0; } - //if (actually_send_the_bass) { - amy_add_event(e); - //} + amy_add_event(e); } } } +void example_fm(uint32_t start) { + // Direct construction of an FM tone, as in the documentation. + struct event e; + + // Output oscillator (op 1) + e = amy_default_event(); + e.time = start; + e.osc = 0; + e.wave = SINE; + e.ratio = 0.2f; + e.amp_coefs[COEF_CONST] = 0.1f; + e.amp_coefs[COEF_VEL] = 0; + e.amp_coefs[COEF_EG0] = 1.0f; + strcpy(e.bp0, "0,1,1000,0,0,0"); + amy_add_event(e); + + // Modulating oscillator (op 2) + e = amy_default_event(); + e.time = start; + e.osc = 1; + e.wave = SINE; + e.ratio = 1.0f; + e.amp_coefs[COEF_CONST] = 1.0f; + e.amp_coefs[COEF_VEL] = 0; + e.amp_coefs[COEF_EG0] = 0; + amy_add_event(e); + + // ALGO control oscillator + e = amy_default_event(); + e.time = start; + e.osc = 2; + 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,-1,-1,-1,1,0"); + amy_add_event(e); + + // Add a note on event. + e = amy_default_event(); + e.time = start + 100; + e.osc = 2; + e.midi_note = 60; + e.velocity = 1.0f; + amy_add_event(e); +} + + // Minimal custom oscillator #if AMY_HAS_CUSTOM == 1 diff --git a/src/examples.h b/src/examples.h index fad48f1..4cabb3d 100644 --- a/src/examples.h +++ b/src/examples.h @@ -5,11 +5,11 @@ #include "amy.h" -void example_reverb() ; -void example_chorus() ; -void example_ks(uint32_t start) ; -void bleep(uint32_t start) ; -void example_fm(uint32_t start) ; +void example_reverb(); +void example_chorus(); +void example_ks(uint32_t start); +void bleep(uint32_t start); +void example_fm(uint32_t start); void example_multimbral_fm(); void example_drums(uint32_t start, int loops); void example_sine(uint32_t start);