From 5727c0dc8a1166a7dbc68c80e59fbb9ed2af3eba Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Thu, 1 Dec 2022 14:56:50 +0100 Subject: [PATCH] clean up tunes + also load presets.orc --- packages/csound/csound.mjs | 7 +- packages/csound/{sounds.orc => presets.orc} | 21 +++++ .../test/__snapshots__/tunes.test.mjs.snap | 14 ++++ repl/src/tunes.mjs | 84 +------------------ 4 files changed, 41 insertions(+), 85 deletions(-) rename packages/csound/{sounds.orc => presets.orc} (66%) diff --git a/packages/csound/csound.mjs b/packages/csound/csound.mjs index 657310e9..3e698b55 100644 --- a/packages/csound/csound.mjs +++ b/packages/csound/csound.mjs @@ -1,8 +1,8 @@ import { getFrequency, logger, Pattern } from '@strudel.cycles/core'; import { getAudioContext } from '@strudel.cycles/webaudio'; import csd from './project.csd?raw'; -import orc from './livecode.orc?raw'; -// import orc from './sounds.orc?raw'; +import livecodeOrc from './livecode.orc?raw'; +import presetsOrc from './presets.orc?raw'; let csoundLoader, _csound; @@ -76,7 +76,8 @@ async function load() { await _csound.setOption('-m0'); // see -m flag https://csound.com/docs/manual/CommandFlags.html await _csound.setOption('--sample-accurate'); await _csound.compileCsdText(csd); - await _csound.compileOrc(orc); + await _csound.compileOrc(livecodeOrc); + await _csound.compileOrc(presetsOrc); await _csound.start(); return _csound; } diff --git a/packages/csound/sounds.orc b/packages/csound/presets.orc similarity index 66% rename from packages/csound/sounds.orc rename to packages/csound/presets.orc index 9bba7e01..b75122d5 100644 --- a/packages/csound/sounds.orc +++ b/packages/csound/presets.orc @@ -1,3 +1,4 @@ +; TODO add incredibly dope synths instr organ iduration = p3 ifreq = p4 @@ -37,4 +38,24 @@ instr triangle asig *= linsegr:a(0, iattack, 1, iduration, 1, irelease, 0) out(asig, asig) +endin + +instr pad + iduration = p3 + ifreq = p4 + igain = p5 + ioct = octcps(ifreq) + + asig = vco2(igain, ifreq, 0) + + ; amp envelope + iattack = .5 + irelease = .1 + asig *= linsegr:a(0, iattack, 1, iduration, 1, irelease, 0) + + idepth = 2 + acut = transegr:a(0, .005, 0, idepth, .06, -4.2, 0.001, .01, -4.2, 0) + asig = zdf_2pole(asig, 1000, 2) + + out(asig, asig) endin \ No newline at end of file diff --git a/repl/src/test/__snapshots__/tunes.test.mjs.snap b/repl/src/test/__snapshots__/tunes.test.mjs.snap index 864a9ba7..6f3cc298 100644 --- a/repl/src/test/__snapshots__/tunes.test.mjs.snap +++ b/repl/src/test/__snapshots__/tunes.test.mjs.snap @@ -1409,6 +1409,20 @@ exports[`renders tunes > tune: chop 1`] = ` ] `; +exports[`renders tunes > tune: csoundDemo 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: csoundMixed 1`] = ` [ "2/3 -> 3/4: {\\"note\\":58.95209612324834,\\"gain\\":1}", diff --git a/repl/src/tunes.mjs b/repl/src/tunes.mjs index c65224e8..cf839ead 100644 --- a/repl/src/tunes.mjs +++ b/repl/src/tunes.mjs @@ -992,62 +992,7 @@ export const juxUndTollerei = `note("c3 eb3 g3 bb3").palindrome() .delay(.5).delaytime(.1).delayfeedback(.4) .pianoroll()`; -export const csoundTest = `await csound\` -instr sawtooth - iduration = p3 - ifreq = p4 - igain = p5 - ioct = octcps(ifreq) - - asig = vco2(igain, ifreq, 0) - - ; amp envelope - iattack = .5 - irelease = .1 - asig *= linsegr:a(0, iattack, 1, iduration, 1, irelease, 0) - - idepth = 2 - acut = transegr:a(0, .005, 0, idepth, .06, -4.2, 0.001, .01, -4.2, 0) - asig = zdf_2pole(asig, 1000, 2) - - out(asig, asig) -endin\` - -stack( - note("/2".voicings()).s('sawtooth'), - note("/2").s('sawtooth') -) -.csound('sawtooth')`; - -export const csoundTest2 = `await csound\` -instr organ - iduration = p3 - ifreq = p4 - igain = p5 - ioct = octcps(ifreq) - - kpwm = oscili(.5, 2) - asig = vco2(igain, ifreq, 4, .5 + kpwm) - asig += vco2(igain/4, ifreq * 2) - - iattack = .01 - irelease = .005 - asig *= linsegr:a(0, iattack, 1, iduration, 0, irelease, 0) - - out(asig, asig) -endin\` - -"<0 2 [4 6](3,4,1) 3*2>" -.off(1/4, add(2)) -.off(1/2, add(6)) -.scale('D minor') -.legato(perlin.range(.2,2).slow(8)) -// .echo(4, 1/8, .5) -.note() -.pianoroll() -.csound('organ');`; - -export const csoundTest3 = `await csound\` +export const csoundDemo = `await csound\` instr CoolSynth iduration = p3 ifreq = p4 @@ -1077,29 +1022,4 @@ endin\` .scale('D minor') .note() //.pianoroll() -.csound("/4")`; - -export const csoundTest4 = `await csound() - -stack( - note("/2".voicings()).csound('organ').gain(.5), - note("/2".superimpose(add(.1))).s('sawtooth').cutoff(800).resonance(10).shape(.3) -)`; - -export const csoundMixed = `await csound() - -stack( - "/2".voicings() - .add(rand.range(-.1,.1)).note() - .csound('organ').gain(1).struct("[~@2 x]*2").legato(.25) - , - "/2" - .superimpose(add(rand.range(-.1,.1))).note() - .s('sawtooth').cutoff(perlin.range(200,500)).resonance(10) - .struct("x(4,6,1) x(5,6,2)") - .decay(.1).sustain(0) - , - s("bd*2,hh:1(4,6),[~ sd]/2") - .room(.5) - .speed(perlin.range(.9,1.1).slow(4)) -).slow(2)`; +.csound("/4")`;