From 0a098e3008ad78d3ea2f323db7e5e213f68e0960 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Tue, 29 Nov 2022 22:04:46 +0100 Subject: [PATCH] mock csound --- repl/src/runtime.mjs | 4 ++ .../test/__snapshots__/tunes.test.mjs.snap | 69 +++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/repl/src/runtime.mjs b/repl/src/runtime.mjs index 8945f1a8..d0c96c45 100644 --- a/repl/src/runtime.mjs +++ b/repl/src/runtime.mjs @@ -88,6 +88,9 @@ const toneHelpersMocked = { strudel.Pattern.prototype.osc = function () { return this; }; +strudel.Pattern.prototype.csound = function () { + return this; +}; strudel.Pattern.prototype.tone = function () { return this; }; @@ -170,6 +173,7 @@ evalScope( { // gist, // euclid, + csound: id, mini, getDrawContext, getAudioContext, diff --git a/repl/src/test/__snapshots__/tunes.test.mjs.snap b/repl/src/test/__snapshots__/tunes.test.mjs.snap index a1598d3f..864a9ba7 100644 --- a/repl/src/test/__snapshots__/tunes.test.mjs.snap +++ b/repl/src/test/__snapshots__/tunes.test.mjs.snap @@ -1409,6 +1409,75 @@ exports[`renders tunes > tune: chop 1`] = ` ] `; +exports[`renders tunes > tune: csoundMixed 1`] = ` +[ + "2/3 -> 3/4: {\\"note\\":58.95209612324834,\\"gain\\":1}", + "2/3 -> 3/4: {\\"note\\":61.95209612324834,\\"gain\\":1}", + "2/3 -> 3/4: {\\"note\\":63.95209612324834,\\"gain\\":1}", + "2/3 -> 3/4: {\\"note\\":66.95209612324834,\\"gain\\":1}", + "0/1 -> 1/6: {\\"note\\":\\"c2\\",\\"s\\":\\"sawtooth\\",\\"cutoff\\":277.9313247650862,\\"resonance\\":10,\\"decay\\":0.1,\\"sustain\\":0}", + "0/1 -> 1/6: {\\"note\\":35.95209612324834,\\"s\\":\\"sawtooth\\",\\"cutoff\\":277.9313247650862,\\"resonance\\":10,\\"decay\\":0.1,\\"sustain\\":0}", + "1/3 -> 1/2: {\\"note\\":\\"c2\\",\\"s\\":\\"sawtooth\\",\\"cutoff\\":277.9313247650862,\\"resonance\\":10,\\"decay\\":0.1,\\"sustain\\":0}", + "1/3 -> 1/2: {\\"note\\":35.95209612324834,\\"s\\":\\"sawtooth\\",\\"cutoff\\":277.9313247650862,\\"resonance\\":10,\\"decay\\":0.1,\\"sustain\\":0}", + "1/2 -> 2/3: {\\"note\\":\\"c2\\",\\"s\\":\\"sawtooth\\",\\"cutoff\\":277.9313247650862,\\"resonance\\":10,\\"decay\\":0.1,\\"sustain\\":0}", + "1/2 -> 2/3: {\\"note\\":35.95209612324834,\\"s\\":\\"sawtooth\\",\\"cutoff\\":277.9313247650862,\\"resonance\\":10,\\"decay\\":0.1,\\"sustain\\":0}", + "5/6 -> 1/1: {\\"note\\":\\"c2\\",\\"s\\":\\"sawtooth\\",\\"cutoff\\":277.9313247650862,\\"resonance\\":10,\\"decay\\":0.1,\\"sustain\\":0}", + "5/6 -> 1/1: {\\"note\\":35.95209612324834,\\"s\\":\\"sawtooth\\",\\"cutoff\\":277.9313247650862,\\"resonance\\":10,\\"decay\\":0.1,\\"sustain\\":0}", + "0/1 -> 1/1: {\\"s\\":\\"bd\\",\\"room\\":0.5,\\"speed\\":0.900230494513707}", + "1/3 -> 2/3: {\\"s\\":\\"hh:1\\",\\"room\\":0.5,\\"speed\\":0.900230494513707}", + "2/3 -> 1/1: {\\"s\\":\\"hh:1\\",\\"room\\":0.5,\\"speed\\":0.9009985942422922}", +] +`; + +exports[`renders tunes > tune: csoundTest 1`] = ` +[ + "0/1 -> 2/1: {\\"note\\":\\"B3\\",\\"s\\":\\"sawtooth\\"}", + "0/1 -> 2/1: {\\"note\\":\\"D4\\",\\"s\\":\\"sawtooth\\"}", + "0/1 -> 2/1: {\\"note\\":\\"E4\\",\\"s\\":\\"sawtooth\\"}", + "0/1 -> 2/1: {\\"note\\":\\"G4\\",\\"s\\":\\"sawtooth\\"}", + "0/1 -> 2/1: {\\"note\\":\\"c2\\",\\"s\\":\\"sawtooth\\"}", +] +`; + +exports[`renders tunes > tune: csoundTest2 1`] = ` +[ + "0/1 -> 511525/2531369: {\\"note\\":\\"D3\\"}", + "-1/4 -> -1508319/10125476: {\\"note\\":\\"Bb3\\"}", + "1/4 -> 4577469/10125476: {\\"note\\":\\"F3\\"}", + "0/1 -> 511525/5062738: {\\"note\\":\\"F4\\"}", + "1/2 -> 3554419/5062738: {\\"note\\":\\"C4\\"}", + "-1/4 -> -1508319/10125476: {\\"note\\":\\"A4\\"}", + "1/4 -> 3554419/10125476: {\\"note\\":\\"A4\\"}", + "1/4 -> 3554419/10125476: {\\"note\\":\\"A4\\"}", + "3/4 -> 9640207/10125476: {\\"note\\":\\"E4\\"}", +] +`; + +exports[`renders tunes > tune: csoundTest3 1`] = ` +[ + "0/1 -> 1/1: {\\"note\\":\\"D3\\"}", + "-1/4 -> 1/4: {\\"note\\":\\"Bb3\\"}", + "1/4 -> 5/4: {\\"note\\":\\"F3\\"}", + "0/1 -> 1/2: {\\"note\\":\\"F4\\"}", + "1/2 -> 3/2: {\\"note\\":\\"C4\\"}", + "-1/4 -> 1/4: {\\"note\\":\\"A4\\"}", + "1/4 -> 3/4: {\\"note\\":\\"A4\\"}", + "1/4 -> 3/4: {\\"note\\":\\"A4\\"}", + "3/4 -> 7/4: {\\"note\\":\\"E4\\"}", +] +`; + +exports[`renders tunes > tune: csoundTest4 1`] = ` +[ + "0/1 -> 2/1: {\\"note\\":\\"B3\\",\\"gain\\":0.5}", + "0/1 -> 2/1: {\\"note\\":\\"D4\\",\\"gain\\":0.5}", + "0/1 -> 2/1: {\\"note\\":\\"E4\\",\\"gain\\":0.5}", + "0/1 -> 2/1: {\\"note\\":\\"G4\\",\\"gain\\":0.5}", + "0/1 -> 2/1: {\\"note\\":\\"c2\\",\\"s\\":\\"sawtooth\\",\\"cutoff\\":800,\\"resonance\\":10,\\"shape\\":0.3}", + "0/1 -> 2/1: {\\"note\\":36.1,\\"s\\":\\"sawtooth\\",\\"cutoff\\":800,\\"resonance\\":10,\\"shape\\":0.3}", +] +`; + exports[`renders tunes > tune: delay 1`] = ` [ "0/1 -> 1/2: {\\"s\\":\\"bd\\",\\"delay\\":0,\\"delaytime\\":0.16,\\"delayfeedback\\":0.8,\\"speed\\":-1}",