From dbc04d8f1cbcfdd53716d748b2e333192addd654 Mon Sep 17 00:00:00 2001 From: zzsnzmn Date: Thu, 16 Dec 2021 08:17:41 +0700 Subject: [PATCH 01/12] beep bop --- README.md | 27 ++++++- engine/Engine_Phonotype.sc | 22 ++++++ engine/busses.sc | 34 +++++++++ engine/phonotype.sc | 55 ++++++++++---- engine/poly.sc | 145 +++++++++++++++++++++++++++++++------ engine/rhythm.sc | 2 +- phonotype.lua | 68 +++++++++++------ 7 files changed, 292 insertions(+), 61 deletions(-) mode change 100644 => 100755 engine/Engine_Phonotype.sc mode change 100644 => 100755 engine/poly.sc mode change 100644 => 100755 phonotype.lua diff --git a/README.md b/README.md index 2f5e605..98ab601 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ It is like Teletype but for sound. Useful for: -* Custom midi (mono, for now) synths +* Custom midi synths * Effects chains of your dreams * Fluid live-coding, changing the control flow as you go * An entire dang modular in this box yo @@ -293,6 +293,31 @@ For example, this is a LFO-modulated drone of the first six partials of a low A: L.MIX 1 6: * UNI RRAMP I / SIN * 110 I I ``` +`MIDI.1 : ` - Not quite monophonic MIDI + +`MIDI.2 : ` - 2 note polyphony + +`MIDI.4 : ` - 4 note polyphony + +`MIDI.6 : ` - 6 note polyphony + +`MIDI.8 : ` - 8 note polyphony + +Within ``, you can use `F`, `G`, and `V` to refer to the frequency, +gate, and velocity of the particular voice, and you can find the voice number (0 +through number of voices) as `I`, in case you want to make each voice distinct +in your poly synth. + +PHONOTYPE will actually initialize one additional voice to allow one note to +decay as it is being replaced. We use a voice-stealing allocator, and the voice +we recycle is whichever is *nearest in frequency* to the newly allocated note. + +For supercollider nerds: I wrote some code to pause the group when a voice isn't +in use. I hope it works to decrease the baseline CPU of this thing and early +experimental evidence is that it does somewhat on my laptop, though of course if +you're playing every voice it'll use all that CPU. The cost is that detecting +the silence to pause the voice itself isn't free. + ### Filters `LPF ` - Low pass filter diff --git a/engine/Engine_Phonotype.sc b/engine/Engine_Phonotype.sc old mode 100644 new mode 100755 index 0c609d2..2f8b9f3 --- a/engine/Engine_Phonotype.sc +++ b/engine/Engine_Phonotype.sc @@ -32,6 +32,17 @@ Engine_Phonotype : CroneEngine { }; }; + + // does this auto wire things together? where should the OSCdef live? + OSCdef(\scCrowOut, { |msg| + PTDbg << "calling oscdef crow out:"; + PTDbg << msg; + luaOscAddr.sendMsg("/crow/out", msg[3].asFloat, msg[4].asFloat, msg[5].asFloat); + //luaOscAddr.sendMsg("/crow/out", msg[0], msg[1], msg[3].asFloat, msg[4].asFloat, msg[5].asFloat]); + //luaOscAddr.sendMsg("/crow/out", msg[0]); + },"/crow/out"); + + // :/ pt = PT.new(context.server); pt.load("", { @@ -101,6 +112,17 @@ Engine_Phonotype : CroneEngine { PTVoiceAllocator.deliverNoteOff(msg[1].asInt, msg[2].asInt, msg[3].asFloat); }); + this.addCommand("note_bend", "iiff", { arg msg; + PTVoiceAllocator.deliverNoteBend(msg[1].asInt, msg[2].asInt, msg[3].asFloat, msg[4].asFloat); + }); + + this.addCommand("crow_out", "iff", { arg msg; + // msg: [output, slew, volts] + //luaOscAddr.sendMsg("/crow/out", msg[1].asInt, msg[2].asFloat, msg[3].asFloat); + // How to notify the sc server to call the \scCrowOut OSCdef? + SendReply.kr(\scCrowOut, "/crow/out", [msg[1].asInt, msg[2].asFloat, msg[3].asFloat]); + }); + this.addCommand("quant", "iiii", { arg msg; var prevQuant = pt.getQuant(msg[2].asInt, msg[3].asInt); var prevQuantIndex = if(prevQuant < 1, {((-1 / prevQuant) + 2).round}, {prevQuant.round}); diff --git a/engine/busses.sc b/engine/busses.sc index 8f39007..02f8eae 100644 --- a/engine/busses.sc +++ b/engine/busses.sc @@ -36,6 +36,40 @@ PTBusOp : PTOp { } } +PTDynBusOp : PTOp { + var rate, symbol, min, max; + + *new { |name, rate, symbol, min, max| + ^super.newCopyArgs(name, 0, rate, symbol, min, max); + } + + min { |args, resources| + ^min; + } + + max { |args, resources| + ^max; + } + + alloc { + ^[nil]; + } + + commit { |args, resources, group, dynCtx| + PTDbg << "Storing away dynamic bus num for " << symbol << " " << dynCtx[symbol] << "\n"; + resources[0] = dynCtx[symbol]; + } + + instantiate { |args, resources| + ^if (rate == \audio) { + In.ar(resources[0], 1); + } { + In.kr(resources[0], 1); + } + } + +} + PTBusSendOp : PTOp { var rate, busses; diff --git a/engine/phonotype.sc b/engine/phonotype.sc index 822822c..422aa13 100644 --- a/engine/phonotype.sc +++ b/engine/phonotype.sc @@ -83,9 +83,9 @@ PTOp { } // commit runs as part of a Routine; it can yield. - commit { |args, resources, group| + commit { |args, resources, group, dynCtx| args.do { |a| - a.commit(group); + a.commit(group, dynCtx); } } @@ -134,8 +134,8 @@ PTNode { ^op.max(args, resources); } - commit { |group| - op.commit(args, resources, group); + commit { |group, dynCtx| + op.commit(args, resources, group, dynCtx); } set { |key, value| @@ -186,6 +186,7 @@ PTParser { "IN" -> PTInOp.new(), "PI" -> PTConst.new("PI", pi), "SIN" -> PTOscOp.new("SIN", 1, SinOsc, SinOsc), + "CROW" -> PTCrowOut.new("CROW", 1), "PSIN" -> PTOscOpPhase("PSIN", 2, SinOsc, SinOsc), "TRI" -> PTOscOp.new("TRI", 1, VarSaw, VarSaw), "VSAW" -> PTOscOpWidth.new("VSAW", 2, VarSaw, VarSaw), @@ -350,9 +351,9 @@ PTParser { var elt; var subctx = ( I: PTConst.new("I", i), - G: PTArgOp.new("G", \g, \control, 0, 1, channels: 1), - F: PTArgOp.new("F", \freq, \control, 20, 20000, channels: 1, initValue: 20), - V: PTArgOp.new("V", \velocity, \control, 0, 1, channels: 1, initValue: 1), + G: PTDynBusOp.new("G", \control, \gate, 0, 1), + F: PTDynBusOp.new("F", \control, \freq, 20, 20000), + V: PTDynBusOp.new("V", \control, \velocity, 0, 1), ); subctx.parent = ctx; elt = this.parseHelper(tokens, 0, subctx); @@ -363,6 +364,18 @@ PTParser { ^(end -> newNode); } + parseCrow { |preTokens, tokens, ctx| + var end, newNode, channel, results, freq, crow; + PTDbg << "Parsing crow " << preTokens << "\n"; + freq = this.parseHelper(preTokens, 1, ctx); + PTDbg << freq; + crow = ctx[preTokens[0].asSymbol]; + + // TODO: PTNode? + newNode = PTNode.new(crow, results, ctx['callSite']); + ^(end -> newNode); + } + parse { |str, context=nil| var ctx = context ? (callSite: nil); var s = if ( (str == nil) || (str == ""), {"IT"}, {str}); @@ -392,6 +405,10 @@ PTParser { a = this.parseMidi(preTokens, tokens, ctx); end = a.key; } + {preTokens[0].beginsWith("CROW") && ctx.includesKey(preTokens[0].asSymbol)} { + a = this.parseCrow(preTokens, tokens, ctx); + end = a.key; + } {true} { PTParseError.new("Unknown PRE: " ++ preTokens[0]).throw; }; @@ -927,7 +944,7 @@ PTScriptNet { PTDbg.complex; if (entry.newNode != nil, { PTDbg << "Committing new node " << entry.newNode << "\n"; - entry.newNode.commit; + entry.newNode.commit(parentGroup, dynCtx: ()); PTDbg << "Scheduling for free " << entry.node << " because we have " << entry.newNode << "\n"; freeNodes.add(entry.node); timeToFree = max(timeToFree, entry.timeToFree); @@ -1037,11 +1054,11 @@ PTScriptOp : PTOp { ^[net]; } - commit { |args, resources, group| + commit { |args, resources, group, dynCtx| var net = resources[0]; - PTDbg << "Committing args " << args << "\n"; + PTDbg << "Committing args " << args << " context " << dynCtx.size << "\n"; args.do { |a| - a.commit(group); + a.commit(group, dynCtx); }; PTDbg << "Committing net from op " << net.id << "\n"; net.commit(group).do { |w| w.yield }; @@ -1541,18 +1558,27 @@ PT { } initPoly { |ctx| - ctx['MIDI.2'] = PTMidiOp.new("MIDI.4", server, 3); + ctx['MIDI.1'] = PTMidiOp.new("MIDI.2", server, 2); + ctx['MIDI.2'] = PTMidiOp.new("MIDI.2", server, 3); ctx['MIDI.4'] = PTMidiOp.new("MIDI.4", server, 5); ctx['MIDI.6'] = PTMidiOp.new("MIDI.6", server, 7); + ctx['MIDI.8'] = PTMidiOp.new("MIDI.6", server, 9); ctx['STRUM.4'] = PTStrumOp.new(server, 4); } + // initCrow { |ctx| + // TODO: this doesn't do anything + //ctx['CROW.OUT.1'] = PTCrowOutOp.new("CROW.OUT.1", 440) // what other args? + // } + init { this.reset; ctx = (); this.initBusses(ctx); this.initBeats(ctx); this.initPoly(ctx); + // this.initCrow(ctx); + ctx['PAUSE'] = PTPauseOp.new(server); if (out_proxy == nil, { out_proxy = NodeProxy.new(server, \audio, 2); @@ -1577,6 +1603,7 @@ PT { scripts.add(description); main = PTScriptNet.new(server: server, parser: parser, lines: [], args: [PTNode.new(PTInOp.new, [], nil)], script: scripts[numScripts-1]); + } loadBuffer { |i, size, filepath| @@ -1645,7 +1672,7 @@ PT { }; stream << "\n"; } - } + } setFadeTime { |script, index, time| scripts[script].setFadeTime(index, time); @@ -1784,4 +1811,4 @@ PT { consonants, vowels, consonants].collect({ |x| x.choose })); } -} \ No newline at end of file +} diff --git a/engine/poly.sc b/engine/poly.sc old mode 100644 new mode 100755 index 02ff28f..f1b540d --- a/engine/poly.sc +++ b/engine/poly.sc @@ -1,7 +1,7 @@ // This file contains code for Phonotype's polyphony support, such as it is. PTVoiceAllocator { - var model:script_size(editing_script) + 1 then edit_row = model:script_size(editing_script) + 1 edit_col = 1 end - + redraw() elseif path == "/save" then local text = args[1] @@ -659,6 +670,17 @@ function osc_in(path, args, from) params:set("scene", full_filename) print("Wrote", full_filename) err_line = filename + elseif path == "/crow/out" then + local output = args[1] + local slew = args[2] + local volts = args[3] + -- if crow_is_connected then + print("crow output", output, slew, volts) + crow.output[output].slew = slew + crow.output[output].volts = volts + -- end + else + print(path) end end From 107901ee248d185a5d86c026e264232e6ac2a5ac Mon Sep 17 00:00:00 2001 From: zzsnzmn Date: Thu, 16 Dec 2021 08:43:41 +0700 Subject: [PATCH 02/12] whoopsies --- phonotype.lua | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/phonotype.lua b/phonotype.lua index 74bc67d..fd5f689 100755 --- a/phonotype.lua +++ b/phonotype.lua @@ -1,13 +1,8 @@ -- PHONOTYPE -- v0.2 @sixolet -- https://llllllll.co/t/phonotype-code-a-sound/49564 -<<<<<<< HEAD --- --- phonotype exists between -======= -- -- phonotype exists between ->>>>>>> crow-osc -- keyboard and speaker -- -- Plug a computer keyboard @@ -358,11 +353,6 @@ function init() params:add_binary("retrigger", "retrigger","toggle", 1) params:set_action("retrigger", function (x) retrigger = x end) params:add_number("bend_range", "bend range", 1, 48, 2) -<<<<<<< HEAD - -======= - ->>>>>>> crow-osc params:read(1) params:bang() sync_routine = clock.run(sync_every_beat) From 91176e3f4f02765e5e5c76d3b78991604a26d0fa Mon Sep 17 00:00:00 2001 From: zzsnzmn Date: Thu, 16 Dec 2021 09:16:06 +0700 Subject: [PATCH 03/12] Make `CROW ` work. --- engine/ops.sc | 2 +- engine/poly.sc | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/engine/ops.sc b/engine/ops.sc index 0fe4de5..da823a4 100644 --- a/engine/ops.sc +++ b/engine/ops.sc @@ -1240,4 +1240,4 @@ PTCrushOp : PTOp { var f = PTCrushOp.foldval(args[1].instantiate); ^SmoothDecimator.ar(args[0].instantiate, f); } -} \ No newline at end of file +} diff --git a/engine/poly.sc b/engine/poly.sc index f1b540d..bfe55d0 100755 --- a/engine/poly.sc +++ b/engine/poly.sc @@ -231,7 +231,7 @@ PTMidiOp : PTOp { PTCrowOut : PTOp { // - var server, index, frequency; + var server, index, frequency, iargs, v; *new { |name, server| ^super.newCopyArgs("CROW", 1, server); @@ -251,11 +251,12 @@ PTCrowOut : PTOp { instantiate { |args, resources| // should SendReply happen here? - PTDbg << "crow out args, resources\n"; - PTDbg << args; - PTDbg << resources; - - ^SendReply.kr(Impulse.kr(0), "/crow/out", values: [1, 2, 3]); + //PTDbg << "crow out args, resources\n"; + //PTDbg << args; + //PTDbg << resources; + var iargs = PTOp.instantiateAll(args); + var v = iargs[0]; + ^SendReply.kr(Impulse.kr(0), "/crow/out", values: [1, 0.01, v]); } // TODO: do we need a commit method? From bc30efb438e6adbef4d5e53df8f9aca358b8dfd7 Mon Sep 17 00:00:00 2001 From: zzsnzmn Date: Thu, 16 Dec 2021 10:09:00 +0700 Subject: [PATCH 04/12] Add multiple outputs. --- engine/phonotype.sc | 13 +++++++------ engine/poly.sc | 17 +++++------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/engine/phonotype.sc b/engine/phonotype.sc index 422aa13..6491d9e 100644 --- a/engine/phonotype.sc +++ b/engine/phonotype.sc @@ -186,7 +186,6 @@ PTParser { "IN" -> PTInOp.new(), "PI" -> PTConst.new("PI", pi), "SIN" -> PTOscOp.new("SIN", 1, SinOsc, SinOsc), - "CROW" -> PTCrowOut.new("CROW", 1), "PSIN" -> PTOscOpPhase("PSIN", 2, SinOsc, SinOsc), "TRI" -> PTOscOp.new("TRI", 1, VarSaw, VarSaw), "VSAW" -> PTOscOpWidth.new("VSAW", 2, VarSaw, VarSaw), @@ -1566,10 +1565,12 @@ PT { ctx['STRUM.4'] = PTStrumOp.new(server, 4); } - // initCrow { |ctx| - // TODO: this doesn't do anything - //ctx['CROW.OUT.1'] = PTCrowOutOp.new("CROW.OUT.1", 440) // what other args? - // } + initCrow { |ctx| + ctx['CROW.OUT.1'] = PTCrowOut.new("CROW.OUT.1", 1); + ctx['CROW.OUT.2'] = PTCrowOut.new("CROW.OUT.2", 2); + ctx['CROW.OUT.3'] = PTCrowOut.new("CROW.OUT.3", 3); + ctx['CROW.OUT.4'] = PTCrowOut.new("CROW.OUT.4", 4); + } init { this.reset; @@ -1577,7 +1578,7 @@ PT { this.initBusses(ctx); this.initBeats(ctx); this.initPoly(ctx); - // this.initCrow(ctx); + this.initCrow(ctx); ctx['PAUSE'] = PTPauseOp.new(server); if (out_proxy == nil, { diff --git a/engine/poly.sc b/engine/poly.sc index bfe55d0..242c547 100755 --- a/engine/poly.sc +++ b/engine/poly.sc @@ -230,11 +230,10 @@ PTMidiOp : PTOp { } PTCrowOut : PTOp { - // - var server, index, frequency, iargs, v; + var output, frequency; - *new { |name, server| - ^super.newCopyArgs("CROW", 1, server); + *new { |name, output| + ^super.newCopyArgs(name, 1, output); } rate { |args, resources| @@ -246,20 +245,14 @@ PTCrowOut : PTOp { } max { |args, resources| - ^1; + ^4; } instantiate { |args, resources| - // should SendReply happen here? - //PTDbg << "crow out args, resources\n"; - //PTDbg << args; - //PTDbg << resources; var iargs = PTOp.instantiateAll(args); var v = iargs[0]; - ^SendReply.kr(Impulse.kr(0), "/crow/out", values: [1, 0.01, v]); + ^SendReply.ar(Impulse.ar(0), "/crow/out", values: [output, 0.01, v]); } - // TODO: do we need a commit method? - } From 0427123d7dbdfcf9d2f148358f93606b57496c0d Mon Sep 17 00:00:00 2001 From: zzsnzmn Date: Thu, 16 Dec 2021 10:22:27 +0700 Subject: [PATCH 05/12] Remove unused command and introduce var for crowOSCOut. --- engine/Engine_Phonotype.sc | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/engine/Engine_Phonotype.sc b/engine/Engine_Phonotype.sc index 2f8b9f3..e855fe3 100755 --- a/engine/Engine_Phonotype.sc +++ b/engine/Engine_Phonotype.sc @@ -34,15 +34,10 @@ Engine_Phonotype : CroneEngine { }; // does this auto wire things together? where should the OSCdef live? - OSCdef(\scCrowOut, { |msg| - PTDbg << "calling oscdef crow out:"; - PTDbg << msg; - luaOscAddr.sendMsg("/crow/out", msg[3].asFloat, msg[4].asFloat, msg[5].asFloat); - //luaOscAddr.sendMsg("/crow/out", msg[0], msg[1], msg[3].asFloat, msg[4].asFloat, msg[5].asFloat]); - //luaOscAddr.sendMsg("/crow/out", msg[0]); + var crowOSCOut = OSCdef(\scCrowOut, { |msg| + luaOscAddr.sendMsg("/crow/out", msg[3].asInt, msg[4].asFloat, msg[5].asFloat); },"/crow/out"); - // :/ pt = PT.new(context.server); pt.load("", { @@ -116,13 +111,6 @@ Engine_Phonotype : CroneEngine { PTVoiceAllocator.deliverNoteBend(msg[1].asInt, msg[2].asInt, msg[3].asFloat, msg[4].asFloat); }); - this.addCommand("crow_out", "iff", { arg msg; - // msg: [output, slew, volts] - //luaOscAddr.sendMsg("/crow/out", msg[1].asInt, msg[2].asFloat, msg[3].asFloat); - // How to notify the sc server to call the \scCrowOut OSCdef? - SendReply.kr(\scCrowOut, "/crow/out", [msg[1].asInt, msg[2].asFloat, msg[3].asFloat]); - }); - this.addCommand("quant", "iiii", { arg msg; var prevQuant = pt.getQuant(msg[2].asInt, msg[3].asInt); var prevQuantIndex = if(prevQuant < 1, {((-1 / prevQuant) + 2).round}, {prevQuant.round}); From cd180936ba4f6ab35c923678e1aa68a440cafbc6 Mon Sep 17 00:00:00 2001 From: zzsnzmn Date: Thu, 16 Dec 2021 11:08:23 +0700 Subject: [PATCH 06/12] Address PR review and make CROW.V n v --- engine/phonotype.sc | 13 ++----------- engine/poly.sc | 24 ++++++++++-------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/engine/phonotype.sc b/engine/phonotype.sc index 6491d9e..a18c803 100644 --- a/engine/phonotype.sc +++ b/engine/phonotype.sc @@ -238,6 +238,8 @@ PTParser { "LEAP" -> PTLeapOp.new, "COUNT" -> PTCountOp.new, + "CROW.V" -> PTCrowOut.new, + "CDIV" -> PTFilterOp.new("CDIV", 2, PulseDivider), "DUR" -> PT01DelegatedOp("DUR", 2, Trig1), "PROB" -> PT01DelegatedOp("PROB", 2, CoinGate), @@ -365,9 +367,6 @@ PTParser { parseCrow { |preTokens, tokens, ctx| var end, newNode, channel, results, freq, crow; - PTDbg << "Parsing crow " << preTokens << "\n"; - freq = this.parseHelper(preTokens, 1, ctx); - PTDbg << freq; crow = ctx[preTokens[0].asSymbol]; // TODO: PTNode? @@ -1565,20 +1564,12 @@ PT { ctx['STRUM.4'] = PTStrumOp.new(server, 4); } - initCrow { |ctx| - ctx['CROW.OUT.1'] = PTCrowOut.new("CROW.OUT.1", 1); - ctx['CROW.OUT.2'] = PTCrowOut.new("CROW.OUT.2", 2); - ctx['CROW.OUT.3'] = PTCrowOut.new("CROW.OUT.3", 3); - ctx['CROW.OUT.4'] = PTCrowOut.new("CROW.OUT.4", 4); - } - init { this.reset; ctx = (); this.initBusses(ctx); this.initBeats(ctx); this.initPoly(ctx); - this.initCrow(ctx); ctx['PAUSE'] = PTPauseOp.new(server); if (out_proxy == nil, { diff --git a/engine/poly.sc b/engine/poly.sc index 242c547..f432abc 100755 --- a/engine/poly.sc +++ b/engine/poly.sc @@ -230,28 +230,24 @@ PTMidiOp : PTOp { } PTCrowOut : PTOp { - var output, frequency; - *new { |name, output| - ^super.newCopyArgs(name, 1, output); + *new { + ^super.newCopyArgs("CROW", 2); } rate { |args, resources| - ^\audio; - } - - min { |args, resources| - ^0; - } - - max { |args, resources| - ^4; + ^\control; } instantiate { |args, resources| var iargs = PTOp.instantiateAll(args); - var v = iargs[0]; - ^SendReply.ar(Impulse.ar(0), "/crow/out", values: [output, 0.01, v]); + // n is crow output # + var n = iargs[0]; + // v is voltage v + var v = iargs[1]; + // s is slew ... hardcoded for now + var s = 0.01; + ^SendReply.kr(Impulse.kr(0), "/crow/out", values: [n, s, v]); } } From c5e09daca8c97deb2ccd43a30688eed5a59da7c0 Mon Sep 17 00:00:00 2001 From: zzsnzmn Date: Thu, 16 Dec 2021 11:09:18 +0700 Subject: [PATCH 07/12] Fix filemode from borked smb share. --- engine/Engine_Phonotype.sc | 0 engine/poly.sc | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 engine/Engine_Phonotype.sc mode change 100755 => 100644 engine/poly.sc diff --git a/engine/Engine_Phonotype.sc b/engine/Engine_Phonotype.sc old mode 100755 new mode 100644 diff --git a/engine/poly.sc b/engine/poly.sc old mode 100755 new mode 100644 From ba009d0f3989355cb7160128852b4577f012de74 Mon Sep 17 00:00:00 2001 From: zzsnzmn Date: Thu, 16 Dec 2021 11:10:04 +0700 Subject: [PATCH 08/12] Remove comment for OSCdef. --- engine/Engine_Phonotype.sc | 1 - 1 file changed, 1 deletion(-) diff --git a/engine/Engine_Phonotype.sc b/engine/Engine_Phonotype.sc index e855fe3..16a511d 100644 --- a/engine/Engine_Phonotype.sc +++ b/engine/Engine_Phonotype.sc @@ -33,7 +33,6 @@ Engine_Phonotype : CroneEngine { }; - // does this auto wire things together? where should the OSCdef live? var crowOSCOut = OSCdef(\scCrowOut, { |msg| luaOscAddr.sendMsg("/crow/out", msg[3].asInt, msg[4].asFloat, msg[5].asFloat); },"/crow/out"); From 44dac33a3f2ce0011a2f86514651d5d77cfacdae Mon Sep 17 00:00:00 2001 From: zzsnzmn Date: Thu, 16 Dec 2021 11:15:03 +0700 Subject: [PATCH 09/12] Remove parseCrow. --- engine/phonotype.sc | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/engine/phonotype.sc b/engine/phonotype.sc index a18c803..09a7f8c 100644 --- a/engine/phonotype.sc +++ b/engine/phonotype.sc @@ -365,15 +365,6 @@ PTParser { ^(end -> newNode); } - parseCrow { |preTokens, tokens, ctx| - var end, newNode, channel, results, freq, crow; - crow = ctx[preTokens[0].asSymbol]; - - // TODO: PTNode? - newNode = PTNode.new(crow, results, ctx['callSite']); - ^(end -> newNode); - } - parse { |str, context=nil| var ctx = context ? (callSite: nil); var s = if ( (str == nil) || (str == ""), {"IT"}, {str}); @@ -403,10 +394,6 @@ PTParser { a = this.parseMidi(preTokens, tokens, ctx); end = a.key; } - {preTokens[0].beginsWith("CROW") && ctx.includesKey(preTokens[0].asSymbol)} { - a = this.parseCrow(preTokens, tokens, ctx); - end = a.key; - } {true} { PTParseError.new("Unknown PRE: " ++ preTokens[0]).throw; }; From 7f8e1db87a3f6523b1bf21dd3060207c49f5f171 Mon Sep 17 00:00:00 2001 From: zzsnzmn Date: Tue, 19 Apr 2022 18:00:38 -0500 Subject: [PATCH 10/12] Shift args forward to allow for a trigger t. --- engine/poly.sc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/engine/poly.sc b/engine/poly.sc index f432abc..b447043 100644 --- a/engine/poly.sc +++ b/engine/poly.sc @@ -241,13 +241,14 @@ PTCrowOut : PTOp { instantiate { |args, resources| var iargs = PTOp.instantiateAll(args); + var t = iargs[0]; // n is crow output # - var n = iargs[0]; + var n = iargs[1]; // v is voltage v - var v = iargs[1]; + var v = iargs[2]; // s is slew ... hardcoded for now var s = 0.01; - ^SendReply.kr(Impulse.kr(0), "/crow/out", values: [n, s, v]); + ^SendReply.kr(t, "/crow/out", values: [n, s, v]); } } From 8c61351436fed19c2728e162ffdb8eb5e0ad0737 Mon Sep 17 00:00:00 2001 From: David Sutton Date: Tue, 19 Apr 2022 18:25:07 -0500 Subject: [PATCH 11/12] Latch the output voltage and crow #. --- engine/poly.sc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engine/poly.sc b/engine/poly.sc index b447043..5739f85 100644 --- a/engine/poly.sc +++ b/engine/poly.sc @@ -248,7 +248,9 @@ PTCrowOut : PTOp { var v = iargs[2]; // s is slew ... hardcoded for now var s = 0.01; - ^SendReply.kr(t, "/crow/out", values: [n, s, v]); + + SendReply.kr(t, "/crow/out", values: [n, s, v]); + ^Latch.kr(v, n); } } From fd93dc57efc8f679a1ba3ed70375b1a6351988a0 Mon Sep 17 00:00:00 2001 From: zzsnzmn Date: Thu, 21 Apr 2022 08:17:29 +0700 Subject: [PATCH 12/12] 'yield' (is that right?) the SendReply. --- engine/poly.sc | 7 ++++--- phonotype.lua | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/engine/poly.sc b/engine/poly.sc index 5739f85..abb1119 100644 --- a/engine/poly.sc +++ b/engine/poly.sc @@ -232,7 +232,7 @@ PTMidiOp : PTOp { PTCrowOut : PTOp { *new { - ^super.newCopyArgs("CROW", 2); + ^super.newCopyArgs("CROW", 3); } rate { |args, resources| @@ -249,8 +249,9 @@ PTCrowOut : PTOp { // s is slew ... hardcoded for now var s = 0.01; - SendReply.kr(t, "/crow/out", values: [n, s, v]); - ^Latch.kr(v, n); + ^SendReply.kr(t, "/crow/out", values: [n, s, v]); + // FIXME: does this need to latch? + //^Latch.kr(args[2], args[1]); } } diff --git a/phonotype.lua b/phonotype.lua index fd5f689..82f4e25 100755 --- a/phonotype.lua +++ b/phonotype.lua @@ -670,13 +670,13 @@ function osc_in(path, args, from) print("Wrote", full_filename) err_line = filename elseif path == "/crow/out" then - local output = args[1] + local crow_output = args[1] local slew = args[2] local volts = args[3] -- if crow_is_connected then - print("crow output", output, slew, volts) - crow.output[output].slew = slew - crow.output[output].volts = volts + print("crow output", crow_output, slew, volts) + crow.output[crow_output].slew = slew + crow.output[crow_output].volts = volts -- end else print(path)