diff --git a/engine/Engine_Phonotype.sc b/engine/Engine_Phonotype.sc index 1dd710d..16a511d 100644 --- a/engine/Engine_Phonotype.sc +++ b/engine/Engine_Phonotype.sc @@ -32,6 +32,11 @@ Engine_Phonotype : CroneEngine { }; }; + + 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("", { 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/phonotype.sc b/engine/phonotype.sc index 45c5ad3..09a7f8c 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), @@ -1555,6 +1557,7 @@ PT { this.initBusses(ctx); this.initBeats(ctx); this.initPoly(ctx); + ctx['PAUSE'] = PTPauseOp.new(server); if (out_proxy == nil, { out_proxy = NodeProxy.new(server, \audio, 2); @@ -1579,6 +1582,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| @@ -1647,7 +1651,7 @@ PT { }; stream << "\n"; } - } + } setFadeTime { |script, index, time| scripts[script].setFadeTime(index, time); @@ -1786,4 +1790,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 index 3c1b9a5..abb1119 100644 --- a/engine/poly.sc +++ b/engine/poly.sc @@ -229,6 +229,33 @@ PTMidiOp : PTOp { } } +PTCrowOut : PTOp { + + *new { + ^super.newCopyArgs("CROW", 3); + } + + rate { |args, resources| + ^\control; + } + + instantiate { |args, resources| + var iargs = PTOp.instantiateAll(args); + var t = iargs[0]; + // n is crow output # + var n = iargs[1]; + // v is voltage v + var v = iargs[2]; + // s is slew ... hardcoded for now + var s = 0.01; + + ^SendReply.kr(t, "/crow/out", values: [n, s, v]); + // FIXME: does this need to latch? + //^Latch.kr(args[2], args[1]); + } +} + + PTPolyArgCaptureOp : PTOp { var orgIdx, minVal, maxVal, index; @@ -473,4 +500,4 @@ PTPauseOp : PTOp { resources[1].ar; }); } -} \ No newline at end of file +} diff --git a/engine/rhythm.sc b/engine/rhythm.sc index 44f9226..1ae5be1 100644 --- a/engine/rhythm.sc +++ b/engine/rhythm.sc @@ -211,4 +211,4 @@ PTEveryOp : PTOp { }); ^b.kr; } -} \ No newline at end of file +} diff --git a/phonotype.lua b/phonotype.lua old mode 100644 new mode 100755 index d6ed562..82f4e25 --- a/phonotype.lua +++ b/phonotype.lua @@ -1,8 +1,8 @@ -- PHONOTYPE -- v0.2 @sixolet -- https://llllllll.co/t/phonotype-code-a-sound/49564 --- --- phonotype exists between +-- +-- phonotype exists between -- keyboard and speaker -- -- Plug a computer keyboard @@ -16,24 +16,24 @@ -- In scene description Alt+Enter saves -- Choose scene from params menu to load -- Shift+Alt+Esc loads a fresh scene --- +-- -- Mini tutorial --- Try --- SIN 440 --- in M. --- +-- Try +-- SIN 440 +-- in M. +-- -- Then on the next --- line put +-- line put -- * IT PERC QN .5 -- (QN = quarter notes. -- .5 is our env decay) --- +-- -- Now add -- + IT * .5 DEL.F IT * .75 M 3 -- DEL.F is a delay w/ feedback -- we delay by a dotted eigth -- with a 3s decay. --- +-- -- Then go back -- to the first line. -- Hit ctrl-enter to get @@ -115,7 +115,7 @@ function BasicModel:as_string(script) if self.scripts[script] == nil then return "" end - + return table.concat(self.scripts[script], "\n") end @@ -230,7 +230,7 @@ function PTModel:enter() -- moved here so we can use it when pasting, cutting, e elseif editing == "" then model:remove(editing_script, edit_row) moved_line = true - -- Anticipates that the "next" row will become this one, but + -- Anticipates that the "next" row will become this one, but -- we should stay highlighting this editing = model:get(editing_script, edit_row+1) model:to_line(edit_row) @@ -303,7 +303,7 @@ function init() param_spec) params:set_action(param_id, function(x) engine.set_param(i, x) end) end - + params:add_group("buffers", 48) local buf_size_spec = controlspec.def{ min=64, @@ -337,23 +337,22 @@ function init() _menu.rebuild_params() end) end - + midi_device = {} -- container for connected midi devices midi_device_names = {} target = 1 for i = 1,#midi.vports do -- query all ports midi_device[i] = midi.connect(i) -- connect each device - local full_name = + local full_name = table.insert(midi_device_names,"port "..i..": "..util.trim_string_to_width(midi_device[i].name,40)) -- register its name end - + params:add_option("midi target", "midi target",midi_device_names,1) params:set_action("midi target", midi_target) 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) - params:read(1) params:bang() sync_routine = clock.run(sync_every_beat) @@ -393,7 +392,7 @@ function process_midi(data) if retrigger then engine.set_param(20, 0) end - + engine.set_param(20, 1) -- gate on elseif d.type == "note_off" then active_notes[d.note] = false @@ -646,13 +645,13 @@ function osc_in(path, args, from) end model.scripts[script_num] = split_lines(script_contents) - + -- If we just loaded a shorter script... if edit_row > 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] @@ -670,6 +669,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 crow_output = args[1] + local slew = args[2] + local volts = args[3] + -- if crow_is_connected then + print("crow output", crow_output, slew, volts) + crow.output[crow_output].slew = slew + crow.output[crow_output].volts = volts + -- end + else + print(path) end end