Skip to content
5 changes: 5 additions & 0 deletions engine/Engine_Phonotype.sc
Original file line number Diff line number Diff line change
Expand Up @@ -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("", {
Expand Down
2 changes: 1 addition & 1 deletion engine/ops.sc
Original file line number Diff line number Diff line change
Expand Up @@ -1240,4 +1240,4 @@ PTCrushOp : PTOp {
var f = PTCrushOp.foldval(args[1].instantiate);
^SmoothDecimator.ar(args[0].instantiate, f);
}
}
}
8 changes: 6 additions & 2 deletions engine/phonotype.sc
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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);
Expand All @@ -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|
Expand Down Expand Up @@ -1647,7 +1651,7 @@ PT {
};
stream << "\n";
}
}
}

setFadeTime { |script, index, time|
scripts[script].setFadeTime(index, time);
Expand Down Expand Up @@ -1786,4 +1790,4 @@ PT {
consonants, vowels, consonants].collect({ |x| x.choose }));
}

}
}
29 changes: 28 additions & 1 deletion engine/poly.sc
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,33 @@ PTMidiOp : PTOp {
}
}

PTCrowOut : PTOp {

*new {
^super.newCopyArgs("CROW", 3);
}

rate { |args, resources|
Comment thread
zzsnzmn marked this conversation as resolved.
^\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;

Expand Down Expand Up @@ -473,4 +500,4 @@ PTPauseOp : PTOp {
resources[1].ar;
});
}
}
}
2 changes: 1 addition & 1 deletion engine/rhythm.sc
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,4 @@ PTEveryOp : PTOp {
});
^b.kr;
}
}
}
50 changes: 30 additions & 20 deletions phonotype.lua
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -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

Expand Down