shithub: neindaw

Download patch

ref: cb02cb542f17f9a9fa1c408a32358d0f47f9bd1d
parent: 0c2f81916eff6df420133848ec87f8fecab86f0e
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Tue May 12 09:25:06 EDT 2020

piper: add AY parts

--- a/piper/ay.c
+++ b/piper/ay.c
@@ -10,6 +10,7 @@
 		int enable;
 		int noise;
 		int env;
+		int vol;
 	}abc[3];
 	struct {
 		int period;
@@ -27,6 +28,38 @@
 static int
 cmd(void *aux, Cmd *c)
 {
+	AY *ay;
+	int i;
+	float dur;
+
+	ay = aux;
+	switch (c->type) {
+	case CmdNote:
+		fprint(ay->env.hit, "0");
+		for (i = 0; i < 3; i++)
+			fprint(ay->abc[i].enable, "0");
+
+		dur = 0.0;
+		for (i = 0; i < c->numnotes; i++) {
+			fprint(ay->abc[i].enable, "1");
+			fprint(ay->abc[i].freq, "%g", c->note[i].freq);
+			fprint(ay->abc[i].vol, "%g", c->note[i].vel);
+			if (dur < c->note[i].dur)
+				dur = c->note[i].dur;
+		}
+
+		fprint(ay->env.period, "%g", dur);
+		fprint(ay->env.hit, "1");
+		break;
+
+	case CmdVol:
+		fprint(ay->volume, "%g", c->vol);
+		break;
+
+	case CmdRaw:
+		break;
+	}
+
 	return 0;
 }
 
@@ -40,13 +73,16 @@
 		for (i = 0; i < 3; i++) {
 			ay->abc[i].freq = pathopen(path, "%c/Tone/Frequency/ctl", 'A'+i);
 			ay->abc[i].enable = pathopen(path, "%c/Tone/Enable/ctl", 'A'+i);
-			ay->abc[i].enable = pathopen(path, "%c/Noise/ctl", 'A'+i);
-			ay->abc[i].enable = pathopen(path, "%c/Envelope/ctl", 'A'+i);
+			ay->abc[i].noise = pathopen(path, "%c/Noise/ctl", 'A'+i);
+			ay->abc[i].env = pathopen(path, "%c/Envelope/ctl", 'A'+i);
+			ay->abc[i].vol = pathopen(path, "%c/Volume/ctl", 'A'+i);
+			fprint(ay->abc[i].env, "1");
 		}
 
 		ay->env.period = pathopen(path, "Envelope/Period/ctl");
 		ay->env.alter = pathopen(path, "Envelope/Alternate/ctl");
 		ay->env.attack = pathopen(path, "Envelope/Attack/ctl");
+		fprint(ay->env.attack, "1");
 		ay->env.cont = pathopen(path, "Envelope/Continue/ctl");
 		ay->env.hold = pathopen(path, "Envelope/Hold/ctl");
 		ay->env.hit = pathopen(path, "Envelope/Hit/ctl");