2024-10-09 21:43:52 +00:00
|
|
|
/*
|
|
|
|
Peacock-8 VA polysynth
|
|
|
|
|
|
|
|
Copyright 2024 Gordon JC Pearce <gordonjcp@gjcp.net>
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
|
|
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
|
|
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
|
|
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ic29.hpp"
|
|
|
|
|
|
|
|
#include "peacock.hpp"
|
|
|
|
|
2024-10-11 23:15:00 +00:00
|
|
|
Synth::Synth() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void Synth::run() {
|
|
|
|
printf("called synth::run()\n");
|
|
|
|
printf("%d\n", voices[0].env.phase);
|
|
|
|
}
|
|
|
|
|
2024-10-09 21:51:37 +00:00
|
|
|
void Synth::voiceOn(uint8_t voice, uint8_t note) {
|
|
|
|
// enable synth voice, start it all running
|
|
|
|
}
|
2024-10-11 23:15:00 +00:00
|
|
|
|
|
|
|
Envelope::Envelope() {
|
|
|
|
level = 0;
|
|
|
|
phase = ENV_IDLE;
|
|
|
|
printf("initialising envelope\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Envelope::run() {
|
|
|
|
switch (phase) {
|
|
|
|
case ENV_ATK:
|
|
|
|
level += s.envAtk;
|
|
|
|
if (level > 0x3fff) {
|
|
|
|
level = 0x3fff;
|
|
|
|
phase = ENV_DCY;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ENV_DCY:
|
|
|
|
if (level > s.envStn) {
|
|
|
|
level -= s.envStn;
|
|
|
|
level *= s.envDcy;
|
|
|
|
level += s.envStn;
|
|
|
|
} else {
|
|
|
|
level = s.envStn;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ENV_RLS:
|
|
|
|
level *= s.envRls;
|
|
|
|
break;
|
|
|
|
case ENV_IDLE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Envelope::gate(uint8_t gate) {
|
|
|
|
}
|
|
|
|
|
|
|
|
Voice::Voice() {
|
|
|
|
}
|