Browse files

almost finished refactoring main.sc

  • Loading branch information...
1 parent f3c231e commit fcb07133c565065ae2d6129bb8a99bef56758fe6 @grirgz committed Oct 29, 2011
Showing with 1,889 additions and 1,191 deletions.
  1. +4 −4 TODO
  2. +4 −4 crap.sc
  3. +85 −49 editplayer.sc
  4. +345 −0 hmatrix.sc
  5. +222 −8 keycode.sc
  6. +1 −1 live5.sc
  7. +231 −0 live7.sc
  8. +340 −0 main.sc
  9. +2 −7 matrix.sc
  10. +90 −77 mixer.sc
  11. +3 −0 player.sc
  12. +501 −0 sccode.sc
  13. +61 −52 seqpanel.sc → score.sc
  14. +0 −989 seco.sc
View
8 TODO
@@ -1,10 +1,10 @@
Important
=====================
-- fix adsr midi edit
-- add a record midi notes mode
+//- fix adsr midi edit
+//- add a record midi notes mode
- enable copy/link of groupnodes
-- add a general mixer board
+//- add a general mixer board
- add livenode and groupnode effects
Others
@@ -32,7 +32,7 @@ Can wait
- modulation wheel
- value knob
- enable modifiying a whole seq line with knobs
-- rework the editplayer interface to separate params (like amp and legato)
+//- rework the editplayer interface to separate params (like amp and legato)
- fix make_libnode_from_patfun (broken)
- add make_libnode_from_instr
- add an abstraction layer between midi hardware and seco
View
8 crap.sc
@@ -317,16 +317,16 @@ SynthDef(\addbeeps, { arg out=0, gate=1;
(
var a;
a = Pbind(\degree, Prand((0..7),12), \dur, 0.3, \legato, 0.2);
-a = Pfxb(a, \echo, \dtime, 0.2, \decay, 3);
-a = Pfxb(a, \addbeeps);
+a = Pfx(a, \echo, \dtime, 0.2, \decay, 3);
+a = Pfx(a, \addbeeps);
a.play;
)
(
var a;
a = Pbind(\degree, Prand((0..7),12), \dur, 0.3, \legato, 0.2);
-a = Pfxb(a, \addbeeps);
-a = Pfxb(a, \echo, \dtime, 0.2, \decay, 3);
+a = Pfx(a, \addbeeps);
+a = Pfx(a, \echo, \dtime, 0.2, \decay, 3);
a.play;
)
View
134 editplayer.sc
@@ -1,27 +1,19 @@
(
-~set_numpad_mode = { arg kb_handler, fun;
- var buf = "", save = Dictionary.new, restore, special = [\enter, \point, \escape];
+~set_numpad_mode = { arg commands, fun;
+ var buf = "", restorefun;
- //save
- ~kbnumpad.do { arg kc, i; save[i] = kb_handler[[0, kc]] };
- special.do { arg i; save[i] = kb_handler[[0, ~kbspecial[i]]] };
+ restorefun = commands.overload_mode([\editplayer, \edit_value_mode]);
- restore = {
- ~kbnumpad.do { arg kc, i; kb_handler[[0, kc]] = save[i] };
- special.do { arg i; kb_handler[[0, ~kbspecial[i]]] = save[i]; }
- };
-
- // enable
- ~kbnumpad.do { arg kc, i; kb_handler[[0, kc]] = {
+ commands.array_set_action([\editplayer, \edit_value_mode, \insert_number], 10, { arg i;
+ [buf, i, i.asString].debug("ibuf");
buf = buf ++ i.asString;
- } };
- kb_handler[[0, ~kbspecial.point]] = { buf = buf ++ "." };
- kb_handler[[0, ~kbspecial.escape]] = { restore.() };
- kb_handler[[0, ~kbspecial.enter]] = {
- restore.();
- fun.(buf);
- };
+ [buf, i, i.asString].debug("buf");
+ });
+ commands.set_action([\editplayer, \edit_value_mode, \insert_point], { buf = buf ++ "." });
+ commands.set_action([\editplayer, \edit_value_mode, \cancel], { restorefun.() });
+ commands.set_action([\editplayer, \edit_value_mode, \ok], { restorefun.(); [buf, i, i.asString].debug("ok buf"); fun.(buf) });
+
};
@@ -419,7 +411,7 @@
txt_midi_label = GUI.staticText.new(midibloc, Rect(0,0,15,height));
txt_midi_val = GUI.staticText.new(midibloc, Rect(0,0,75,height));
- slider = GUI.knob.new(midibloc, Rect(0,0,30,height));
+ slider = GUI.slider.new(midibloc, Rect(0,0,30,height));
},{
// spacer
txt_midi_val = GUI.staticText.new(row_layout, Rect(0,0,30,height));
@@ -569,8 +561,13 @@
selected: { arg self;
bt_name.value = display.selected;
},
+ selected_cell: { arg self;
+ param.changed(\cells);
+ },
cells: { arg self, msg, cellidx;
+
+ param.get_val.debug("simplecontrol val");
txtval.string = param.get_val;
}
@@ -638,7 +635,7 @@
txt_midi_label = GUI.staticText.new(midibloc, Rect(0,0,15,height));
txt_midi_val = GUI.staticText.new(midibloc, Rect(0,0,75,height));
- slider = GUI.knob.new(midibloc, Rect(0,0,30,height));
+ slider = GUI.slider.new(midibloc, Rect(0,0,30,height));
},{
// spacer
txt_midi_val = GUI.staticText.new(row_layout, Rect(0,0,30,height));
@@ -887,6 +884,8 @@
//param.debug("make_midi_control.unblock_do param");
cc_value = get_midi_val.();
param_value = param.get_norm_val.();
+ param.name.debug("midi unblock param name");
+ param_value.debug("midi unblock param value");
switch(self.blocked,
\not, fun,
@@ -913,6 +912,8 @@
cc_value = get_midi_val.();
param_value = param.get_norm_val.();
+ param.name.debug("midi block param name");
+ param_value.debug("midi block param value");
case
{ cc_value > param_value } {
@@ -1240,9 +1241,12 @@
};
-~make_editplayer = { arg main, player, parent, kb_handler;
- var ep;
+~make_editplayer = { arg main, parent;
+ var ep, player;
"============making editplayer".debug;
+ player = main.panels.parlive.get_selected_cell;
+ player.debug("editplayer:player");
+
ep = (
player: player,
model: (
@@ -1400,7 +1404,8 @@
)},
- init: { arg editplayer, player, parent, kb_handler;
+
+ init: { arg editplayer, player, parent;
var param_order = editplayer.model.param_status_group ++ editplayer.model.param_order, selected;
"========== init editplayer ============".debug;
@@ -1443,53 +1448,73 @@
// kb shotcuts
- ~kbnumline.do { arg kc, i; kb_handler[[0, kc]] = {
+ main.commands.matrix_add_enable([\parlive, \select_cell], [\kb, 0], ~keycode.kbpad8x4, { arg x, y; editplayer.set_selection(x,y) });
+ main.commands.array_add_enable([\parlive, \change_bank], [\kb, 0], ~keycode.kbnumpad, { arg x; editplayer.set_bank(x) });
+ main.commands.add_enable([\parlive, \load_libnode], [\kb, ~keycode.mod.fx, ~keycode.kbfx[0]], { editplayer.load_libnode });
+
+ main.commands.array_add_enable([\editplayer, \select_cell], [\kb, 0], ~keycode.kbnumline, { arg i;
editplayer.controller.select_cell((player.get_bank*editplayer.model.max_cells)+i)
- } };
+ });
+ // edit value mode
- kb_handler[[0, ~kbspecial.enter]] = {
+ main.commands.add_enable([\editplayer, \edit_value], [\kb, 0, ~keycode.kbspecial.enter], {
var sel = editplayer.controller.get_selected_param;
sel.name.debug("voici le nom!");
case
{ editplayer.model.param_field_group.includes(sel.name)} {
- ~set_numpad_mode.(kb_handler, { arg val;
+ ~set_numpad_mode.(main.commands, { arg val;
if(val.interpret.isNumber, { sel.set_val(val.interpret); sel.changed(\cells) });
});
}
{ sel.name == \bufnum || sel.name.asString.containsStringAt(0,"bufnum_")} {
~choose_sample.(main, { arg buf, w; sel.set_val(buf); w.debug("window").close })
};
- };
+ });
+ main.commands.array_set_shortcut([\editplayer, \edit_value_mode, \insert_number], [\kb, 0], ~keycode.kbnumpad);
+ main.commands.set_shortcut([\editplayer, \edit_value_mode, \insert_point], [\kb, 0, ~keycode.kbspecial.point]);
+ main.commands.set_shortcut([\editplayer, \edit_value_mode, \cancel], [\kb, 0, ~keycode.kbspecial.escape]);
+ main.commands.set_shortcut([\editplayer, \edit_value_mode, \ok], [\kb, 0, ~keycode.kbspecial.enter]);
+
+ //
- ~kbnumline.do { arg kc, i; kb_handler[[~modifiers.ctrl, kc]] = {
+ main.commands.array_add_enable([\editplayer, \select_param], [\kb, ~keycode.mod.ctrl], ~keycode.kbnumline, { arg i;
editplayer.controller.select_param(i);
- } };
+ });
+
+ main.commands.array_add_enable([\editplayer, \select_simple_param], [\kb, ~keycode.mod.alt], ~keycode.kbnumline, { arg i;
+ editplayer.controller.select_param(i+editplayer.get_param_offset)
+ });
- ~kbnumline.do { arg kc, i; kb_handler[[~modifiers.alt, kc]] = { editplayer.controller.select_param(i+editplayer.get_param_offset) } };
- kb_handler[[~modifiers.alt, ~kbaalphanum["a"]]] = { editplayer.controller.change_kind(\seq) };
- kb_handler[[~modifiers.alt, ~kbaalphanum["s"]]] = { editplayer.controller.change_kind(\scalar) };
+ main.commands.add_enable([\editplayer, \set_seq_kind], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["a"]], {
+ editplayer.controller.change_kind(\seq)
+ });
+ main.commands.add_enable([\editplayer, \set_scalar_kind], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["s"]], {
+ editplayer.controller.change_kind(\scalar)
+ });
// noteline
- kb_handler[[~modifiers.alt, ~kbaalphanum["n"]]] = {
+ main.commands.add_enable([\editplayer, \set_noteline_mode], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["n"]], {
player.set_noteline(true);
editplayer.changed(\paramlist);
- };
- kb_handler[[~modifiers.alt, ~kbaalphanum["b"]]] = {
+ });
+
+ main.commands.add_enable([\editplayer, \unset_noteline_mode], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["b"]], {
player.set_noteline(false);
editplayer.changed(\paramlist);
- };
+ });
//~prec = ~piano_recorder.value(player); // debile
- kb_handler[[~modifiers.alt, ~kbaalphanum["r"]]] = {
+ main.commands.add_enable([\editplayer, \start_recording], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["r"]], {
"STARTRECORD!!".debug;
player.get_arg(\noteline).midi.start_recording.();
player.get_arg(\noteline).midi.changed(\recording);
- };
- kb_handler[[~modifiers.alt, ~kbaalphanum["t"]]] = {
+ });
+
+ main.commands.add_enable([\editplayer, \stop_recording], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["t"]], {
var sum = 0;
var midi = player.get_arg(\noteline).midi;
midi.stop_recording.();
@@ -1502,27 +1527,38 @@
sum.debug("total sum");
player.get_arg(\noteline).notes = midi.track;
player.get_arg(\noteline).changed(\notes);
- };
+ });
// cells
- kb_handler[[0, ~numpad.plus]] = { editplayer.controller.add_cell_bar.() };
- kb_handler[[~modifiers.ctrl, ~numpad.plus]] = { editplayer.controller.remove_cell_bar.() };
+ main.commands.add_enable([\editplayer, \add_cell_bar], [\kb, 0, ~keycode.numpad.plus], {
+ editplayer.controller.add_cell_bar.()
+ });
+ main.commands.add_enable([\editplayer, \remove_cell_bar], [\kb, ~keycode.mod.ctrl, ~keycode.numpad.plus], {
+ editplayer.controller.remove_cell_bar.()
+ });
- ~kbnumpad.do { arg keycode, idx;
- kb_handler[[0, keycode]] = { player.set_bank(idx) };
- };
+ main.commands.array_add_enable([\editplayer, \change_bank], [\kb, 0], ~keycode.kbnumpad, { arg idx; player.set_bank(idx) });
+ // playing
+
+ main.commands.add_enable([\editplayer, \play_selected], [\kb, ~keycode.mod.fx, ~keycode.kbfx[4]], { player.node.play });
+ main.commands.add_enable([\editplayer, \stop_selected], [\kb, ~keycode.mod.fx, ~keycode.kbfx[5]], { player.node.stop });
+
+ // change panel
+
+ main.commands.add_enable([\editplayer, \show_panel, \parlive], [\kb, ~keycode.mod.fx, ~keycode.kbfx[8]], { main.show_panel(\parlive) });
+ main.commands.add_enable([\editplayer, \show_panel, \mixer], [\kb, ~keycode.mod.fx, ~keycode.kbfx[9]], { main.show_panel(\mixer) });
+ main.commands.add_enable([\editplayer, \show_panel, \score], [\kb, ~keycode.mod.fx, ~keycode.kbfx[10]], { main.show_panel(\score) });
// make view
~make_editplayer_view.(parent, editplayer, player, param_order);
}
);
- ep.init(player, parent, kb_handler);
+ ep.init(player, parent);
ep;
};
)
-
View
345 hmatrix.sc
@@ -0,0 +1,345 @@
+(
+
+~make_cell = { arg parent, label;
+ var bt;
+
+ bt = GUI.button.new(parent, Rect(50,50,200,30));
+ bt.states = [
+ [ label, Color.black, Color.white],
+ [ label, Color.white, Color.black],
+ ];
+ bt.value = 0;
+ bt;
+
+};
+~make_header_cell = { arg parent, label;
+ var bt;
+
+ bt = GUI.button.new(parent, Rect(50,50,200,30));
+ bt.states = [
+ [ label, Color.black, ~color_scheme.header_cell],
+ [ label, Color.white, Color.black],
+ ];
+ bt.value = 0;
+ bt;
+
+};
+
+~set_cell_label = { arg cell, label;
+ var val;
+ val = cell.value;
+ cell.states = [
+ [ label, Color.black, Color.white],
+ [ label, Color.white, Color.black],
+ ];
+ cell.value = val;
+};
+
+~in_range = { arg datalist, address;
+ if(address.isNil, {
+ false;
+ }, {
+ ((address.bank * 32) + (address.x * 4) + address.y) < datalist.size
+ })
+};
+
+~in_line_range = { arg datalist, address;
+ if(address.isNil, {
+ false;
+ }, {
+ ((address.bank * 8) + (address.x)) < datalist.size
+ })
+};
+
+~node_column_view = { arg parent, controller;
+
+ var layout, ps_col_layout, curbank, address;
+ var width = 1350;
+
+ layout = GUI.vLayoutView.new(parent, Rect(0,0,(160),60*6));
+ layout.background = ~editplayer_color_scheme.control;
+
+ //parent.view.background = ~editplayer_color_scheme.background;
+ ~make_view_responder.(layout, controller, (
+
+ redraw: { arg obj, msg, header, datalist;
+ var cell;
+ controller.debug("rederaw column");
+ //datalist.debug("==========================datalist");
+ layout.removeAll;
+ //layout.focus(true);
+ cell = ~make_header_cell.(layout, header);
+ datalist.do { arg node;
+
+ ~make_cell.(layout, node.name);
+ }
+ },
+
+ header_label: { arg obj, msg, val;
+ ~set_cell_label.(layout.children[0], val)
+ },
+
+ cell_label: { arg obj, msg, x, val;
+ ~set_cell_label.(layout.children[x+1], val)
+ },
+
+ header_selection: { arg obj, msg, selected;
+ layout.children[0].value = selected;
+ },
+
+ cell_selection: { arg obj, msg, x, selected;
+ layout.children[x+1].value = selected;
+ }
+
+ ));
+ controller.changed(\redraw, controller.name, controller.children);
+};
+
+~hmatrix_view = { arg parent, controller;
+
+ var sl_layout, ps_col_layout, curbank, address;
+ var width = 1350;
+
+ sl_layout = GUI.hLayoutView.new(parent, Rect(0,0,width,60*6));
+ sl_layout.background = ~editplayer_color_scheme.background;
+
+ //parent.view.background = ~editplayer_color_scheme.background;
+ ~make_view_responder.(sl_layout, controller, (
+
+ redraw: { arg obj, msg, datalist;
+ //controller.model.debug("rederaw hmatrix");
+ "".debug("rederaw hmatrix");
+ datalist = controller.model.datalist;
+ //datalist.debug("==========================datalist");
+ sl_layout.removeAll;
+ //sl_layout.focus(true);
+ datalist.size.debug("datalist size");
+ controller.model.bank.debug("bank");
+ //~node_column_view.(sl_layout, datalist[0]);
+ datalist[(controller.model.bank*8)..(((controller.model.bank+1)*8)-1)].do { arg node;
+ ~node_column_view.(sl_layout, node);
+ };
+ parent.focus(true);
+
+ }
+
+ ))
+};
+
+~empty_player = (
+ name: \void,
+ kind: \player
+);
+
+~make_empty_parnode = {(
+
+ children: SparseArray.newClear(8, ~empty_player),
+ kind: \parnode,
+ name: \void
+
+)};
+
+
+~make_parlive = { arg main;
+
+ var obj;
+
+ obj = (
+
+ model: (
+ //samplelist: {arg i; "sounds/default" ++ i }!50,
+ //patlist: main.model.patlist,
+ datalist: (8*9).collect( ~make_empty_parnode),
+ selection: (x:0, y:0, bank:0),
+ bank: 0,
+ offset: 0@0
+ ),
+
+ kb_handler: Dictionary.new,
+
+ address_to_index: { arg self, ad;
+ (ad.bank * 32) + (ad.x * 4) + ad.y;
+ },
+
+ refresh: { arg self;
+ var sel = self.model.selection;
+ self.changed(\redraw);
+ sel.debug("refresh sel");
+ if(sel.notNil, {
+ if(sel.bank == self.model.bank, {
+ self.set_selection(sel.x, sel.y);
+ });
+ });
+ },
+
+ set_bank: { arg self, idx;
+ idx.debug("set bank");
+ self.model.bank = idx;
+ self.refresh;
+ },
+
+ set_datalist: { arg self, datalist;
+ self.model.datalist = datalist;
+ self.model.selection = nil;
+ self.refresh;
+ },
+
+ get_cell_by_address: { arg self, ad;
+ if(ad.y == -1, {
+ self.model.datalist[ (ad.bank * 8) + ad.x];
+ }, {
+ self.model.datalist[ (ad.bank * 8) + ad.x].children[ad.y];
+ })
+ },
+
+ get_selected_cell: { arg self;
+ self.get_cell_by_address(self.model.selection)
+ },
+
+ set_selection: { arg self, x, y;
+ var sel, oldsel;
+ sel = (
+ x: x,
+ y: y,
+ bank: self.model.bank
+ );
+ "set_selection:sel".debug(sel);
+ if(
+ (((sel.bank * 8) + (sel.x)) < self.model.datalist.size)
+ && { self.model.datalist[sel.bank*8 + sel.x].notNil }
+ && { sel.y < self.model.datalist[sel.bank*8 + sel.x].children.size }
+ ,{
+ oldsel = self.model.selection;
+ self.model.selection = sel;
+ if(oldsel.notNil, {
+ if(oldsel.y == -1, {
+ self.model.datalist[oldsel.bank*8 + oldsel.x].changed(\header_selection, 0);
+ }, {
+ self.model.datalist[oldsel.bank*8 + oldsel.x].changed(\cell_selection, oldsel.y, 0);
+ });
+ });
+ if(sel.y == -1, {
+ self.model.datalist[sel.bank*8 + sel.x].changed(\header_selection, 1);
+ }, {
+ self.model.datalist[sel.bank*8 + sel.x].changed(\cell_selection, sel.y, 1);
+ });
+ });
+ },
+
+ set_cell: { arg self, address, val;
+ var name;
+ name = if(val.isNil, { "" }, {val.name});
+ if(address.y == -1, {
+ self.model.datalist[ address.bank * 8 + address.x ] = val;
+ self.changed(\cell_label, address.x, name);
+ }, {
+ self.model.datalist[ address.bank * 8 + address.x ].children[address.y] = val;
+ self.model.datalist[ address.bank * 8 + address.x ].changed(\cell_label, address.y, name);
+ });
+ },
+
+
+ play_selected: { arg self;
+ self.get_selected_cell.node.play
+ },
+
+ stop_selected: { arg self;
+ self.get_selected_cell.node.stop
+ },
+
+ make_livenodename_from_libnodename: { arg self, name;
+ // TODO: handle name collision
+ name++"_l"++UniqueID.next;
+
+ },
+
+ make_newlivenodename_from_livenodename: { arg self, name;
+ // TODO: make it real
+ name[ .. name.findBackwards("_l") ] ++ "l" ++ UniqueID.next;
+ },
+
+ make_livenode_from_libnode: { arg self, libnodename;
+ var livenodename;
+ var player;
+ livenodename = self.make_livenodename_from_libnodename(libnodename);
+ player = ~make_player.(main.model.patpool[libnodename]);
+ player.name = livenodename;
+ player;
+ },
+
+ duplicate_livenode: { arg self, livenodename;
+ var newlivenodename, newlivenode, newlivenode_pdict;
+ newlivenodename = self.make_newlivenodename_from_livenodename(livenodename);
+ newlivenodename.debug("newlivenodename");
+ livenodename.debug("livenodename");
+ self.model.livenodepool.debug("livenodepool");
+ self.model.livenodepool[newlivenodename] = self.model.livenodepool[livenodename].clone;
+ self.model.livenodepool[newlivenodename].name = newlivenodename;
+ newlivenodename;
+ },
+
+ load_libnode: { arg self;
+ var livenode;
+ if(self.model.selection.y == -1, {
+ "Can't load libnode in header".error;
+ }, {
+ ~choose_libnode.(main, { arg libnodename;
+ livenode = self.make_livenode_from_libnode(libnodename);
+ self.set_cell(self.model.selection, livenode)
+ });
+ })
+ },
+
+ stop_all: { arg self;
+ self.model.datalist.do { arg i; i.node.stop };
+ },
+
+ delete_node: { arg self;
+ var livenode;
+ if(self.model.selection.y == -1, {
+ "Can't delete node in header".error;
+ }, {
+ self.set_cell(self.model.selection, nil)
+ })
+
+ },
+
+ make_gui: { arg self, parent;
+ ~hmatrix_view.(parent, self);
+ },
+
+ init: { arg self;
+ var parent;
+
+ //self.model.datalist[8*9] = nil;
+ //self.model.datalist.debug("patlist");
+ main.commands.matrix_add_enable([\parlive, \select_cell], [\kb, 0], ~keycode.kbpad8x4, { arg x, y; self.set_selection(x,y) });
+ main.commands.array_add_enable([\parlive, \select_header], [\kb, ~keycode.mod.alt], ~keycode.kbnumline[..7], { arg x; self.set_selection(x,-1) });
+
+ main.commands.array_add_enable([\parlive, \change_bank], [\kb, 0], ~keycode.kbnumpad, { arg x; self.set_bank(x) });
+
+ main.commands.add_enable([\parlive, \load_libnode], [\kb, ~keycode.mod.fx, ~keycode.kbfx[0]], { self.load_libnode });
+ main.commands.add_enable([\parlive, \delete_node], [\kb, ~keycode.mod.fx, ~keycode.kbfx[2]], { self.delete_node });
+
+ main.commands.add_enable([\parlive, \play_selected], [\kb, ~keycode.mod.fx, ~keycode.kbfx[4]], { self.play_selected });
+ main.commands.add_enable([\parlive, \stop_selected], [\kb, ~keycode.mod.fx, ~keycode.kbfx[5]], { self.stop_selected });
+ main.commands.add_enable([\parlive, \stop_all], [\kb, ~keycode.mod.fx, ~keycode.kbfx[7]], { self.stop_all });
+
+
+
+ main.commands.add_enable([\parlive, \show_panel, \mixer], [\kb, ~keycode.mod.fx, ~keycode.kbfx[9]], { main.show_panel(\mixer) });
+ main.commands.add_enable([\parlive, \show_panel, \score], [\kb, ~keycode.mod.fx, ~keycode.kbfx[10]], { main.show_panel(\score) });
+ main.commands.add_enable([\parlive, \show_panel, \editplayer], [\kb, ~keycode.mod.fx, ~keycode.kbfx[11]], { main.show_panel(\editplayer) });
+
+ }
+
+ );
+ obj.init;
+ obj;
+
+};
+
+)
+
+
+
View
230 keycode.sc
@@ -121,27 +121,164 @@
dico;
}.value;
+
+
+
+~keycode = Environment.make({
+ ~kbpad8x4 = [
+ [ 38, 233, 34, 39, 40, 45, 232, 95 ],
+ [97, 122, 101, 114, 116, 121, 117, 105 ],
+ [113, 115, 100, 102, 103, 104, 106, 107 ],
+ [119, 120, 99, 118, 98, 110, 44, 59 ]
+ ];
+ ~kbpad8x4_flat = ~kbpad8x4.flat;
+ ~kbcalphanum = {
+ var dict = Dictionary.new;
+ //TODO: only for Ctrl (262144) modifier, do others
+ //NOTE: ^W close the window
+ var keycodes = [
+ [ 38, 233, 34, 39, 40, 45, 232, 31, 231, 224, 41, 61 ],
+ [ 1, 26, 5, 18, 20, 25, 21, 9, 15, 16, 36 ],
+ [ 17, 19, 4, 6, 7, 8, 10, 11, 12, 13, 249, 42],
+ [60, 24, 3, 22, 2, 14, 44, 59, 58, 33] //FIXME: complete keycodes
+ ];
+ var alnum = [
+ "1234567890)=",
+ "azertyuiop^$",
+ "qsdfghjklmù*",
+ "<wxcvbn,;:!"
+ ];
+ keycodes.do { arg row, rowidx;
+ row.do { arg kc, kcidx;
+ dict[ alnum[rowidx][kcidx].asString ] = kc;
+ };
+ };
+ dict;
+ }.value;
+ ~kbaalphanum = {
+ var dict = Dictionary.new;
+ //NOTE: only for Alt and no modifier
+ var keycodes = [
+ [ 38, 233, 34, 39, 40, 45, 232, 31, 231, 224, 41, 61 ],
+ [97, 122, 101, 114, 116, 121, 117, 105, 111,112, 36 /* ^ not working */, 36 ],
+ [113, 115, 100, 102, 103, 104, 106, 107, 108, 109, 249, 42 ],
+ [60, 119, 120, 99, 118, 98, 110, 44, 59 ] //FIXME: complete keycodes
+ ];
+ var alnum = [
+ "1234567890)=",
+ "azertyuiop^$",
+ "qsdfghjklmù*",
+ "<wxcvbn,;:!"
+ ];
+ keycodes.do { arg row, rowidx;
+ row.do { arg kc, kcidx;
+ dict[ alnum[rowidx][kcidx].asString ] = kc;
+ };
+ };
+ dict;
+ }.value;
+ ~kb8x2line = [
+ 38, 97, 233, 122, 34, 101, 39, 114, 40, 166, 45, 121, 232, 117, 95, 105
+ ];
+ ~kbnumline = [
+ 38, 233, 34, 39, 40, 45, 232, 95, 231, 224, 41, 61
+ ];
+ ~kbnumpad = [
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
+ ];
+ ~numpad = (
+ plus: 43,
+ minus: 45
+ );
+ ~mod = (
+ fx: 8388608,
+ ctrlfx: 8650752,
+ ctrl: 262144,
+ shift: 131072,
+ alt: 524288
+ );
+ ~kbfx = [
+ // modifiers = 8388608
+ 63236, 63237, 63238, 63239, 63240, 63241, 63242, 63243, 63244, 63245, 63246, 63247
+ //49,50,51,52,53,54,55,56,57,58
+ ];
+ ~kbarrow = (
+ // modifiers = 8388608
+ left: 63234,
+ right: 63235,
+ up: 63232,
+ down: 63233
+ );
+ ~kbspecial = (
+ delete: 127,
+ enter: 13,
+ escape: 27,
+ point: 46
+ );
+ ~cakewalk = (
+ \knob: [
+ 16,17,18,19, 20,21,22,23, 24
+ ],
+ \button: [
+ 34,35,36,37, 38,39,40,41, 42
+ ],
+ \toggle: [
+ 43,44,45,46
+ ],
+ \slider: [
+ 25,26,27,28, 29,30,31,32, 33
+ ]
+ );
+ ~midi = {
+ var dico = Dictionary.new;
+ ~cakewalk.collect { arg v, k;
+ "v:".postln;
+ v.postln;
+ "k:".postln;
+ k.postln;
+ v.do { arg raw, i;
+ dico[raw] = [k, i];
+ };
+ };
+ dico;
+ }.value;
+}).as(Event);
+
~shortcut = (
kb_handler: Dictionary.new,
midi_handler: Dictionary.new,
actions: MultiLevelIdentityDictionary.new,
config: MultiLevelIdentityDictionary.new,
+ commands: Dictionary.new,
- add: { arg self, path, default_shortcut=nil, action;
+ add_shortcut: { arg self, path, default_shortcut=nil, action;
var shortcut;
self.actions.put(*path++[action]);
- self.config.put(*path ++ [ self.config.at(*path) ?? default_shortcut ]);
+ self.config.put(*path ++ [ self.config.at(*path) ?? default_shortcut ]); //FIXME: why never overwrite shortcut ?
+ },
+
+ set_action: { arg self, path, action;
+ self.actions.put(*path++[action]);
+ if ( self.commands[self.config.at(*path)] == path ) {
+ path.debug("already enabled, so enforce");
+ self.enable(path);
+ };
},
enable: { arg self, path;
- var action, shortcut, panel = path[0];
+ var action, shortcut, panel = path.debug("enablepath")[0];
+ //path.debug("enabling path");
shortcut = self.config.at(*path);
action = self.actions.at(*path);
+ //shortcut.debug("shortcut");
+ //action.debug("action");
if(shortcut.notNil, {
+ self.commands[shortcut] = path;
switch(shortcut[0],
\kb, {
self.kb_handler[panel] = self.kb_handler[panel] ?? Dictionary.new;
self.kb_handler[panel][shortcut] = action;
+ [path, shortcut].debug("path enabled");
},
\midi, {
self.midi_handler[panel] = self.midi_handler[panel] ?? Dictionary.new;
@@ -151,29 +288,106 @@
},
+ disable: { arg self, path;
+ var shortcut, panel = path[0];
+
+ shortcut = self.config.at(*path);
+
+ if(shortcut.notNil, {
+ self.commands[shortcut] = nil;
+ switch(shortcut[0],
+ \kb, {
+ self.kb_handler[panel] = self.kb_handler[panel] ?? Dictionary.new;
+ self.kb_handler[panel][shortcut] = nil;
+ [path, shortcut].debug("path disabled");
+ },
+ \midi, {
+ self.midi_handler[panel] = self.midi_handler[panel] ?? Dictionary.new;
+ self.midi_handler[panel][shortcut] = nil;
+ })
+ })
+
+ },
+
enable_mode: { arg self, path;
self.config.leafDoFrom(path, { arg path, val;
self.enable(path);
});
},
+ overload_mode: { arg self, path;
+ var restorefun=nil;
+ self.commands.debug("overload_mode:commands");
+ self.config.leafDoFrom(path, { arg leafpath, val;
+ var oldpath;
+ oldpath = self.commands[ self.config.at(*leafpath) ];
+ [oldpath, leafpath, self.config.at(*leafpath)].debug("oldpath, path, scap");
+
+ if( oldpath.isNil, {
+ restorefun = restorefun.addFunc({ self.disable(leafpath) });
+ }, {
+ restorefun = restorefun.addFunc({ self.enable(oldpath) });
+ });
+
+ self.enable(leafpath);
+ });
+ restorefun;
+ },
+
add_enable: { arg self, path, default_shortcut=nil, action;
- self.add(path, default_shortcut, action);
+ self.add_shortcut(path, default_shortcut, action);
self.enable(path);
},
+
+ matrix_add_enable: { arg self, path, prefix, matrix, action;
+ matrix.do { arg i, y;
+ i.do { arg j, x;
+ self.add_enable(path++[x,y], prefix ++ [j], { action.(x,y) })
+ };
+ };
+ },
+
+ array_add_enable: { arg self, path, prefix, array, action;
+ array.do { arg i, x;
+ self.add_enable(path++[x], prefix ++ [i], { action.(x) })
+ };
+ },
+
+ array_set_action: { arg self, path, size, action;
+ size.do { arg i;
+ self.set_action(path++[i], { action.(i) })
+ };
+ },
+
+
- change: { arg self, path, shortcut;
+ set_shortcut: { arg self, path, shortcut;
self.config.put(*path++[shortcut]);
},
- get_kb_responder: { arg self, name;
-
+ array_set_shortcut: { arg self, path, prefix, array;
+ array.do { arg i, x;
+ self.set_shortcut(path++[x], prefix ++ [i])
+ };
+ },
+ get_kb_responder: { arg self, name;
+ name.debug("giving panel responder");
+ { arg view, char, modifiers, u, k;
+ [name, modifiers, u].debug("KEYBOARD INPUT");
+ self.handle_key(name, [\kb, modifiers,u]);
+ };
},
handle_key: { arg self, panel, shortcut;
- var fun = self.kb_handler[panel][shortcut];
+ var fun;
+ //self.kb_handler.debug("handle_key: kb_handler");
+ panel.debug("current shortcut panel");
+ self.commands[shortcut].debug("shortcut of path called");
+ fun = self.kb_handler[panel][shortcut];
if(fun.isNil, { nil }, { fun.value; 1 })
};
);
+
+
View
2 live5.sc
@@ -1,6 +1,6 @@
s.boot;
s.exit
-
+Quarks.gui
Buffer.freeAll
(
View
231 live7.sc
@@ -0,0 +1,231 @@
+s.boot
+
+(
+s.waitForBoot({
+"/home/ggz/code/sc/seco/main.sc".loadDocument;
+
+~synthlib = [
+ \sinadsr,
+ \vowel,
+ \kickTrig1,
+ \snTrig1,
+ \boom1,
+ \KSpluck,
+ \KSpluck2,
+ \KSpluck3,
+ \hihat,
+ \loop
+].collect({ arg i; i -> i });
+
+~samplelib = [
+ "sounds/amen-break.wav",
+ "sounds/default.wav"
+];
+
+~seq = ~mk_sequencer.value;
+~seq.load_patlib( ~synthlib );
+~seq.load_samplelib( ~samplelib );
+~seq.make_gui;
+
+});
+)
+
+(
+SynthDef(\formant, { arg out=0, amp=0.1, gate=1, freq=200, formfreq=300, bw=10;
+
+var ou;
+ou = Formant.ar(freq, formfreq, bw);
+ou = ou * Linen.kr(gate, doneAction:2);
+Out.ar(out, ou*amp);
+
+
+}, metadata:(specs:(
+ formfreq: \widefreq.asSpec,
+ bw: \widefreq.asSpec
+))).add;
+
+SynthDef(\formant2, { arg out=0, amp=0.1, gate=1, freq=200, formfreq=300, bandw=10, rq=0.1;
+
+ var ou, ou2;
+ ou = WhiteNoise.ar(1);
+ ou = Mix.fill(4, { arg num;
+ var stack=2;
+ var lou = ou;
+ num = num+1;
+ stack.do ({ arg i;
+ lou = BPF.ar(lou, freq*num, rq);
+ });
+ lou;
+ });
+ ou = ou * Linen.kr(gate, doneAction:2) * 10;
+ Out.ar(out, ou*amp);
+}, metadata:(specs:(
+ formfreq: \freq.asSpec,
+ bandw: \freq.asSpec
+))).add;
+
+SynthDef(\saw, { arg out=0, amp=0.1, gate=1, freq=200, formfreq=300, bw=10;
+
+var ou;
+ou = Saw.ar(freq);
+ou = ou * Linen.kr(gate, doneAction:2);
+Out.ar(out, ou*amp);
+
+
+}).add;
+
+
+SynthDef(\vowel, { arg out=0, amp=0.1, gate=1, freq=200, rqfreq=100, rqoffset=10;
+var env, env2, envf, enva, ou, ou2;
+env = ~make_adsr.(\adsr);
+env2 = ~make_adsr.(\adsr_vowel);
+envf = EnvGen.kr(env2, gate);
+enva = EnvGen.kr(env, gate,doneAction:2);
+ou = Formants.ar(freq, Vowel(\i, \bass).blend(Vowel(\o, \bass), envf + LFNoise0.kr([5,5.1],mul:0.1,add:1).lag(0.1))) ;
+ou = PinkNoise.ar(1)*0.5 + ou;
+ou2 = BPF.ar(ou, freq+LFNoise0.kr([1.12,5.2],1,20*enva).lag(0.1), SinOsc.kr(rqfreq*enva+rqoffset,0,1,4.1))*5;
+ou = Klank.ar(`[[1.1],[0.1],[0.5]],ou,700) + ou2;
+ou = ou*enva*amp;
+Out.ar(out, ou);
+
+}).store;
+
+SynthDef(\sinadsr, {
+ arg out=0, amp=0.1, gate=1, freq=440;
+ var ou;
+ var env, envctl;
+
+ env = Env.adsr(0.02, 0.2, 0.25, 0.1, 1, -4);
+ //env = Env.newClear(6);
+
+ envctl = Control.names([\adsr]).kr( env.asArray );
+ ou = SinOsc.ar( freq);
+ ou = ou * EnvGen.kr(envctl, gate, doneAction:2);
+ Out.ar(out, ou * amp)
+}).store;
+
+SynthDef("kickTrig1", { arg levK=1, t_trig=0, sustain=0.125, f1=36.7, f2=73.4, amp=0.1, out=0;
+ var kEnv, ou;
+ var kickEnv;
+ kickEnv = Env.linen(0.001, 1.9, 0.099, 1);
+ kEnv=EnvGen.ar(kickEnv,1, doneAction:2, timeScale: sustain, levelScale: levK);
+ ou =Pan2.ar(Decay2.kr(t_trig, 0.005, 0.45,
+ FSinOsc.ar(f1, 0.4)+FSinOsc.ar(f2, 0.2)),0);
+
+ Out.ar(out, ou * kEnv * amp);
+}).store;
+SynthDef("snTrig1", { arg levSn=1, t_trig=0, sustain=0.125, panPos=0, amp=0.1,
+ out=0;
+ var snEnv, ou;
+ var snareEnv;
+ snareEnv = Env.linen(0.001, 1.9, 0.099, 1);
+ snEnv=EnvGen.ar(snareEnv,1, doneAction:2, timeScale: sustain, levelScale: levSn);
+ ou =Pan2.ar(Decay2.kr(t_trig, 0.005, 0.25, FSinOsc.ar(38.midicps, 0.3)+ BrownNoise.ar(0.4)),panPos);
+
+ Out.ar(out, ou*snEnv * amp);
+}).store;
+SynthDef("hihat", { arg out=0, amp=0.1, sustain=0.5, freq=440, noise=0.5,
+ at=0.001, rq=1.9;
+ var ou;
+ ou = WhiteNoise.ar(noise);
+ ou = ou * EnvGen.kr(Env.perc(at, sustain),doneAction:2);
+ ou = Resonz.ar(ou, freq, rq);
+
+ Out.ar(out, ou*amp);
+}).store;
+
+
+
+SynthDef("boom1", {
+ arg out=0, t_trig=1, attack=0.005, release=1.25, noise=1, f_base=70,
+ mod=4, range=300, carrier=400, amp=0.1;
+
+ d = Decay2.kr(t_trig, attack, release, BrownNoise.ar(noise)
+ + SinOsc.ar(f_base)
+ + SinOsc.ar(SinOsc.kr(mod,1.0)*range+carrier)
+ );
+ DetectSilence.ar(in: d, amp: 0.001, time: 0.1, doneAction: 2);
+ Out.ar(out,d*amp)
+
+}).store;
+
+SynthDef("perc1", {
+ arg out=0, attack=0.005, release=1.25, lpf=50, bpf=100, bprq=0.1,
+ ratio=4, range=300, carrier=400, amp=0.1;
+ var mid, ou, env;
+
+ mid = SinOsc.ar(SinOsc.ar(carrier*ratio)*range+carrier);
+ mid = BPF.ar(mid, bpf, bprq);
+
+ ou = Klang.ar( `[[50,86,93,136,182],nil,nil] );
+ ou = LPF.ar(ou, lpf);
+ ou = mid + ou;
+
+ env = EnvGen.kr(Env.perc(attack, release), doneAction:2);
+ ou = ou * env * amp;
+
+ Out.ar(out,ou)
+
+}).store;
+
+SynthDef("snare1", {
+ arg out=0, attack=0.005, release=1.25, relratio=0.5, amp=0.1;
+ var mid, ou, ou2, env1, env2;
+
+ ou = LFTri.ar(111);
+ ou = FreqShift.ar(ou, [175, 224]).sum;
+ env1 = EnvGen.ar(Env.perc(attack, release), doneAction:2);
+
+ env2 = EnvGen.ar(Env.perc(attack, release*relratio));
+ ou2 = SinOsc.ar([330,180]).sum*env2;
+
+ ou = ou + ou2;
+ ou = ou * env1 * amp;
+
+
+ Out.ar(out,ou.dup)
+
+}).store;
+
+
+
+SynthDef("KSpluck", { arg freq = 200, delayDecay = 1.0, attack=0.0001, release=0.001, amp=0.1, out=0;
+ var burstEnv, att = attack, dec = release;
+ var signalOut, delayTime;
+ delayTime = [freq, freq * 2].reciprocal;
+ burstEnv = EnvGen.kr(Env.perc(att, dec));
+ signalOut = PinkNoise.ar(burstEnv);
+ signalOut = CombL.ar(signalOut, delayTime, delayTime, delayDecay, add: signalOut);
+ DetectSilence.ar(signalOut, doneAction:2);
+ Out.ar(out, signalOut*amp)
+}).store;
+
+SynthDef("KSpluck3", { arg freq = 200, delayDecay = 1.0, attack=0.1, release=0.1, amp=0.1, out=0;
+ var burstEnv, att = attack, dec = release;
+ var signalOut, delayTime;
+ delayTime = [freq, freq * 2].reciprocal;
+ burstEnv = EnvGen.kr(Env.perc(att, dec));
+ signalOut = PinkNoise.ar(10);
+ signalOut = CombL.ar(signalOut, delayTime, delayTime, delayDecay, add: signalOut);
+ signalOut = signalOut * burstEnv;
+ signalOut = signalOut * amp * 0.1;
+ DetectSilence.ar(signalOut, doneAction:2);
+ Out.ar([0,1], signalOut)
+}).store;
+
+SynthDef("KSpluck2", { arg freq = 200, noise=10, bpratio=0.9, rq=0.1, delayDecay = 1.0, attack=0.1, release=0.1, amp=0.1, out=0;
+ var burstEnv, att = attack, dec = release;
+ var signalOut, delayTime;
+ delayTime = [freq, freq * 2].reciprocal;
+ burstEnv = EnvGen.kr(Env.perc(att, dec));
+ signalOut = WhiteNoise.ar(noise);
+ signalOut = BPF.ar(signalOut, freq*bpratio, rq);
+ signalOut = CombL.ar(signalOut, delayTime, delayTime, [delayDecay, delayDecay*1.0.rand], add: signalOut);
+ signalOut = signalOut * burstEnv;
+ signalOut = signalOut * amp * 0.01;
+ DetectSilence.ar(signalOut, doneAction:2);
+ Out.ar(out, signalOut.dup)
+}).store;
+
+
+)
View
340 main.sc
@@ -0,0 +1,340 @@
+
+~toggle_value = { arg value;
+ if( value.isNil, { value = 0 });
+ ((value+1) % 2);
+};
+
+~toggle_button = { arg button;
+ button.value = ((button.value+1) % 2);
+};
+
+
+~compare_point = { arg a, b;
+ case
+ { a.x == b.x } { a.y < b.y }
+ { a.x < b.x }
+};
+
+
+~prefix_array = { arg prefix, array;
+
+ array.collect { arg e;
+ prefix ++ [e];
+ };
+};
+
+
+~matrix3_from_list = { arg list, collectfun = { arg x; x };
+ var banklist = List[], collist = List[], celllist = List[];
+ var bankidx = 0, colidx = 0, cellidx = 0;
+ list.do { arg asso;
+ if( cellidx >= 4, {
+ if( colidx >= 8, {
+ banklist.add( collist );
+ collist = List[];
+ colidx = 0;
+ bankidx = bankidx + 1;
+ });
+ collist.add( celllist );
+ colidx = colidx + 1;
+ cellidx = 0;
+ celllist = List[];
+ });
+ celllist.add( collectfun.(asso) );
+ cellidx = cellidx + 1;
+ };
+ banklist.add( collist );
+ collist.add( celllist );
+ banklist;
+
+};
+
+~init_controller = { arg controller, messages;
+ messages.keysValuesDo { arg key, val; controller.put(key, val) };
+};
+
+~editplayer_color_scheme = (
+ background: Color.newHex("94A1BA"),
+ control: Color.newHex("6F88BA"),
+ led: Color.newHex("A788BA")
+);
+
+~color_scheme = (
+
+ header_cell: Color.newHex("BBBBA9")
+
+);
+
+~make_view_responder = { arg parent, model, message_responders;
+ var controller;
+
+ controller = SimpleController(model);
+
+ Dictionary.newFrom(message_responders).keysValuesDo { arg key, val;
+ controller.put(key, val)
+ };
+
+ parent.onClose = parent.onClose.addFunc { controller.remove };
+
+ model.refresh()
+};
+
+// ==========================================
+// INCLUDES
+// ==========================================
+
+[
+ "synth",
+ "keycode",
+ "player",
+ "matrix",
+ "hmatrix",
+ "editplayer",
+ "mixer",
+ "score"
+].do { arg file;
+ ("Loading " ++ file ++".sc...").inform;
+ ("/home/ggz/code/sc/seco/"++file++".sc").loadDocument;
+};
+"Done loading.".inform;
+
+
+// ==========================================
+// SEQUENCER FACTORY
+// ==========================================
+
+
+
+
+~main_view = { arg controller;
+
+ var window, sl_layout, ps_col_layout, curbank, address;
+ var width = 1350, height = 800;
+ var parent;
+
+
+ window = GUI.window.new("seq", Rect(50, 50, width, height));
+ window.view.decorator = FlowLayout(window.view.bounds); // notice that FlowView refers to w.view, not w
+ //parent = window;
+
+ sl_layout = GUI.hLayoutView.new(window, Rect(0,0,width,60*6));
+ //parent = window;
+ parent = sl_layout;
+
+ //parent.view.background = ~editplayer_color_scheme.background;
+ ~make_view_responder.(parent, controller, (
+
+ panel: { arg obj, msg, panel;
+ block { arg break;
+ panel.debug("main view: changing to panel");
+ "pan0".debug;
+ if([\seqlive, \parlive].includes(panel), {
+ "pan1".debug;
+ parent.removeAll;
+ controller.panels[panel].make_gui(parent)
+ }, {
+ switch(panel,
+ \mixer, {
+ "pan2".debug;
+ parent.removeAll;
+ ~make_mixer.(controller, parent);
+ "pan2,5".debug;
+ },
+ \editplayer, {
+ if (controller.panels.parlive.get_selected_cell.name == \void) {
+ "FORBIDDEN: can't edit empty player".inform;
+ break.value
+ };
+ "pan3".debug;
+ parent.removeAll;
+ ~make_editplayer.(controller, parent);
+ },
+ \score, {
+ "pan4".debug;
+ parent.removeAll;
+ ~make_score.(controller, parent);
+ }
+ )
+ });
+ "pan5".debug;
+ window.view.keyDownAction = controller.commands.get_kb_responder(panel);
+ "pan6".debug;
+ }
+ }
+ ));
+ window.front;
+
+};
+
+~make_context = { arg main;
+
+ var context;
+ context = (
+ parbank: 0,
+ seqbank: 0,
+ spacekind: \par, // par, seq
+ selected_node: ~make_empty_parnode.(),
+
+ get_selected_node: { arg self;
+ self.selected_node;
+ },
+
+ get_selected_node_set: { arg self;
+ switch(self.spacekind,
+ \par, {
+ //main.panels.parlive.model.datalist.debug("context:get_selected_node_set:datalist"); // FIXME: hardcoded values
+ main.panels.parlive.model.datalist[(self.parbank*8)..][..11]; // FIXME: hardcoded values
+ },
+ \seq, {
+ main.panels.seqlive.model.datalist[(self.seqbank*8)..][..11]; // FIXME: hardcoded values
+ }
+ )
+ },
+
+ get_selected_bank: { arg self;
+ switch(self.spacekind,
+ \par, {
+ self.parbank
+ },
+ \seq, {
+ self.seqbank
+ }
+ )
+
+ }
+ );
+
+};
+
+~mk_sequencer = {
+
+ var main;
+
+ main = (
+ model: (
+ current_panel: \parlive,
+ clipboard: nil,
+
+
+ nodelib: nil,
+ presetlib: nil,
+ samplelib: nil,
+
+ patpool: nil,
+ livenodepool: nil
+ ),
+
+ context: \to_init,
+
+ archive_livenodepool: { arg self, projpath;
+ var dict = Dictionary.new;
+ self.model.livenodepool.keysValuesDo { arg key, val;
+ (key -> [val.defname, val.save_data]).writeArchive(projpath++"/livenode_"++key);
+ };
+ },
+
+ unarchive_livenodepool: { arg self, projpath;
+ var path;
+ var pool = Dictionary.new;
+ path = PathName.new(projpath);
+ path.entries.do { arg file;
+ var fullname, name, asso;
+ fullname = file.fullPath;
+ name = file.fileName;
+ if(name[..8] == "livenode_", {
+ asso = Object.readArchive(fullname);
+ pool[asso.key] = ~make_player_from_synthdef.(asso.value[0]);
+ pool[asso.key].load_data( asso.value[1] );
+ });
+ };
+ pool;
+ },
+
+ save_project: { arg self, name;
+ var proj;
+
+ ("mkdir "++name).unixCmd;
+ proj = ();
+ proj.patlib = self.model.patlib;
+ proj.patpool = self.model.patpool;
+ proj.parlive = self.model.parlive;
+ proj.state = self.state;
+ proj.volume = s.volume.volume;
+
+ self.archive_livenodepool(name);
+
+ proj.writeArchive(name++"/core");
+
+ },
+
+ load_project: { arg self, name;
+ var proj;
+ proj = Object.readArchive(name++"/core");
+ if(proj.notNil, {
+ self.model.patlib = proj.patlib.debug("patlib=============================");
+ self.model.patpool = proj.patpool.debug("patpool===============================");
+ self.model.livenodepool = self.unarchive_livenodepool(name).debug("livenodepool==================");
+ self.state = proj.state.debug("state====================================");
+ self.model.parlive = proj.parlive.debug("parlive=================================");
+ s.volume.volume = proj.volume;
+ //self.model = pro[0];
+ //self.state = pro[1];
+ }, {
+ ("Project `"++name++"' can't be loaded").postln
+ });
+ },
+
+ panels: (
+ //seqlive: ~make_seqlive.(main),
+ seqlive: \to_init,
+ parlive: \to_init
+ ),
+
+ load_patlib: { arg self, patlist;
+ var patpool, patlib, bank = 0, ix = 0, iy = 0;
+ patpool = Dictionary.new;
+
+ patlib = ~matrix3_from_list.(patlist, { arg asso;
+ patpool[asso.key] = asso.value;
+ asso.key;
+ });
+ self.model.patlib = patlib;
+ self.model.patlist = patlist.collect { arg asso; asso.key };
+ self.model.patpool = patpool;
+ },
+
+ load_samplelib: { arg self, samplelist;
+ self.model.samplelist = samplelist;
+ self.model.samplelib = samplelist;
+
+ },
+
+ show_panel: { arg self, panel;
+ self.model.current_panel = panel;
+ self.changed(\panel, panel)
+ },
+
+ commands: ~shortcut,
+
+ refresh: { arg self;
+ "refresh called".debug;
+ self.changed(\panel, self.model.current_panel);
+ },
+
+ make_gui: { arg self;
+ self.main_view = ~main_view.(self);
+ },
+
+ init: { arg self;
+ self.panels.parlive = ~make_parlive.(self);
+ self.context = ~make_context.(main);
+
+ }
+
+ );
+ main.init;
+ main
+
+};
+
+
View
9 matrix.sc
@@ -212,7 +212,7 @@
]
);
-~choose_pat = { arg main, action;
+~choose_libnode = { arg main, action;
var sl;
var callbacks;
var oldsel = nil;
@@ -317,11 +317,6 @@
//~choose_pat.(nil, { arg x; x.debug("yeak") });
//~choose_sample.(nil, { arg x; x.debug("yeak") });
-~save_pat.(nil, { arg x; x.debug("yeak") });
+//~save_pat.(nil, { arg x; x.debug("yeak") });
)
-
-
-a = SparseArray.new
-a[12] = nil
-a
View
167 mixer.sc
@@ -1,7 +1,73 @@
(
+~mixer_view = { arg parent, mixer, paramlist;
+ var midi;
+ var width = 1200;
+ var row_layout;
+ var sc_mixer;
+ var mixer_messages;
+
+ row_layout = GUI.vLayoutView.new(parent, Rect(0,0,(width+10),800));
+ row_layout.background = Color.blue;
-~make_mixer = { arg main, parent, kb_handler;
+
+ mixer_messages = Dictionary.newFrom((
+ paramlist: { arg self;
+ var player;
+ var master;
+ var midi;
+
+ ~midi_interface.clear_assigned(\slider);
+ ~midi_interface.clear_assigned(\knob);
+
+ CCResponder.removeAll; // FIXME: must not remove other useful CC
+
+ row_layout.removeAll;
+
+ "paramlist begin".debug;
+ player = (
+ // fake player
+ name: \mixer_panel,
+ get_bank: 0
+ );
+
+ "0paramlist begin".debug;
+ master = ~make_volume_param.(\master);
+ "1paramlist begin".debug;
+ master.midi = ~midi_interface.assign_master(master);
+ "2paramlist begin".debug;
+ ~make_control_view.(row_layout, mixer.make_param_display(\master, 0), master, master.midi);
+ "3paramlist begin".debug;
+
+ self.get_paramlist.debug("paramlist");
+ self.get_paramlist.do { arg paramasso, i;
+ var hihi2 = \rah;
+ var player_name = paramasso.key.name;
+ var param = paramasso.value;
+ paramasso.debug("paramasso");
+
+ midi = ~midi_interface.assign_first(\slider, param);
+ param.midi = midi;
+ ~make_control_view.(row_layout, mixer.make_param_display(param, i), param, midi);
+
+ };
+ "end paramlist method".debug;
+ }
+ ));
+
+ sc_mixer = SimpleController(mixer);
+ ~init_controller.(sc_mixer, mixer_messages);
+ mixer.refresh.();
+
+ // remove func
+
+ row_layout.onClose = {
+ sc_mixer.remove;
+ };
+
+};
+
+~make_mixer = { arg main, parent;
var mixer;
"iniyuyyy".debug;
@@ -29,7 +95,7 @@
show_midibloc: true,
name: { arg self;
var pname;
- pname = mixer.get_paramlist[idx].key;
+ pname = mixer.get_paramlist[idx].key.name;
pname;
},
noteline_numbeats: 32,
@@ -48,17 +114,23 @@
get_paramlist: { arg self, offset=nil;
var list = List.new;
+ "begin get_paramlist".debug;
offset = offset ?? self.model.param_offset;
- main.model.parlive.sortedKeysValuesDo( { arg key, val;
- if( ~compare_point.(key, offset).not, {
- val.data.do { arg pla;
- if(pla != 0, {
- list.add(pla -> main.model.livenodepool[pla].get_arg(\amp));
+ "1begin get_paramlist".debug;
+ //main.model.parlive.debug("get_paramlist main.model.parlive");
+ main.context.get_selected_node_set.do { arg nodegroup, i;
+ if (nodegroup.name != \void_FIXME) { // FIXME: change groupname when it has children
+ nodegroup.children.do { arg node;
+ if(node.name != \void, {
+ //FIXME: check for other types of nodes
+ //node.debug("get_paramlist:node");
+ list.add(node -> node.get_arg(\amp));
});
};
- })
- }, ~compare_point);
- list.debug("get_paramlist list");
+ }
+ };
+ //list.debug("get_paramlist list");
+ list;
},
refresh: { arg self;
@@ -67,10 +139,15 @@
init: { arg self;
"ini".debug;
- ~kbnumline.do { arg kc, i; kb_handler[[0, kc]] = {
- self.model.param_offset = 0@i;
+
+ main.commands.array_add_enable([\mixer, \select_offset], [\kb, 0], ~keycode.kbnumline, { arg x;
+ self.model.param_offset = 0@x;
self.changed(\paramlist);
- }};
+ });
+ main.commands.add_enable([\mixer, \show_panel, \parlive], [\kb, ~keycode.mod.fx, ~keycode.kbfx[8]], { main.show_panel(\parlive) });
+ main.commands.add_enable([\mixer, \show_panel, \score], [\kb, ~keycode.mod.fx, ~keycode.kbfx[10]], { main.show_panel(\score) });
+ main.commands.add_enable([\mixer, \show_panel, \editplayer], [\kb, ~keycode.mod.fx, ~keycode.kbfx[11]], { main.show_panel(\editplayer) });
+ "ini2".debug;
~mixer_view.(parent, mixer);
"inifin".debug;
@@ -84,70 +161,6 @@
};
-~mixer_view = { arg parent, mixer, paramlist;
- var midi;
- var width = 1200;
- var row_layout;
- var sc_mixer;
- var mixer_messages;
-
- row_layout = GUI.vLayoutView.new(parent, Rect(0,0,(width+10),800));
- row_layout.background = Color.blue;
-
-
- mixer_messages = Dictionary.newFrom((
- paramlist: { arg self;
- var player;
- var master;
- var midi;
-
- ~midi_interface.clear_assigned(\slider);
- ~midi_interface.clear_assigned(\knob);
-
- CCResponder.removeAll; // FIXME: must not remove other useful CC
-
- row_layout.removeAll;
-
- "paramlist begin".debug;
- player = (
- // fake player
- name: \mixer_panel,
- get_bank: 0
- );
-
- "0paramlist begin".debug;
- master = ~make_volume_param.(\master);
- "1paramlist begin".debug;
- master.midi = ~midi_interface.assign_master(master);
- "2paramlist begin".debug;
- ~make_control_view.(row_layout, mixer.make_param_display(\master, 0), master, master.midi);
- "3paramlist begin".debug;
-
- self.get_paramlist.debug("paramlist");
- self.get_paramlist.do { arg paramasso, i;
- var player_name = paramasso.key;
- var param = paramasso.value;
- paramasso.debug("paramasso");
-
- midi = ~midi_interface.assign_first(\slider, param);
- param.midi = midi;
- ~make_control_view.(row_layout, mixer.make_param_display(param, i), param, midi);
-
- };
- }
- ));
-
- sc_mixer = SimpleController(mixer);
- ~init_controller.(sc_mixer, mixer_messages);
- mixer.refresh.();
-
- // remove func
-
- row_layout.onClose = {
- sc_mixer.remove;
- };
-
-};
)
View
3 player.sc
@@ -953,6 +953,9 @@
noteline: false,
node: EventPatternProxy.new,
to_destruct: List.new,
+ name: defname,
+ kind: \player,
+ uid: nil,
init: { arg self;
View
501 sccode.sc
@@ -0,0 +1,501 @@
+s.boot
+
+(
+Ndef(\a, { |freq=2000, rate=1, width=0.6|
+ LFPulse.kr(rate, 0, 4/6) *
+ LFPulse.kr(rate * 6, 0, width) *
+ Pulse.ar(freq, 0.3, 0.1)
+}).play
+)
+
+
+
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+
+
+
+
+
+
+
+
+(
+SynthDef(\dollar, { |out, freq = 440, amp = 0.1, pan = 0, sustain = 1.0|
+ var env = EnvGen.kr(Env([amp, amp, 0], [sustain, 0.01]), doneAction: 2);
+ var decay = freq ** -0.5 * 100;
+ var string = CombL.ar(Decay2.ar(Impulse.ar(0), 0.0001, 0.001), 1/freq, 1/freq, decay);
+ var damped = string; //LPF.ar(string, Line.kr(11000, 3000, decay));
+ OffsetOut.ar(out, Pan2.ar(damped * env, pan));
+}).add;
+);
+
+(
+SynthDef(\euro, { |out, freq = 440, amp = 0.1, pan = 0, sustain = 1.0|
+ var env = EnvGen.kr(Env.perc(0.001, sustain), doneAction: 2);
+ var decay = freq ** -0.5 * 100;
+ var thing;
+ freq = freq * (1..7).nthPrime;
+ thing = SinOsc.ar(freq , 0, amp * AmpComp.kr(freq)).mean;
+ OffsetOut.ar(out, Pan2.ar(thing * env, pan));
+}).add;
+);
+
+
+(
+Pdef(\stock, { |note = 0, sustain = 1|
+ Pbind(
+ \instrument, [\dollar, \euro].choose,
+ \note, note.value + Pseq((12..0).curdle(0.1).scramble.flat * 3),
+ \dur, sustain.value / 12
+ )
+})
+);
+
+(
+Pdef(\ett,
+ Pbind(
+ \type, \phrase,
+ \instrument, \stock,
+ \dur, 4,
+ \legato, Prand((1..5), inf),
+ \note, Prand((0..12), inf) + Prand([[0, 2], [0, 6], [0, 7], 0, 0], inf)
+ )
+).play
+)
+
+
+
+(
+play{
+ p=LFPulse;
+ n=LFNoise1;
+ Limiter.ar(
+ GVerb.ar(
+ LPF.ar(LeakDC.ar(
+ mean({|n|(p.ar(n*1e2+50*p.kr(4-n/[4,7,5]).sum+3e2)*p.kr(n+1*2,0,0.8).lag(0.1))}!3)
+ ),4000) * 0.4, 200, 9, 0.6, 0.5, 40, 1, 0.15, 0.25
+ ).madd(0.8) + GVerb.ar(
+ {|i|BPF.ar(PinkNoise.ar(Decay.ar(Impulse.ar(2,0.95+n.kr(1,0.08)),rrand(0.2,0.4),2)).tanh,600*i+1200,0.4)}.dup(6).sum*1.2,
+ 90, 3, 0.7, 0.5, 30, 1, 0.2, 0.3
+ ) + Splay.ar(
+ {|i|Ringz.ar(LPF.ar(Impulse.ar(6,n.kr(1,0.08)),4000),6*i+40+n.kr(30,2),0.5,n.kr(3).range(4,8)).tanh}.dup(3),0.5
+ ).madd(0.3)
+ )
+}
+)
+
+play{p=LFPulse;cos(p.ar(p.kr(2)+p.kr(3)*[50,51]).lag(2e-3)+mean({|n|(p.ar(n*1e2+50*p.kr(4-n/[2,7,4]).sum+3e2)*p.kr(n+1*2,0,0.8))}!3))}
+
+n=LFNoise1;Ndef(\x,{a=SinOsc.ar(65,Ndef(\x).ar*n.ar(0.1,3),n.ar(3,6)).tanh;9.do{a=AllpassL.ar(a,0.3,{0.2.rand+0.1}!2,5)};a.tanh}).play
+
+
+(
+Ndef(\a, {
+ var src, loc, delay=0.01;
+ src = Decay2.ar(Impulse.ar(1/8), LFNoise2.kr(4).range(0.001, 0.0001),
+ LFNoise2.kr(4).range(0.005, 0.05))!2
+ * Saw.ar(LFNoise2.kr(4).exprange(40, 4000));
+ loc = BPF.ar(LocalIn.ar(2) + [src, 0], LFNoise0.kr(1/4).range(100, 1200).lag, 3.2);
+ loc = GVerb.ar(loc, 100, 4, mul:0.02, add:loc);
+ loc = Compander.ar(loc, loc, 0.9, 1, 0.001);
+ loc = (loc * 0.501).tanh;
+ loc = Compander.ar(loc, loc, 0.1, 1, 0.1);
+ loc = DelayC.ar(loc, delay * 2, delay * 1);
+ LocalOut.ar(loc.reverse * 0.49);
+ Out.ar(0, loc * 0.9)
+}).play;
+
+Ndef(\b, {
+ var src, loc, del;
+ del = 1/100;
+ src = Decay2.ar(TDuty.ar(1/4,0,Dseq([1, 0.5, 0.3, 0.1],inf)),
+ LFNoise2.kr(4).range(0.001, 0.0001), LFNoise2.kr(4).range(0.005, 0.05))!2
+ * Saw.ar(LFNoise2.kr(200).exprange(40, 14000));
+ loc = BPF.ar(LocalIn.ar(2) + [src, 0], LFNoise2.kr(0.1).range(40, 400), 3.2);
+ loc = GVerb.ar(loc, 100, 4, mul:0.02, add:loc);
+ loc = Compander.ar(loc, loc, 0.9, 1, 0.001);
+ loc = (loc * 0.51).tanh;
+ loc = Compander.ar(loc, loc, 0.1, 1, 0.1);
+ loc = DelayC.ar(loc, del * 2, del * 1);
+ LocalOut.ar(loc.reverse * 0.45);
+ Out.ar(0, Compander.ar(loc,loc,0.1, 1, 0.05) * 1.2)
+}).play;
+
+Ndef(\c, {
+ var src, loc, del=1/4;
+ src = Decay2.ar(Impulse.ar(1), 0.0001, 0.05) * SinOsc.ar(60);
+ loc = src + LocalIn.ar(2);
+ loc = BPF.ar(loc, 800, 3.2).softclip;
+ loc = DelayN.ar(loc, del, [0, del]);
+ LocalOut.ar(loc.reverse * 0.99);
+ Out.ar(0, loc * 2)
+}).play;
+)
+
+
+(
+SynthDef(\dubecho,{|length = 1, fb = 0.8, sep = 0.012|
+var input = In.ar(0, 2);
+var output = input + Fb({
+
+arg feedback; // this will contain the delayed output from the Fb unit
+
+var left,right;
+var magic = LeakDC.ar(feedback*fb + input);
+magic = HPF.ar(magic, 400); // filter's on the feedback path
+magic = LPF.ar(magic, 5000);
+magic = magic.tanh; // and some more non-linearity in the form of distortion
+#left, right = magic; // let's have named variables for the left and right channels
+magic = [DelayC.ar(left, 1, LFNoise2.ar(12).range(0,sep)), DelayC.ar(right, 1, LFNoise2.ar(12).range(sep,0))]; // In addition to the main delay handled by the feedback quark, this adds separately modulated delays to the left and right channels, which with a small "sep" value creates a bit of spatialization
+
+},length);
+ReplaceOut.ar(0, output);
+}).store;
+)
+
+// Example Usage
+~echo = Synth(\dubecho, [\length, TempoClock.default.tempo*(3/8), \fb, 0.7, \sep, 0.0012], addAction: \addToTail);
+~echo.free;
+~echo.set(\gate, 0);
+
+
+
+(
+SynthDef(\pluck, {|freq = 440, dur = 1|
+var klang,note;
+dur = dur * 2;
+note = freq.cpsmidi;
+note = note + (LFNoise2.ar(20).range(-1,1) * (1/8));
+klang = SinOsc.ar((note * [1,1.002]).midicps, phase: VarSaw.ar(note.midicps, width: Line.ar(1,0.2,dur))) * 0.3;
+klang = klang * XLine.ar(1,1/10000,dur,doneAction:2);
+Out.ar(0, klang);
+}).store;
+)
+
+(
+Pbind(
+\instrument, \pluck,
+\degree, Pn(Pseries(0, Pwrand([Pwhite(-3,3,inf).round(1),1],[32,1],inf), 4),inf)-1 + [0,2,-1,-14],
+\dur, Pseq([4, [5,2,1]].convertRhythm / 2, inf),
+\strum, Pwhite(0,1/8,inf),
+\octave, [5,6]
+).play;
+)
+
+
+(
+play {
+ Limiter.ar(
+ tanh(
+ 3 * GVerb.ar(
+ HPF.ar(
+ PinkNoise.ar(0.08+LFNoise1.kr(0.3,0.02))+LPF.ar(Dust2.ar(LFNoise1.kr(0.2).range(40,50)),7000),
+ 400
+ ),
+ 250,100,0.25,drylevel:0.3
+ ) * Line.kr(0,1,10)
+ ) + (
+ GVerb.ar(
+ LPF.ar(
+ 10 * HPF.ar(PinkNoise.ar(LFNoise1.kr(3).clip(0,1)*LFNoise1.kr(2).clip(0,1) ** 1.8), 20)
+ ,LFNoise1.kr(1).exprange(100,2500)
+ ).tanh,
+ 270,30,0.7,drylevel:0.5
+ ) * Line.kr(0,0.7,30)
+ )
+ )
+};
+)
+
+
+(
+SynthDef("additivePad",
+ { arg numOfCycles = 100;
+ var lfo;
+ var lfo2;
+ var lfo3;
+ lfo = SinOsc.kr([Rand(0.5,1000),Rand(0.5,1000)], 1.5pi, 0.5, 0.5);
+ lfo3 = SinOsc.kr([Rand(0.1,0.5),Rand(0.1,0.5)], 1.5pi, 0.5, 0.5);
+ lfo2 = SinOsc.kr([(Rand(0.5,1000) * lfo) * lfo3, (Rand(0.5,1000) * (1 - lfo)) * (1 - lfo3)], 1.5pi, 0.5, 0.5);
+ Out.ar(
+ 0,
+ Mix.arFill(
+ numOfCycles,
+ {
+ SinOsc.ar(
+ Rand(40,1000),
+ 0,
+ (numOfCycles.reciprocal * 0.75) * lfo2)
+ }
+ ) * EnvGen.kr(Env.perc(Rand(0.1,30), Rand(0.1,30)), doneAction: 2)
+ )
+ }
+).send(s);
+)
+
+(
+r = Routine({
+ 200.do({
+ x = Synth.new("additivePad");
+ 10.wait;
+ });
+});
+)
+
+r.play;
+
+
+
+TempoClock.default.tempo = 156/60;
+TempoClock.default.tempo =1
+
+(
+t = Bus.audio(Server.default, 2);
+
+SynthDef(\kick1507, { | dur = 0.15, amp = 1, truncate_freq = 300 |
+ var sig = HPF.ar(
+ LPF.ar(
+ SinOsc.ar( EnvGen.ar( Env.perc( 0, dur, curve: -6), levelScale: 1300) ),
+ truncate_freq
+ ),
+ 15
+ );
+ var env = EnvGen.ar( Env.perc( 0.001, dur, curve: 5), doneAction: 2, levelScale: amp );
+ Out.ar(0, sig * env ! 2);
+}).add;
+
+SynthDef(\bass1507, { | dur = 0.15, gate = 1, freq = 50 |
+ var sig = Blip.ar( freq, 5, 0.9 );
+ var env = EnvGen.ar( Env.sine( dur ), gate, doneAction: 2 );
+ Out.ar(0, sig * env ! 2);
+}).add;
+
+SynthDef(\bass1607, { | dur = 0.15, gate = 1, freq = 50, amp = 1, index = 10 |
+ var sig = PMOsc.ar( freq, freq + 5, index );
+ var env = EnvGen.ar( Env.triangle( dur ), gate, amp, doneAction: 2 );
+ Out.ar(0, sig * env ! 2);
+}).add;
+
+x = {
+ var sig = Limiter.ar(
+ In.ar(t, 2);
+ );
+ Out.ar(0, sig);
+}.play;
+)
+
+
+(
+Pbind(*[
+ instrument: \kick1507,
+ delta: 1,
+ dur: TempoClock.default.tempo.reciprocal / 4,
+ amp: Pseq( [
+ Pseq([1], 16),
+ Pseq([0.6, 1], 8),
+ Pseq([1], 16),
+ Pseq([0.7, 0.7, 0.85, 1], 8)
+ ], inf)
+]).play(quant:[1,0,0]);
+)
+
+(
+Pbind(*[
+ instrument: \bass1507,
+ delta: 0.25,
+ dur: TempoClock.default.tempo.reciprocal / 4,
+ freq: Pseq([\rest, Pseq([(33,34.5..45)], 3)], inf),
+]).play(quant:[1,0,0]);
+)
+
+(
+Pbind(*[
+ instrument: \bass1607,
+ delta: 0.25,
+ dur: TempoClock.default.tempo.reciprocal / 4,
+ freq: Pseq([\rest, Pseq([(50,51..60)], 3)], inf),
+]).play(quant:[1,0,0]);
+)
+
+// kick from above?
+(
+Pbind(*[
+ instrument: \kick1507,
+ delta: Pseq(Array.geom(540, 1, 1.015).reciprocal.reverse),
+ truncate_freq: Pseq(Array.series(540, 300, 2).reverse),
+ dur: Pkey(\delta)/4,
+ amp: 1
+]).play;
+)
+
+
+
+(
+SynthDef(\brumm, { |dur = 1, pan = 2, freq = 40, index = 20|
+ var sig = Pan2.ar(
+ Blip.ar(freq, index),
+ pan
+ ) * EnvGen.ar(Env.perc(0.01, dur), doneAction: 2);
+ Out.ar(0, sig);
+}).add;
+)
+
+(
+Pbind(*[
+ dur: Pseq([1.2, 0.2, 0.5, Pseries(0.1, -0.001, 100)], inf),
+ pan: Pxrand(#[-0.5, 0.5, 0.1, -0.1, 0.8, -1], inf),
+ freq: 40,
+ instrument: \brumm
+]).play();
+)
+
+(
+Pbind(*[
+ dur: Pseq([1.2, 0.2, 0.5, Pseries(0.1, -0.001, 100)], inf),
+ pan: Pxrand(#[-0.5, 0.5, 0.1, -0.1, 0.8, -1], inf),
+ freq: Pseq([Pseries(140, 0.5, 200)], inf),
+ instrument: \brumm
+]).play;
+)
+
+(
+Pbind(*[
+ dur: Pseq(Signal.chebyFill(1024, Array.rand(10, 0.0, 10.0)).abs + 0.05, inf),
+ pan: Pxrand(#[-0.5, 0.5, 0.1, -0.1, 0.8, -1], inf),
+ freq: Pseq(Signal.chebyFill(1024, Array.rand(10, 0.0, 10.0)).abs * 18000 + 120, inf),
+ instrument: \brumm
+]).play;
+)
+
+
+(
+Pbind(*[
+ dur: Pseq([1.2, 0.2, 0.5, Pseries(0.1, -0.002, 50)], inf),
+ pan: Pxrand(#[-0.5, 0.5, 0.1, -0.1, 0.8, -1, 1, -0.8], inf),
+ freq: Pseq([Pseries(740, 0.5, 200), Pxrand(Array.series(740, 0.5, 200), 50)], inf),
+ instrument: \brumm
+]).play;
+)
+
+
+
+
+
+
+
+
+
+
+
+
+~amen = Buffer.read(s, "sounds/amen-break.wav");
+
+(
+SynthDef(\loop, {| out = 0, amp=0.1, bufnum = 0, gate = 1, pos = 0, speed = 1, freq = 0, endfreq = 0.001, sustain=0.5, wobble = 3, boost = 1|
+
+ var player,env;
+ freq = XLine.ar(freq,endfreq,sustain/4);
+ freq = freq.cpsmidi + (LFNoise2.ar(3).range(-1,1) * (1/12));
+ freq = freq.midicps;
+ env = Env.adsr(0.0001,0.01, 1, sustain/8, 1);
+ amp = EnvGen.kr(env, gate, doneAction:2) * amp;
+ player = PlayBuf.ar(2, bufnum, BufRateScale.kr(bufnum) * speed, Impulse.ar(freq), startPos: (pos*BufFrames.kr(bufnum)) + Rand(0,20), doneAction:2, loop: 1) * boost;
+ player = RLPF.ar(player, SinOsc.ar(wobble/sustain).range(20000,80), XLine.ar(0.2,0.9,sustain)) * boost;
+ Out.ar(out, player);
+
+}).store;
+
+SynthDef(\compressor, {
+ var in,compressed;
+ in = In.ar(0,2);
+ compressed = Compander.ar(in, in, 0.1, 1, 1/8, 0.002, 0.01);
+ ReplaceOut.ar(0, compressed * 4);
+}).store;
+)
+
+TempoClock.default.tempo = 16/~amen.duration;
+
+~rhythm = Pseq([8,[2,[1,[1,1,[1,1!3],[1,1!4]]],[1,1!4]]].convertRhythm,1); // Evaluate one of these before playing the Pbind
+~rhythm = Pseq([8,[[2,[2,1,[1,1!12]]],[1,[1,1,[1,1!3],[1,1!4]]],[1,1!4]]].convertRhythm,1);
+~rhythm = Pseq([8,1!16].convertRhythm,1);
+
+(
+Pbind(
+\instrument, \loop,
+\bufnum, a.bufnum,
+\out, 0,
+\freq, Pstep([43.midicps,0,0,0],2,inf),
+\endfreq, Pstep([40.midicps/2,0,0,0],2,inf),
+\wobble, Pstep([Prand([1/2,2,1,1/3]),0,0,0],2,inf),
+\pos, Pstep(Array.series(8, 0, 1),1,inf)/8,
+\legato, 1,
+\dur, Pn(Plazy({~rhythm}))
+).play;
+)
+
+(
+Pbind(
+\instrument, \loop,
+\bufnum, a.bufnum,
+\out, 0,
+\freq, Pstep([43.midicps,0,0,0],2,inf),
+\endfreq, Pstep([40.midicps/2,0,0,0],2,inf),
+\wobble, Pstep([Prand([1/2,2,1,1/3]),0,0,0],2,inf),
+\pos, Pstep(Array.series(8, 0, 1),1,inf)/8,
+\legato, 1,
+\dur, Pn(Plazy({~rhythm}))
+).play;
+)
+
+
+(
+( 'instrument': \loop, 'speed': 1, 'dur': 0.25, \gate:1,
+ 'sustain': 0.5, 'segdur': 0.25, 'wobble': 3, 'boost': 1, 'pos': 0,
+ 'out': 0, 'legato': 0.5, 'stretchdur': 1, 'freq': 0, 'bufnum': 1,
+ 'endfreq': 0.0010000000474975 ).play
+)
+
+~comp = Synth(\compressor, addAction: \addToTail);
+
+~comp.free;
View
113 seqpanel.sc → score.sc
@@ -1,6 +1,6 @@
(
-~seq_view = { arg parent, seq, paramlist;
+~score_view = { arg parent, seq, paramlist;
var midi;
var width = 1200;
var row_layout;
@@ -25,11 +25,13 @@
"hah33333333ahahahjkkj".debug;
self.get_paramlist.do { arg paramasso, i;
- var player_name = paramasso.key;
+ var hihi1 = \bla;
+ var player_name = paramasso.key.name;
var param = paramasso.value;
+ paramasso.debug("=======paramasso");
- player = seq.get_player_from_name(player_name);
+ player = paramasso.key;
if(param.name == \noteline, {
midi = ~piano_recorder.(player);
@@ -57,7 +59,7 @@
};
-~make_seq = { arg main, parent, kb_handler;
+~make_score = { arg main, parent, kb_handler;
var seq;
@@ -66,13 +68,13 @@
model: (
param_offset: 0@0,
max_cells: 32,
- selected_param: main.state.panel.seqpanel.selected_player_idx;
+ selected_param: 0; //FIXME: load it from main
),
make_param_display: { arg self, param, idx;
(
get_bank: { arg self;
- main.state.panel.seqpanel.bank
+ main.context.get_selected_bank
},
selected: { arg self;
if(idx.debug("idx") == seq.model.selected_param.debug("sel"), {1}, {0});
@@ -88,7 +90,7 @@
var pname;
pname.debug("pname");
param.dump.debug("param");
- pname = seq.get_paramlist[idx].key;
+ pname = seq.get_paramlist[idx].key.name;
pname.debug("pname");
},
noteline_numbeats: 32,
@@ -110,9 +112,7 @@
},
get_selected_player: { arg self;
- var pname;
- pname = self.get_paramlist[seq.model.selected_param].key;
- main.model.livenodepool[pname];
+ self.get_paramlist[seq.model.selected_param].key;
},
get_player_from_name: { arg self, name;
@@ -127,8 +127,8 @@
oldparam = self.get_param_at(seq.model.selected_param);
param = self.get_param_at(idx);
seq.model.selected_param = idx;
- main.state.panel.seqpanel.selected_player = self.get_selected_player;
- main.state.panel.seqpanel.selected_player_idx = idx;
+ //main.state.panel.seqpanel.selected_player = self.get_selected_player;
+ //main.state.panel.seqpanel.selected_player_idx = idx;
oldparam.changed(\selected);
param.changed(\selected);
}, {
@@ -212,36 +212,37 @@
var list = List.new;
var player_instance;
offset = offset ?? self.model.param_offset;
- main.model.parlive.sortedKeysValuesDo( { arg key, val;
- if( ~compare_point.(key, offset).not, {
- val.data.do { arg pname;
- if(pname != 0, {
- player_instance = main.model.livenodepool[pname];
- if( player_instance.noteline, {
- list.add(pname -> player_instance.get_arg(\noteline));
+ main.context.get_selected_node_set.do( { arg nodegroup;
+ if (nodegroup.name != \void_FIXME) { // FIXME: change groupname when it has children
+ nodegroup.children.do { arg node;
+ if(node.name != \void, {
+ //FIXME: check for other types of nodes
+ //node.debug("get_paramlist:node");
+ if( node.noteline == true, {
+ list.add(node -> node.get_arg(\noteline));
},{
- list.add(pname -> player_instance.get_arg(\stepline));
+ list.add(node -> node.get_arg(\stepline));
});
});
};
- })
- }, ~compare_point);
- list.do{ arg i; i.dump.debug("get_paramlist list") };
+ }
+ });
+ //list.do{ arg i; i.dump.debug("get_paramlist list") };
list;
},
get_bank: { arg self;
- main.state.panel.seqpanel.bank
+ main.context.get_selected_bank
},
set_bank: { arg self, bank;
var player_instance;
- main.state.panel.seqpanel.bank = bank;
+ //main.state.panel.seqpanel.bank = bank;
self.get_paramlist.do { arg asso;
- player_instance = main.model.livenodepool[asso.key];
+ player_instance = asso.key;
player_instance.set_bank(bank);
};
- main.state.panel.seqpanel.bank = bank;
+ //main.state.panel.seqpanel.bank = bank;
},
refresh: { arg self;
@@ -250,40 +251,40 @@
init: { arg self;
- main.state.panel.seqpanel.selected_player = self.get_selected_player;
+ //main.state.panel.seqpanel.selected_player = self.get_selected_player;
- ~kbnumpad.do { arg kc, i; kb_handler[[0, kc]] = {
- self.model.param_offset = 0@i;
+ main.commands.array_add_enable([\score, \select_offset], [\kb, 0], ~keycode.kbnumpad, { arg x;
+ self.model.param_offset = 0@x;
self.changed(\paramlist);
- }};
+ });
- ~kbpad8x4_flat.do { arg kc, i; kb_handler[[0, kc]] = {
+ main.commands.array_add_enable([\score, \select_cell], [\kb, 0], ~keycode.kbpad8x4_flat, { arg i;
seq.select_cell((self.get_bank*self.model.max_cells)+i)
- } };
-
- ~kbnumline.do { arg kc, i; kb_handler[[~modifiers.alt, kc]] = { self.select_param(i) } };
+ });
+ main.commands.array_add_enable([\score, \select_param], [\kb, ~keycode.mod.alt], ~keycode.kbnumline, { arg i; self.select_param(i) });
- kb_handler[[~modifiers.alt, ~kbaalphanum["n"]]] = {