experiments

This commit is contained in:
2025-06-05 21:51:34 +02:00
parent a5b52b6b89
commit d4665c4e9b
4 changed files with 57 additions and 14 deletions

View File

@@ -58,8 +58,8 @@ void audio_callback(void *userdata, Uint8 *stream, int len) {
MidiEvent *ev = &midiEvents[midiChannel][nextMidiEvent[midiChannel]];
printf("Event at %f, %s, note: %d, velocity: %d\n", ev->timeSec, ev->type == MIDI_NOTE_ON ? "ON" : "OFF",
ev->note, ev->velocity);
// printf("Event at %f, %s, note: %d, velocity: %d\n", ev->timeSec, ev->type == MIDI_NOTE_ON ? "ON" : "OFF",
// ev->note, ev->velocity);
uint16_t freq = (uint16_t)(440.0f * powf(2.0f, (ev->note - 69) / 12.0f));
uint8_t midiVoiceIndex = NUM_SYNTH_VOICES - midiChannel - 1;
@@ -69,12 +69,12 @@ void audio_callback(void *userdata, Uint8 *stream, int len) {
v->frequency = freq;
v->volume = ev->velocity * 2;
v->smoothedAmp = 0;
printf("Playing voice %d at freq %d hz, volume %d\n", midiVoiceIndex, v->frequency,
v->volume);
// printf("Playing voice %d at freq %d hz, volume %d\n", midiVoiceIndex, v->frequency,
// v->volume);
} else if (ev->type == MIDI_NOTE_OFF || ev->velocity == 0) {
// Note Off
v->volume = 0;
printf("Stopping voice %d at freq %d hz, volume %d\n", midiVoiceIndex, v->frequency, v->volume);
// printf("Stopping voice %d at freq %d hz, volume %d\n", midiVoiceIndex, v->frequency, v->volume);
} else if ((ev->type & 0xF0) == MIDI_PROGRAM_CHANGE) {
if (ev->note == 0) {
v->waveform = resolvePatch(ev->note);