Mapped oscillator pulse width to modulation wheel.
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define VOICE_COUNT 8
|
#define VOICE_COUNT 16
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
WAVE_SINE,
|
WAVE_SINE,
|
||||||
|
|||||||
@@ -96,12 +96,18 @@ void *midiThread(void *arg)
|
|||||||
synthNoteOff(m->synth, ev->data.note.note);
|
synthNoteOff(m->synth, ev->data.note.note);
|
||||||
break;
|
break;
|
||||||
case SND_SEQ_EVENT_CONTROLLER:
|
case SND_SEQ_EVENT_CONTROLLER:
|
||||||
|
// This are controller parameter changes.
|
||||||
|
// Map the Mod Wheel to PWM:
|
||||||
|
if (ev->data.control.param == 1)
|
||||||
|
m->synth->dutyCycle = 0.05f + (ev->data.control.value / 127.0f) * 0.90f;
|
||||||
|
// This naively maps parameter 70 to the waveform in a way that does not play so nice with real pots.
|
||||||
if (ev->data.control.param == 70)
|
if (ev->data.control.param == 70)
|
||||||
m->synth->waveform = ev->data.control.value % WAVE_COUNT;
|
m->synth->waveform = ev->data.control.value % WAVE_COUNT;
|
||||||
break;
|
break;
|
||||||
case SND_SEQ_EVENT_PITCHBEND:
|
case SND_SEQ_EVENT_PITCHBEND:
|
||||||
m->synth->pitchBend = ev->data.control.value / 8191.0f;
|
m->synth->pitchBend = ev->data.control.value / 8191.0f;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
snd_seq_free_event(ev);
|
snd_seq_free_event(ev);
|
||||||
ev = NULL;
|
ev = NULL;
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ int main(void)
|
|||||||
20, 55, 20, RAYWHITE);
|
20, 55, 20, RAYWHITE);
|
||||||
DrawText(TextFormat("MIDI: client %d port %d", gMidi.client, gMidi.port),
|
DrawText(TextFormat("MIDI: client %d port %d", gMidi.client, gMidi.port),
|
||||||
20, 90, 20, GRAY);
|
20, 90, 20, GRAY);
|
||||||
|
if (gSynth.waveform == WAVE_PULSE)
|
||||||
|
DrawText(TextFormat("Duty Cycle: %.2f", gSynth.dutyCycle), 20, 280, 20, GREEN);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user