--- /dev/null
+#include "colon3sampler.h"
+
+const char *midi_key[128] = {
+ "C-1", "C#-1", "D-1", "D#-1", "E-1", "F-1", "F#-1", "G-1", "G#-1", "A-1", "A#-1", "B-1"
+ "C0", "C#0", "D0", "D#0", "E0", "F0", "F#0", "G0", "G#0", "A0", "A#0", "B0"
+ "C1", "C#1", "D1", "D#1", "E1", "F1", "F#1", "G1", "G#1", "A1", "A#1", "B1"
+ "C2", "C#2", "D2", "D#2", "E2", "F2", "F#2", "G2", "G#2", "A2", "A#2", "B2"
+ "C3", "C#3", "D3", "D#3", "E3", "F3", "F#3", "G3", "G#3", "A3", "A#3", "B3"
+ "C4", "C#4", "D4", "D#4", "E4", "F4", "F#4", "G4", "G#4", "A4", "A#4", "B4"
+ "C5", "C#5", "D5", "D#5", "E5", "F5", "F#5", "G5", "G#5", "A5", "A#5", "B5"
+ "C6", "C#6", "D6", "D#6", "E6", "F6", "F#6", "G6", "G#6", "A6", "A#6", "B6"
+ "C7", "C#7", "D7", "D#7", "E7", "F7", "F#7", "G7", "G#7", "A7", "A#7", "B7"
+ "C8", "C#8", "D8", "D#8", "E8", "F8", "F#8", "G8", "G#8", "A8", "A#8", "B8"
+ "C9", "C#9", "D9", "D#9", "E9", "F9", "F#9", "G9"
+};
+
+
+static int midi_to_midi_int(char *note);
+static float midi_int_to_hz(int midi_int);
+
+float midi_to_hz(char *note)
+{
+ int midi = midi_to_midi_int(note);
+ float hz = midi_int_to_hz(midi);
+ return hz;
+};
+
+static int midi_to_midi_int(char *n)
+{
+ int m = 0; int s = 0;
+ switch (n[0]) {
+ case 'B': m++;
+ case 'A': m++;
+ case 'G': m++;
+ case 'F': m++;
+ case 'E': m++;
+ case 'D': m++;
+ };
+ if (n[1] == '#') {
+ m++; s = 1;
+ };
+
+ int oct = arg_to_float(n+1+s);
+ m += 12*(oct+1);
+ return m;
+
+};
+
+static float midi_int_to_hz(int midi)
+{
+ /* From github.com/UtaUtaUtau/straycat */
+ /* Under the MIT license (ADD MIT LICENSE :<) */
+ /* ok here */
+ /*
+ * Copyright 2022 UtaUtaUtau
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+ /* i hope it's ok to format it like that... */
+ /* it's a bit different bc straycat (original) is in python :) */
+
+ /* "A4 == 440Hz" (quote) */
+ return 440.0 * pow(2,(midi - 69.0) / 12.0);
+};
+