Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

sampleline works!!

  • Loading branch information...
commit d169e590fefc8335a14a217b769f0d4cc54eacb8 1 parent 2b628a6
@grirgz authored
View
38 crap8.sc
@@ -99,3 +99,41 @@ var sum = 0;
b.do { arg x; sum = sum + x.dur };
sum
)
+
+
+(
+a = NoteOnResponder { arg src, chan, num, veloc;
+ [src, chan, num, veloc].debug("noteon");
+}
+
+)
+(
+b = NoteOffResponder { arg src, chan, num, veloc;
+ [src, chan, num, veloc].debug("noteoff");
+}
+)
+b.remove
+
+
+
+
+
+
+(
+
+a = (
+ y: 1,
+ bla: { arg self, x=7; self.y = self.y + 40; x.debug("blablalb"); }
+);
+b = (
+ parent: a,
+ y: 5,
+ bla: { arg self, x=2;
+ "niark".debug;
+ self.parent[\bla].(self, x);
+ self.y.debug("y");
+ }
+);
+b.bla
+
+)
View
140 editplayer.sc
@@ -196,7 +196,7 @@
txt_buf = GUI.staticText.new(row_layout, Rect(0,0,200,height));
txt_buf.string = "nil";
- param_messages = Dictionary.newFrom((
+ ~make_view_responder.(parent, param, (
selected: { arg self;
bt_name.value = display.selected;
},
@@ -207,19 +207,35 @@
}
));
+};
- sc_param = SimpleController(param);
- ~init_controller.(sc_param, param_messages);
- param.refresh.();
+~make_string_param_view = { arg parent, display, param;
+
+ var txt_buf, bt_name;
+ var param_messages, sc_param,
+ width = 1088,
+ height = display.height;
+ var row_layout;
+ row_layout = GUI.hLayoutView.new(parent, Rect(0,0,(width+30),height));
+ row_layout.background = display.background_color;
- // remove func
- row_layout.onClose = {
- param.name.debug("=========== view closed");
- sc_param.remove;
- };
+ bt_name = ~make_name_button.(row_layout, display.name, xsize:display.name_width, ysize:height);
+ txt_buf = GUI.staticText.new(row_layout, Rect(0,0,200,height));
+ txt_buf.string = "nil";
+
+ ~make_view_responder.(parent, param, (
+ selected: { arg self;
+ bt_name.value = display.selected;
+ },
+
+ val: { arg self, msg, cellidx;
+ var newval;
+ txt_buf.string = param.get_val.asString;
+ }
+ ));
};
@@ -1041,7 +1057,7 @@
~make_env_control_view.(row_layout, player, editplayer.make_param_display(param), param);
}
{ param_name == \noteline } {
- if(player.noteline, {
+ if(player.current_mode == \noteline, {
//TODO: do it in editplayer.assign_midi
//midi = ~piano_recorder.(player);
//param.midi = midi;
@@ -1051,6 +1067,9 @@
{ [\repeat].includes(param_name) } {
~make_simple_control_view.(info_layout, editplayer.make_param_display(param), param);
}
+ { [\samplekit].includes(param_name) } {
+ ~make_string_param_view.(info_layout, editplayer.make_param_display(param), param);
+ }
{ [\dur].includes(param_name) } {
//if(player.noteline.not, {
~make_simple_control_view.(info_layout, editplayer.make_param_display(param), param);
@@ -1065,10 +1084,15 @@
//});
}
{ [\stepline].includes(param_name) } {
- if(player.noteline.not, {
+ if(player.current_mode == \stepline, {
~make_control_view.(row_layout, editplayer.make_param_display(param), param);
});
}
+ { [\sampleline].includes(param_name) } {
+ if(player.current_mode == \sampleline, {
+ ~make_noteline_view.(row_layout, editplayer.make_param_display(param), param);
+ });
+ }
{ [\legato, \amp, \pan, \attack, \release, \sustain].includes(param_name)} {
~make_control_view.(info_layout, editplayer.make_param_display(param), param);
}
@@ -1093,18 +1117,28 @@
};
~make_editplayer = { arg main, parent;
- var ep, player;
+ var ep, player, param_types;
"============making editplayer".debug;
player = main.context.get_selected_node;
//player.debug("editplayer:player");
+ param_types = (
+ param_field_group: List[\dur, \segdur, \stretchdur, \repeat],
+ param_slider_group: List[\amp, \legato, \pan, \attack, \sustain, \release],
+ param_status_group: List[\amp, \dur, \segdur, \stretchdur, \repeat, \legato, \pan, \attack, \sustain, \release, \bufnum, \samplekit],
+ param_order: List[\stepline, \noteline, \sampleline, \adsr, \freq],
+ param_reject: [\out, \instrument, \type, \gate, \agate, \t_trig]
+ );
+ param_types.param_no_midi = param_types.param_field_group ++ [\bufnum, \samplekit];
ep = (
player: player,
+ param_types: param_types,
model: (
- param_field_group: List[\dur, \segdur, \stretchdur, \repeat],
- param_status_group: List[\amp, \dur, \segdur, \stretchdur, \repeat, \legato, \pan, \attack, \sustain, \release, \bufnum],
- param_order: List[\stepline, \noteline, \adsr, \freq],
- param_reject: [\out, \instrument, \type, \gate, \agate, \t_trig],
+ param_field_group: param_types.param_field_group,
+ param_status_group: param_types.param_status_group,
+ param_order: param_types.param_order,
+ param_reject: param_types.param_reject,
+ param_no_midi: param_types.param_no_midi,
max_cells: 8,
colselect_mode: true, // select whole column mode
selected_param: 0
@@ -1157,11 +1191,11 @@
get_paramlist: { arg self;
var po = self.model.param_order;
if( player.kind == \player ) {
- if(player.noteline, {
- po.reject({ arg x; [\stepline].includes(x) });
- }, {
- po.reject({ arg x; [\noteline].includes(x) });
- });
+ switch(player.current_mode,
+ \sampleline, { po.reject({ arg x; [\noteline, \stepline].includes(x) }); },
+ \noteline, { po.reject({ arg x; [\stepline, \sampleline].includes(x) }); },
+ \stepline, { po.reject({ arg x; [\noteline, \sampleline].includes(x) }); }
+ );
} {
po;
}
@@ -1179,14 +1213,14 @@
//TODO: working ?
main.midi_center.assign_adsr(param)
}
- { [\noteline, \stepline].includes(param_name) } {
+ { [\sampleline, \noteline, \stepline].includes(param_name) } {
//TODO
//midi = ~piano_recorder.(player);
}
- { self.model.param_field_group.includes(param_name) } {
+ { self.model.param_no_midi.includes(param_name) } {
// no midi
}
- { [\legato, \amp, \pan, \attack, \release, \sustain].includes(param_name)} {
+ { self.param_types.param_slider_group.includes(param_name)} {
main.midi_center.assign_first(\slider, param);
}
{ true } {
@@ -1198,11 +1232,7 @@
get_param_offset: { arg self;
if( player.kind == \player ) {
- if(player.noteline, {
- self.get_paramlist.indexOf(\noteline);
- },{
- self.get_paramlist.indexOf(\stepline);
- });
+ self.get_paramlist.indexOf(player.current_mode);
} {
0
}
@@ -1495,16 +1525,23 @@
editplayer.controller.change_kind(\seg)
});
- // noteline
+ // player mode selection
+ "editplayer shorcut 1".debug;
main.commands.add_enable([\editplayer, \set_noteline_mode], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["n"]], {
- player.set_noteline(true);
+ player.set_mode(\noteline);
+ editplayer.controller.select_param(editplayer.get_param_offset);
+ editplayer.refresh
+ });
+
+ main.commands.add_enable([\editplayer, \set_stepline_mode], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["b"]], {
+ player.set_mode(\stepline);
editplayer.controller.select_param(editplayer.get_param_offset);
editplayer.refresh
});
- main.commands.add_enable([\editplayer, \unset_noteline_mode], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["b"]], {
- player.set_noteline(false);
+ main.commands.add_enable([\editplayer, \set_sampleline_mode], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["m"]], {
+ player.set_mode(\sampleline);
editplayer.controller.select_param(editplayer.get_param_offset);
editplayer.refresh
});
@@ -1517,25 +1554,31 @@
main.commands.add_enable([\editplayer, \start_tempo_recording], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["r"]], {
var recorder = editplayer.recorder;
- var noteline = player.get_arg(\noteline);
+ var nline = if(player.get_mode == \sampleline) {
+ player.get_arg(\sampleline);
+ } {
+ player.get_arg(\noteline);
+ };
"STARTRECORD!!".debug;
+ player.current_mode.debug("player.current_mode");
+ nline.name.debug("nline.name");
recorder.start_tempo_recording(2, TempoClock.tempo, false, {
var sum = 0;
- noteline.changed(\recording, false);
+ nline.changed(\recording, false);
recorder.track.debug("66666666666666666666666666666- this is record!!!!");
recorder.track.do { arg no;
sum = sum + no.dur;
};
sum.debug("total sum");
- noteline.set_notes(recorder.track);
- noteline.mute(false);
- noteline.changed(\notes);
+ nline.set_notes(recorder.track);
+ nline.mute(false);
+ nline.changed(\notes);
player.play_node;
});
- noteline.changed(\recording, true);
- noteline.mute(true);
+ nline.changed(\recording, true);
+ nline.mute(true);
});
// main.commands.add_enable([\editplayer, \start_recording], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["r"]], {
@@ -1563,12 +1606,15 @@
main.commands.add_enable([\editplayer, \set_notequant], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["q"]], {
var delta;
- var param = player.get_arg(\noteline);
- delta = player.get_arg(\dur).get_val;
- if(param.notequant.isNil) {
- param.set_notequant(delta)
- } {
- param.set_notequant(nil)
+ var param;
+ if([\sampleline, \noteline].includes(player.get_mode)) {
+ param = player.get_arg(player.get_mode);
+ delta = player.get_arg(\dur).get_val;
+ if(param.notequant.isNil) {
+ param.set_notequant(delta)
+ } {
+ param.set_notequant(nil)
+ }
}
});
@@ -1577,6 +1623,7 @@
main.commands.add_enable([\editplayer, \edit_wrapper], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["w"]], { player.edit_wrapper });
// noteline
+ "editplayer shorcut 2".debug;
noteline = player.get_arg(\noteline);
if( noteline.notNil ) {
@@ -1664,6 +1711,7 @@
// make view
"make view".debug;
+
editplayer.assign_midi;
~make_editplayer_view.(parent, main, editplayer, player, param_order);
}
View
3  keycode.sc
@@ -234,6 +234,9 @@
],
\slider: [
25,26,27,28, 29,30,31,32, 33
+ ],
+ \pad: [ // in order of label number
+ 36, 38, 42, 43, 46, 47, 50, 49,
]
);
~midi = {
View
1  main.sc
@@ -106,6 +106,7 @@
"synth",
"keycode",
"midi",
+ "samplelib",
"player",
"matrix",
"hmatrix",
View
18 midi.sc
@@ -199,7 +199,7 @@
};
~make_midi_recorder = { arg player;
- var prec, livesynth = player.get_piano;
+ var prec, livesynth;
NoteOnResponder.removeAll;
NoteOffResponder.removeAll;
@@ -250,6 +250,7 @@
if(self.recording, {
"already recording!!!".debug;
}, {
+ livesynth = player.get_piano;
self.tclock.debug("lecture de cette foutue horloge");
record_start_time = self.tclock.beats;
record_start_time.debug("NOW: should be 4 beats");
@@ -263,9 +264,16 @@
self.nonr = NoteOnResponder { arg src, chan, num, veloc;
var note, firstnote;
var start_silence;
+ var slotnum = nil;
//[TempoClock.beats, TempoClock.nextTimeOnGrid(EventPatternProxy.defaultQuant,0), EventPatternProxy.defaultQuant].debug("nc,tc,dq");
- self.livebook[num] = livesynth.value(num.midicps, veloc/127);
+ if(chan == 9) {
+ // pad button pressed
+ slotnum = ~samplekit_manager.midinote_to_slot(num);
+ self.livebook[[chan, num]] = livesynth.value(slotnum, veloc/127);
+ } {
+ self.livebook[[chan, num]] = livesynth.value(num.midicps, veloc/127);
+ };
[src, chan, num, veloc].debug("note on");
note = (
@@ -273,12 +281,15 @@
velocity: veloc,
curtime: self.tclock.beats - s.latency
);
+ if(slotnum.notNil) { note.slotnum = slotnum };
+
if(self.lastnote.isNil, {
// first note
start_silence = self.tclock.beats - s.latency - record_start_time;
if(start_silence < 0, { "Negative dur!!".warning; start_silence = 0; });
firstnote = (
midinote: \rest,
+ slotnum: \rest,
velocity: 0,
sustain: 0.1,
start_silence: start_silence,
@@ -298,7 +309,7 @@
};
self.noffr = NoteOffResponder { arg src, chan, num, veloc;
var note;
- self.livebook[num].release;
+ self.livebook[[chan,num]].release;
note = self.book[num];
self.book.removeAt(num);
note.debug("noffr note");
@@ -331,6 +342,7 @@
if(self.recording, {
"already recording!!!".debug;
}, {
+ livesynth = player.get_piano;
self.recording = true;
self.track = List.new;
self.book = Dictionary.new;
View
513 player.sc
@@ -18,13 +18,13 @@
var val = 0;
var repeat;
userepeat.debug("=============================pdynarray:userepeat");
- ev[\is_noteline].debug("pdynarray:is_noteline");
+ ev[\current_mode].debug("pdynarray:current_mode");
switch(userepeat,
false, {
repeat = inf;
},
\noteline, {
- if( ev[\is_noteline] == true ) {
+ if( ev[\current_mode] == \noteline ) {
repeat = ev[\repeat];
if(repeat == 0) { repeat = inf };
} {
@@ -32,7 +32,15 @@
};
},
\stepline, {
- if( ev[\is_noteline] == false ) {
+ if( ev[\current_mode] == \stepline ) {
+ repeat = ev[\repeat];
+ if(repeat == 0) { repeat = inf };
+ } {
+ repeat = inf;
+ };
+ },
+ \sampleline, {
+ if( ev[\current_mode] == \sampleline ) {
repeat = ev[\repeat];
if(repeat == 0) { repeat = inf };
} {
@@ -408,18 +416,22 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
self.buffer.bufnum.debug("BUFNUM");
Prout({ arg ev;
- var repeat = 1000000;
+ var repeat = 1000;
repeat.do {
- switch(self.current_kind,
- \samplekit, {
+ self.current_kind.debug("2222222222222222222222 entering bufnum vpattern loop");
+ switch(player.get_mode,
+ \sampleline, {
+ ~samplekit_manager.slot_to_bufnum(ev[\sampleline].slotnum, ev[\samplekit]).debug("bufnum::::");
ev = ~samplekit_manager.slot_to_bufnum(ev[\sampleline].slotnum, ev[\samplekit]).yield;
},
- \sample, {
+ // else
+ {
ev = self.buffer.bufnum.yield;
}
);
};
});
+ //Pfunc({ "RAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH".debug; 0});
}
);
@@ -619,15 +631,15 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
};
-~make_sampleline_param = { arg name;
+~make_parent_recordline_param = { arg name, default_value=[];
var ret;
ret = (
name: name,
- classtype: \sampleline,
+ classtype: \noteline,
selected_cell: 0,
selected: 0,
default_val: default_value.asList,
- notes: ~default_sampleline.deepCopy,
+ notes: ~default_noteline3.deepCopy,
start_offset: 0,
end_offset: 0,
muted: false,
@@ -707,17 +719,9 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
set_notes: { arg self, val;
self.notes = val;
- self.trans_notes;
self.update_note_dur;
},
- trans_notes: { arg self;
- // make sample slots compatibles with other code using midinotes
- self.notes = self.notes.collect { x;
- x.midinote = x.slotnum;
- };
- },
-
get_note: { arg self, idx;
var no;
if( self.vnotes.size > 0 && {self.muted.not}) {
@@ -729,7 +733,7 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
no
}
} {
- "sampleline_param: get_node: No notes".inform;
+ "noteline_param: get_node: No notes".inform;
if(idx == 0) {
~empty_note;
} {
@@ -952,347 +956,41 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
self.changed(\selected);
},
vpattern: { arg self;
- //"YE SOUI PREMIER!!!!".debug;
- "--------making vpattern of sampleline".debug;
- ~pdynarray.( { arg idx; self.tick; self.get_note(idx) }, \noteline );
- //self.get_note(0);
+ ~pdynarray.( { arg idx; self.tick; self.classtype.debug("classtype!!!!!!!!"); self.get_note(idx) }, self.classtype );
};
);
ret;
};
-~make_noteline_param = { arg name, default_value=[];
+~make_sampleline_param = { arg name, default_value=[];
var ret;
ret = (
- name: name,
- classtype: \noteline,
- selected_cell: 0,
- selected: 0,
- default_val: default_value.asList,
- notes: ~default_noteline3.deepCopy,
- start_offset: 0,
- end_offset: 0,
- muted: false,
- archive_data: [\name, \classtype, \selected, \selected_cell, \default_val, \notes, \start_offset, \end_offset, \notequant],
- notequant: nil,
- vnotes: [],
-
- save_data: { arg self;
- var data = ();
- self.archive_data.do {
- arg key;
- data[key] = self[key];
- };
- [\seq].do { arg kind;
- data[kind] = ();
- [\val].do { arg key;
- data[kind][key] = self[kind][key];
- }
- };
- data;
- },
+ parent: ~make_parent_recordline_param.(name, default_value),
+ classtype: \sampleline,
+ notes: ~default_sampleline.deepCopy,
- load_data: { arg self, data;
- self.archive_data.do {
- arg key;
- self[key] = data[key];
- };
- [\seq].do { arg kind;
- [\val].do { arg key;
- self[kind][key] = data[kind][key];
- }
+ trans_notes: { arg self;
+ // make sample slots compatibles with other code using midinotes
+ self.notes = self.notes.collect { arg x;
+ x.midinote = x.slotnum;
};
},
- seq: (
- val: default_value.asList,
- change: { arg self, fun;
- self.val = fun.(self.val);
- }
- ),
- get_cells: { arg self;
- self.seq.val;
- },
- get_selected_cell: { arg self;
- self.selected_cell;
- },
- select_param: { arg self;
- self.selected = 1;
- self.changed(\selected);
- },
- deselect_param: { arg self;
- self.selected = 0;
- self.changed(\selected);
- },
-
- add_cells: { arg self, cells;
- self.seq.val.addAll(cells);
- self.changed(\cells);
- },
-
- remove_cells: { arg self, num;
- self.seq.val = self.seq.val[.. (self.seq.val.size - num - 1) ];
- self.changed(\cells);
- },
-
- set_val: { arg self, val;
- self.seq.val[ self.get_selected_cell.() ] = if(val > 1, { 1 },{ 0 });
- },
-
- get_notes: { arg self;
- var no;
- no = self.vnotes.deepCopy;
- //no[0].dur+self.start_offset;
- //no.last.dur+self.end_offset;
- no;
- },
-
- set_notes: { arg self, val;
- self.notes = val;
- self.update_note_dur;
- },
-
- get_note: { arg self, idx;
- var no;
- if( self.vnotes.size > 0 && {self.muted.not}) {
- no = self.vnotes[idx].deepCopy;
- if( no.notNil && (self.notequant.notNil) ) {
- no.dur = no.dur.round(self.notequant);
- no;
- } {
- no
- }
- } {
- "noteline_param: get_node: No notes".inform;
- if(idx == 0) {
- ~empty_note;
- } {
- nil;
- };
- }
- },
-
- total_dur: { arg self, notes;
- var res=0;
- notes.do { arg x; res = x.dur + res; };
- res;
- },
-
update_note_dur: { arg self;
- var find_next, find_prev, delta, prevdelta, idx, previdx;
- "update_note_dur".debug("start");
- if( self.notes.size > 2) {
- find_next = { arg dur, notes;
- var res=0, vidx=0, last=nil, delta=0, prevdelta=0;
- dur.debug("find_next: dur");
- if(dur == 0) {
- delta = 0;
- vidx = 0
- } {
- notes[1..].do { arg x, n;
- [n, res, vidx, last, dur].debug("begin n res vidx last");
- if( res < dur ) {
- res = x.dur + res;
- vidx = vidx + 1;
- last = x.dur;
- };
- [n, res, vidx, last].debug("end");
- };
- delta = res - dur;
- };
- [ delta, vidx+1 ];
- };
-
- find_prev = { arg dur, notes;
- var res=0, vidx=0, last=nil, delta=0, prevdelta=0;
- dur = self.total_dur( notes[1..(notes.lastIndex-1)] ).debug("total dur") - dur;
- dur.debug("find_prev: dur");
-
- notes[1..].do { arg x, n;
- [n, res, vidx, last].debug("begin n res vidx last");
- if( res <= dur ) {
- res = x.dur + res;
- vidx = vidx + 1;
- last = x.dur;
- };
- [n, res, vidx, last].debug("end");
- };
- delta = res - dur;
- if(last.isNil) {
- prevdelta = nil
- } {
- last.debug("last");
- prevdelta = last - delta;
- };
- [ prevdelta, vidx ];
- };
-
- #delta, idx = find_next.(self.notes[0].start_offset, self.notes);
- #prevdelta, previdx = find_prev.(self.notes[0].end_offset, self.notes);
- [delta, idx, prevdelta, previdx].debug("delta, idx, prevdelta, previdx");
- self.notes[0].dur = self.notes[0].start_silence + delta;
- self.vnotes = [self.notes[0]] ++ self.notes[idx..previdx].deepCopy;
- self.vnotes[self.vnotes.lastIndex].dur = self.notes[0].end_silence + prevdelta;
- self.vnotes.debug("update_note_dur: vnotes");
- self.changed(\notes);
- } {
- if(self.notes.size == 2) {
- self.vnotes = self.notes.deepCopy;
- if( (self.notes[0].start_silence + self.notes[0].end_silence) < 0.01 ) {
- "Protection anti infinite loop: setting end_silence to 0.5".error;
- self.notes[0].end_silence = 0.5
- };
- self.vnotes[0].dur = self.notes[0].start_silence;
- self.vnotes[self.vnotes.lastIndex].dur = self.notes[0].end_silence;
- self.vnotes.debug("update_note_dur: vnotes");
- self.changed(\notes);
- }
- }
-
- },
-
- set_start_offset: { arg self, val;
- var dur;
- if(self.notes.size > 2 ) {
- dur = self.total_dur( self.notes[1..(self.notes.lastIndex-1)] );
- if( val >= 0 && (val < (dur - self.notes[0].end_offset)) ) {
- [val, dur, self.notes[0].end_offset, dur - self.notes[0].end_offset].debug("set start_offset: val, dur, eo, dur-eo");
- self.notes[0].start_offset = val;
- self.update_note_dur;
- } {
- [val, dur, self.notes[0].end_offset, dur - self.notes[0].end_offset].debug("can't set start_offset: val, dur, eo, dur-eo");
- }
- } {
- "You are stupid!".debug;
- }
- },
-
- set_end_offset: { arg self, val;
- var dur;
- if(self.notes.size > 0) {
- dur = self.total_dur( self.notes[1..(self.notes.lastIndex-1)] );
- if( val >= 0 && (val < (dur - self.notes[0].start_offset)) ) {
- [val, dur, self.notes[0].end_offset, dur - self.notes[0].end_offset].debug("can't set end_offset: val, dur, so, dur-so");
- self.notes[0].end_offset = val;
- self.update_note_dur;
- } {
- [val, dur, self.notes[0].start_offset, dur - self.notes[0].start_offset].debug("can't set end_offset: val, dur, so, dur-so");
- }
- }
- },
-
- get_start_offset: { arg self;
- if(self.notes.size > 0) {
- self.notes[0].start_offset;
- }
- },
-
- get_end_offset: { arg self;
- if(self.notes.size > 0) {
- self.notes[0].end_offset;
- }
- },
-
- set_start_silence: { arg self, val;
-
- if(self.notes.size > 0 && (val >= 0)) {
- self.notes[0].start_silence = val;
- self.update_note_dur;
- } {
- [val, self.notes.size].debug("can't set start_silence: val, notessize");
- }
- },
-
- set_end_silence: { arg self, val;
-
- if(self.notes.size > 0 && (val >= 0)) {
- self.notes[0].end_silence = val;
- self.update_note_dur;
- } {
- [val, self.notes.size].debug("can't set end_silence: val, notessize");
-
- };
- },
-
- get_start_silence: { arg self;
- if(self.notes.size > 0) {
- self.notes[0].start_silence;
- }
-
- },
-
- get_end_silence: { arg self;
- if(self.notes.size > 0) {
- self.notes[0].end_silence;
- }
-
- },
-
- set_first_note_dur: { arg self, val;
- var res = 0, lastdur = 0, vidx = 0;
- if( self.notes.size > 0) {
- self.notes[0].dur = val;
- if( val < 0 ) {
- self.notes.do { arg x;
- if( res < val.neg ) {
- res = x.dur + res;
- vidx = vidx + 1;
- lastdur = x.dur;
- }
- };
- self.notes[0].virtual_start_idx = vidx -1;
- self.notes[0].virtual_start_dur = res - val.neg;
- }
- }
- },
-
- get_first_note_dur: { arg self;
- self.notes.size.debug("get_first_note_dur self.notes.size");
- if( self.notes.size > 0) {
- self.notes[0].dur;
- } {
- nil
- }
- },
-
- set_notequant: { arg self, val;
- self.notequant = val;
- self.changed(\notes);
- },
-
- tick: { arg idx;
- //"TICK!".postln;
- },
-
- mute: { arg self, val;
- self.muted = val;
- },
-
- toggle_cell: { arg self, idx;
- var oldsel;
- [idx, self.get_cells].debug("make_control_param.select_cell idx, selg.get_cells");
- if( idx < self.get_cells.size, {
- //oldsel = self.selected_cell;
- self.selected_cell = idx;
- //self.changed(\selected_cell, oldsel);
- self.seq.val[ idx ] = ~toggle_value.(self.seq.val[ idx ]);
- self.changed(\val, self.selected_cell);
- })
- },
- refresh: { arg self;
- self.update_note_dur;
- self.get_notes.debug("noteline param refresh: get_notes");
- self.changed(\notes);
- self.changed(\selected);
- },
- vpattern: { arg self;
- //"YE SOUI PREMIER!!!!".debug;
- "--------making vpattern of noteline".debug;
- ~pdynarray.( { arg idx; self.tick; self.get_note(idx) }, \noteline );
- //self.get_note(0);
- };
+ self.trans_notes;
+ self.parent[\update_note_dur].(self);
+ }
+ );
+ ret;
+};
+~make_noteline_param = { arg name, default_value=[];
+ var ret;
+ ret = (
+ parent: ~make_parent_recordline_param.(name, default_value),
+ classtype: \noteline,
+ notes: ~default_noteline3.deepCopy
);
ret;
};
@@ -1472,7 +1170,6 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
selected_cell: 0,
bar_length: bar_length,
default_val: default_value,
- noteline: false,
archive_data: [\name, \classtype, \current_kind, \spec, \selected, \selected_cell, \default_val, \noteline],
save_data: { arg self;
@@ -1705,24 +1402,37 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
},
vpattern: { arg self;
- var segf, scalf, pref;
+ var segf, scalf, pref, scalm;
switch(self.name,
\dur, {
segf = { arg ev;
ev[\noteline].dur * ev[\stretchdur];
};
+ scalm = { arg ev;
+ //ev[\sampleline]
+ ev.debug("dury'a quoi la dedans");
+ ev[\sampleline].debug("durjuste lui ce connard");
+ ev[\sampleline].dur * ev[\stretchdur];
+ };
scalf = pref = segf;
},
\freq, {
segf = { arg ev;
ev[\noteline].midinote.midicps;
};
+ scalm = { arg ev; self.scalar.val };
scalf = pref = segf;
},
\sustain, {
segf = { arg ev;
ev[\noteline].sustain;
};
+ scalm = { arg ev;
+ //ev[\sampleline]
+ ev.debug("y'a quoi la dedans");
+ ev[\sampleline].debug("juste lui ce connard");
+ ev[\sampleline].sustain;
+ };
scalf = pref = segf;
},
// else
@@ -1732,6 +1442,7 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
self.seq.val.blendAt((ev[\elapsed]/ev[\segdur]) % (self.seq.val.size));
};
scalf = { arg ev; self.scalar.val };
+ scalm = { arg ev; self.scalar.val };
pref = { arg ev; self.preset.val[self.preset.selected_cell] };
}
);
@@ -1745,11 +1456,19 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
\scalar, {
//ev.debug("=========== in scalar ev");
8.do { // hack to be in phase when changing kind (should be the size of stepline)
- if(self.noteline, {
- ev = scalf.value(ev).yield;
- }, {
- ev = self.scalar.val.yield;
- });
+ switch(player.get_mode,
+ \sampleline, {
+ [name, scalm.value(ev)].debug("############# scalm!!");
+ ev = scalm.value(ev).yield;
+ //ev = 1.yield;
+ },
+ \noteline, {
+ ev = scalf.value(ev).yield;
+ },
+ \stepline, {
+ ev = self.scalar.val.yield;
+ }
+ );
}
//ev.debug("=========== in scalar ev END");
},
@@ -1764,7 +1483,7 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
ev = (self.seg.val++[self.seg.val[0]]).blendAt((ev[\elapsed]/ev[\segdur]) % (self.seg.val.size)).yield;
},
\seq, {
- if(self.noteline, {
+ if(player.get_mode == \noteline, {
//ev.debug("=========== in noteline ev");
//segf.debug("=========== in noteline segf");
//segf.value(ev).debug("=========== in noteline");
@@ -1781,11 +1500,19 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
//ev.debug("=========== in seq ev END");
},
\preset, {
- if(self.noteline, {
- ev = pref.value(ev).yield;
- }, {
- ev = self.preset.val[self.preset.selected_cell].yield
- });
+ switch(player.get_mode,
+ \sampleline, {
+ [name, scalm.value(ev)].debug("############# scalm!!2");
+ //ev = 1.yield;
+ ev = scalm.value(ev).yield;
+ },
+ \noteline, {
+ ev = pref.value(ev).yield;
+ },
+ \stepline, {
+ ev = self.preset.val[self.preset.selected_cell].yield
+ }
+ );
},
\bus, {
self.bus.get_bus.asMap;
@@ -1841,12 +1568,12 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
defname: defname,
//uname: defname ++ UniqueID.next,
uname: nil,
- noteline: false,
node: EventPatternProxy.new,
to_destruct: List.new,
//name: defname,
name: nil,
- kind: \player,
+ kind: \player, // should be classtype, but backward compat...
+ current_mode: \stepline, // should be current_kind
uid: UniqueID.next,
playlist: List.new,
sourcepat: nil,
@@ -1931,13 +1658,15 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
var dict = Dictionary.new;
var list = List[];
var prio;
- prio = [\repeat, \instrument, \stretchdur, \noteline, \stepline, \type, \dur, \segdur, \legato, \sustain];
+ prio = [\repeat, \instrument, \stretchdur, \sampleline, \noteline, \stepline, \type, \samplekit, \bufnum, \dur, \segdur, \legato, \sustain];
list.add(\elapsed); list.add(Ptime.new);
- list.add(\is_noteline); list.add(Pfunc({ self.noteline }));
+ list.add(\current_mode); list.add(Pfunc({ self.get_mode }));
list.add(\muted); list.add(Pfunc({ self.muted }));
prio.do { arg key;
- list.add(key); list.add( self.data[key].vpattern );
+ if(self.data[key].notNil) {
+ list.add(key); list.add( self.data[key].vpattern );
+ }
};
self.data.keys.difference(prio).do { arg key;
list.add(key); list.add( self.data[key].vpattern );
@@ -1947,7 +1676,7 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
//list.debug("maked pbind list");
//Pbind(*list).dump;
//Pbind(*list).trace;
- Pbind(*list);
+ Pbind(*list).trace;
}.value;
},
@@ -1994,16 +1723,34 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
get_piano: { arg self;
var exclu, list = List[];
- exclu = [\instrument, \noteline, \amp, \freq, \stepline, \type, \dur, \segdur, \legato, \sustain];
+ exclu = [\instrument, \noteline, \amp, \bufnum, \freq, \stepline, \type, \dur, \segdur, \legato, \sustain];
self.data.keys.difference(exclu).do { arg key;
var val = self.data[key].vpiano ?? self.data[key].vpattern;
list.add(key); list.add( val )
};
- { arg freq, veloc;
- Synth(self.data[\instrument].vpiano, (
- [\freq, freq, \amp, self.data[\amp].vpiano.value * veloc ] ++
- list.collect(_.value)).debug("arg listHHHHHHHHHHHHHHHHHHHHHHHHHHH"))
- }
+ if(self.get_mode == \sampleline) {
+ if(self.data[\freq].notNil) {
+ list.add(\freq); list.add( self.data[\freq].vpiano ?? self.data[\freq].vpattern );
+ };
+ { arg slotnum, veloc;
+ [slotnum, self.data[\samplekit].get_val].debug("slotnum, samplekit get val");
+ ~samplekit_manager.slot_to_bufnum(slotnum, self.data[\samplekit].get_val).debug("bufnum");
+ Synth(self.data[\instrument].vpiano, (
+ [\bufnum, ~samplekit_manager.slot_to_bufnum(slotnum, self.data[\samplekit].get_val),
+ \amp, self.data[\amp].vpiano.value * veloc ] ++
+ list.collect(_.value)).debug("sampleline arg listHHHHHHHHHHHHHHHHHHHHHHHHHHH"))
+ }
+ } {
+ if(self.data[\bufnum].notNil) {
+ list.add(\bufnum); list.add( self.data[\bufnum].vpiano ?? self.data[\bufnum].vpattern );
+ };
+ { arg freq, veloc;
+ Synth(self.data[\instrument].vpiano, (
+ [\freq, freq, \amp, self.data[\amp].vpiano.value * veloc ] ++
+ list.collect(_.value)).debug("arg listHHHHHHHHHHHHHHHHHHHHHHHHHHH"))
+ }
+
+ };
},
@@ -2057,7 +1804,16 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
};
},
+ set_mode: { arg self, val;
+ self.current_mode = val;
+ },
+
+ get_mode: { arg self, val;
+ self.current_mode;
+ },
+
set_noteline: { arg self, set;
+ 1.erreur;
self.data.keysValuesDo { arg key, val;
if(val.classtype == \control, {
[val.name, set].debug("setting noteline");
@@ -2067,6 +1823,17 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
self.noteline = set;
},
+ set_sampleline: { arg self, set;
+ 1.erreur;
+ self.data.keysValuesDo { arg key, val;
+ if(val.classtype == \control, {
+ [val.name, set].debug("setting sampleline");
+ val.sampleline = set
+ })
+ };
+ self.sampleline = set;
+ },
+
clone: { arg self;
var pl;
pl = ~make_player_from_synthdef.(main,defname);
@@ -2107,7 +1874,7 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
data.name = defname;
data.defname = defname;
data.bank = self.bank;
- data.noteline = self.noteline;
+ data.current_mode = self.get_mode;
data.sourcewrapper = self.sourcewrapper;
data;
},
@@ -2122,7 +1889,7 @@ Spec.add(\amp, ControlSpec(0, 3, \lin, 0.0001, 0));
};
self.bank = data.bank;
self.set_wrapper_code(data.sourcewrapper);
- self.set_noteline(data.noteline ?? false);
+ self.set_mode(data.current_mode ?? \stepline);
},
save_column_preset: { arg self;
View
242 samplelib.sc
@@ -1,121 +1,137 @@
(
-~make_sample_cell = { arg parent, label;
- var bt;
-
- bt = GUI.button.new(parent, Rect(50,50,200,30));
- bt.states = [
- [ label, Color.black, Color.white],
- ];
- bt.value = 0;
-
-};
-
-~samplelib_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));
-
- //parent.view.background = ~editplayer_color_scheme.background;
- ~make_view_responder.(sl_layout, controller, (
-
- redraw: {
- controller.model.debug("rederaw");
- sl_layout.removeAll;
- sl_layout.focus(true);
- controller.model.samplelist.clump(4).clump(8)[controller.model.bank].do { arg col;
- ps_col_layout = GUI.vLayoutView.new(sl_layout, Rect(0,0,(160),60*6));
- ps_col_layout.background = ~editplayer_color_scheme.control;
-
- col.do { arg label;
- ~make_sample_cell.(ps_col_layout, label);
- };
- }
- }
- ))
-};
-
-
-
-~make_samplelib = { arg main;
-
- var obj;
-
- obj = (
-
- model: (
- //samplelist: {arg i; "sounds/default" ++ i }!50,
- samplelist: main.model.samplelist,
- bank: 0
- ),
-
- kb_handler: Dictionary.new,
-
- refresh: { arg self;
- self.changed(\redraw);
- },
-
- set_bank: { arg self, idx;
- self.model.bank = idx;
- self.changed(\redraw);
- },
-
- get_sample_xy: { arg self, x, y;
- self.model.samplelist[ (self.model.bank * 32) + (x * 4) + y ];
- },
-
- choose_sample: { arg self, action;
- ~kbpad8x4.do { arg line, iy;
- line.do { arg key, ix;
- self.kb_handler[[0, key]] = { action.(self.get_sample_xy(ix, iy),self.window )};
- }
- };
-
- ~kbnumpad.do { arg keycode, idx;
- self.kb_handler[[0, keycode]] = { self.set_bank(idx) };
- };
- },
-
- init: { arg self;
- var parent;
- "zarb".debug("oui");
- self.window = parent = Window.new("Sample Lib",Rect(100,Window.screenBounds.height-400, 1220,300));
-
- self.model.samplelist.debug("samplelist");
- ~samplelib_view.(parent, self);
-
-
- parent.view.keyDownAction = { arg view, char, modifiers, u, k;
- u.debug("slooooooooooooo u");
- modifiers.debug("slooooooooooooo modifiers");
- self.kb_handler.debug("kb");
- self.kb_handler[[modifiers,u]].value
- };
- parent.front;
- "zarb".debug("oui2");
-
- }
-
- );
- obj.init;
- obj;
-
-};
-
-~choose_sample = { arg main, action;
- var sl;
- sl = ~make_samplelib.(main);
- sl.choose_sample(action);
-};
+//~make_sample_cell = { arg parent, label;
+// var bt;
+//
+// bt = GUI.button.new(parent, Rect(50,50,200,30));
+// bt.states = [
+// [ label, Color.black, Color.white],
+// ];
+// bt.value = 0;
+//
+//};
+//
+//~samplelib_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));
+//
+// //parent.view.background = ~editplayer_color_scheme.background;
+// ~make_view_responder.(sl_layout, controller, (
+//
+// redraw: {
+// controller.model.debug("rederaw");
+// sl_layout.removeAll;
+// sl_layout.focus(true);
+// controller.model.samplelist.clump(4).clump(8)[controller.model.bank].do { arg col;
+// ps_col_layout = GUI.vLayoutView.new(sl_layout, Rect(0,0,(160),60*6));
+// ps_col_layout.background = ~editplayer_color_scheme.control;
+//
+// col.do { arg label;
+// ~make_sample_cell.(ps_col_layout, label);
+// };
+// }
+// }
+// ))
+//};
+//
+//
+//
+//~make_samplelib = { arg main;
+//
+// var obj;
+//
+// obj = (
+//
+// model: (
+// //samplelist: {arg i; "sounds/default" ++ i }!50,
+// samplelist: main.model.samplelist,
+// bank: 0
+// ),
+//
+// kb_handler: Dictionary.new,
+//
+// refresh: { arg self;
+// self.changed(\redraw);
+// },
+//
+// set_bank: { arg self, idx;
+// self.model.bank = idx;
+// self.changed(\redraw);
+// },
+//
+// get_sample_xy: { arg self, x, y;
+// self.model.samplelist[ (self.model.bank * 32) + (x * 4) + y ];
+// },
+//
+// choose_sample: { arg self, action;
+// ~kbpad8x4.do { arg line, iy;
+// line.do { arg key, ix;
+// self.kb_handler[[0, key]] = { action.(self.get_sample_xy(ix, iy),self.window )};
+// }
+// };
+//
+// ~kbnumpad.do { arg keycode, idx;
+// self.kb_handler[[0, keycode]] = { self.set_bank(idx) };
+// };
+// },
+//
+// init: { arg self;
+// var parent;
+// "zarb".debug("oui");
+// self.window = parent = Window.new("Sample Lib",Rect(100,Window.screenBounds.height-400, 1220,300));
+//
+// self.model.samplelist.debug("samplelist");
+// ~samplelib_view.(parent, self);
+//
+//
+// parent.view.keyDownAction = { arg view, char, modifiers, u, k;
+// u.debug("slooooooooooooo u");
+// modifiers.debug("slooooooooooooo modifiers");
+// self.kb_handler.debug("kb");
+// self.kb_handler[[modifiers,u]].value
+// };
+// parent.front;
+// "zarb".debug("oui2");
+//
+// }
+//
+// );
+// obj.init;
+// obj;
+//
+//};
+//
+//~choose_sample = { arg main, action;
+// var sl;
+// sl = ~make_samplelib.(main);
+// sl.choose_sample(action);
+//};
//~choose_sample.(nil, { arg x; x.debug("yeak") });
~samplekit_bank = Dictionary[
- \plop -> [
- "plop.wav"
+ \default -> [
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/sn_Wet_b.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/misc_Cowbell.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/tom_Rock_mid.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/kick_Dry_b.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/hhp_Dry_a.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/clap_Dry_c.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/cym_Jazz.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/hhc_Rock_b.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/cra_Rock_a.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/hhc_Dry_a.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/tom_Rock_hi.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/sn_Jazz_c.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/emptySample.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/cym_Rock_b.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/tom_Rock_lo.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/cra_Jazz.flac",
+ "/home/ggz/share/SuperCollider/sounds/hydrogen/GMkit/stick_Woody.flac"
]
];
@@ -126,6 +142,10 @@
} {
BufferPool.get_sample(\samplekit, ~samplekit_bank[samplekit][slot]).bufnum;
};
+ },
+
+ midinote_to_slot: { arg self, midinote;
+ ~keycode.midi[midinote][1]
}
);
View
356 sampleline
@@ -0,0 +1,356 @@
+~make_sampleline_param = { arg name, default_value=[];
+ var ret;
+ ret = (
+ name: name,
+ classtype: \sampleline,
+ selected_cell: 0,
+ selected: 0,
+ default_val: default_value.asList,
+ notes: ~default_sampleline.deepCopy,
+ start_offset: 0,
+ end_offset: 0,
+ muted: false,
+ archive_data: [\name, \classtype, \selected, \selected_cell, \default_val, \notes, \start_offset, \end_offset, \notequant],
+ notequant: nil,
+ vnotes: [],
+
+ save_data: { arg self;
+ var data = ();
+ self.archive_data.do {
+ arg key;
+ data[key] = self[key];
+ };
+ [\seq].do { arg kind;
+ data[kind] = ();
+ [\val].do { arg key;
+ data[kind][key] = self[kind][key];
+ }
+ };
+ data;
+ },
+
+ load_data: { arg self, data;
+ self.archive_data.do {
+ arg key;
+ self[key] = data[key];
+ };
+ [\seq].do { arg kind;
+ [\val].do { arg key;
+ self[kind][key] = data[kind][key];
+ }
+ };
+ },
+
+ seq: (
+ val: default_value.asList,
+ change: { arg self, fun;
+ self.val = fun.(self.val);
+ }
+ ),
+ get_cells: { arg self;
+ self.seq.val;
+ },
+ get_selected_cell: { arg self;
+ self.selected_cell;
+ },
+ select_param: { arg self;
+ self.selected = 1;
+ self.changed(\selected);
+ },
+ deselect_param: { arg self;
+ self.selected = 0;
+ self.changed(\selected);
+ },
+
+ add_cells: { arg self, cells;
+ self.seq.val.addAll(cells);
+ self.changed(\cells);
+ },
+
+ remove_cells: { arg self, num;
+ self.seq.val = self.seq.val[.. (self.seq.val.size - num - 1) ];
+ self.changed(\cells);
+ },
+
+ set_val: { arg self, val;
+ self.seq.val[ self.get_selected_cell.() ] = if(val > 1, { 1 },{ 0 });
+ },
+
+ get_notes: { arg self;
+ var no;
+ no = self.vnotes.deepCopy;
+ //no[0].dur+self.start_offset;
+ //no.last.dur+self.end_offset;
+ no.debug("£££££££££££££££££££££££££££££sampleline param: get_notes");
+ no;
+ },
+
+ set_notes: { arg self, val;
+ self.notes = val;
+ val.debug("£££££££££££££££££££££££££££££sampleline param: set_notes");
+ self.update_note_dur;
+ },
+
+ trans_notes: { arg self;
+ // make sample slots compatibles with other code using midinotes
+ self.notes = self.notes.collect { arg x;
+ x.midinote = x.slotnum;
+ };
+ },
+
+ get_note: { arg self, idx;
+ var no, res;
+ [idx, self.vnotes].debug("sampleline param: get_note");
+ res = if( self.vnotes.size > 0 && {self.muted.not}) {
+ no = self.vnotes[idx].deepCopy;
+ if( no.notNil && (self.notequant.notNil) ) {
+ no.dur = no.dur.round(self.notequant);
+ "1".debug;
+ no;
+ } {
+ "2".debug;
+ no
+ }
+ } {
+ "sampleline_param: get_node: No notes".inform;
+ if(idx == 0) {
+ "3".debug;
+ ~empty_note;
+ } {
+ "4".debug;
+ nil;
+ };
+ };
+ res.debug("sampleline param: get_note: res");
+ },
+
+ total_dur: { arg self, notes;
+ var res=0;
+ notes.do { arg x; res = x.dur + res; };
+ res;
+ },
+
+ update_note_dur: { arg self;
+ var find_next, find_prev, delta, prevdelta, idx, previdx;
+ "update_note_dur".debug("start");
+ self.trans_notes;
+
+ if( self.notes.size > 2) {
+ find_next = { arg dur, notes;
+ var res=0, vidx=0, last=nil, delta=0, prevdelta=0;
+ dur.debug("find_next: dur");
+ if(dur == 0) {
+ delta = 0;
+ vidx = 0
+ } {
+ notes[1..].do { arg x, n;
+ [n, res, vidx, last, dur].debug("begin n res vidx last");
+ if( res < dur ) {
+ res = x.dur + res;
+ vidx = vidx + 1;
+ last = x.dur;
+ };
+ [n, res, vidx, last].debug("end");
+ };
+ delta = res - dur;
+ };
+ [ delta, vidx+1 ];
+ };
+
+ find_prev = { arg dur, notes;
+ var res=0, vidx=0, last=nil, delta=0, prevdelta=0;
+ dur = self.total_dur( notes[1..(notes.lastIndex-1)] ).debug("total dur") - dur;
+ dur.debug("find_prev: dur");
+
+ notes[1..].do { arg x, n;
+ [n, res, vidx, last].debug("begin n res vidx last");
+ if( res <= dur ) {
+ res = x.dur + res;
+ vidx = vidx + 1;
+ last = x.dur;
+ };
+ [n, res, vidx, last].debug("end");
+ };
+ delta = res - dur;
+ if(last.isNil) {
+ prevdelta = nil
+ } {
+ last.debug("last");
+ prevdelta = last - delta;
+ };
+ [ prevdelta, vidx ];
+ };
+
+ #delta, idx = find_next.(self.notes[0].start_offset, self.notes);
+ #prevdelta, previdx = find_prev.(self.notes[0].end_offset, self.notes);
+ [delta, idx, prevdelta, previdx].debug("delta, idx, prevdelta, previdx");
+ self.notes[0].dur = self.notes[0].start_silence + delta;
+ self.vnotes = [self.notes[0]] ++ self.notes[idx..previdx].deepCopy;
+ self.vnotes[self.vnotes.lastIndex].dur = self.notes[0].end_silence + prevdelta;
+ self.vnotes.debug("sampleline update_note_dur: vnotes");
+ self.changed(\notes);
+ } {
+ if(self.notes.size == 2) {
+ self.vnotes = self.notes.deepCopy;
+ if( (self.notes[0].start_silence + self.notes[0].end_silence) < 0.01 ) {
+ "Protection anti infinite loop: setting end_silence to 0.5".error;
+ self.notes[0].end_silence = 0.5
+ };
+ self.vnotes[0].dur = self.notes[0].start_silence;
+ self.vnotes[self.vnotes.lastIndex].dur = self.notes[0].end_silence;
+ self.vnotes.debug("sampleline update_note_dur: vnotes");
+ self.changed(\notes);
+ }
+ }
+
+ },
+
+ set_start_offset: { arg self, val;
+ var dur;
+ if(self.notes.size > 2 ) {
+ dur = self.total_dur( self.notes[1..(self.notes.lastIndex-1)] );
+ if( val >= 0 && (val < (dur - self.notes[0].end_offset)) ) {
+ [val, dur, self.notes[0].end_offset, dur - self.notes[0].end_offset].debug("set start_offset: val, dur, eo, dur-eo");
+ self.notes[0].start_offset = val;
+ self.update_note_dur;
+ } {
+ [val, dur, self.notes[0].end_offset, dur - self.notes[0].end_offset].debug("can't set start_offset: val, dur, eo, dur-eo");
+ }
+ } {
+ "You are stupid!".debug;
+ }
+ },
+
+ set_end_offset: { arg self, val;
+ var dur;
+ if(self.notes.size > 0) {
+ dur = self.total_dur( self.notes[1..(self.notes.lastIndex-1)] );
+ if( val >= 0 && (val < (dur - self.notes[0].start_offset)) ) {
+ [val, dur, self.notes[0].end_offset, dur - self.notes[0].end_offset].debug("can't set end_offset: val, dur, so, dur-so");
+ self.notes[0].end_offset = val;
+ self.update_note_dur;
+ } {
+ [val, dur, self.notes[0].start_offset, dur - self.notes[0].start_offset].debug("can't set end_offset: val, dur, so, dur-so");
+ }
+ }
+ },
+
+ get_start_offset: { arg self;
+ if(self.notes.size > 0) {
+ self.notes[0].start_offset;
+ }
+ },
+
+ get_end_offset: { arg self;
+ if(self.notes.size > 0) {
+ self.notes[0].end_offset;
+ }
+ },
+
+ set_start_silence: { arg self, val;
+
+ if(self.notes.size > 0 && (val >= 0)) {
+ self.notes[0].start_silence = val;
+ self.update_note_dur;
+ } {
+ [val, self.notes.size].debug("can't set start_silence: val, notessize");
+ }
+ },
+
+ set_end_silence: { arg self, val;
+
+ if(self.notes.size > 0 && (val >= 0)) {
+ self.notes[0].end_silence = val;
+ self.update_note_dur;
+ } {
+ [val, self.notes.size].debug("can't set end_silence: val, notessize");
+
+ };
+ },
+
+ get_start_silence: { arg self;
+ if(self.notes.size > 0) {
+ self.notes[0].start_silence;
+ }
+
+ },
+
+ get_end_silence: { arg self;
+ if(self.notes.size > 0) {
+ self.notes[0].end_silence;
+ }
+
+ },
+
+ set_first_note_dur: { arg self, val;
+ var res = 0, lastdur = 0, vidx = 0;
+ if( self.notes.size > 0) {
+ self.notes[0].dur = val;
+ if( val < 0 ) {
+ self.notes.do { arg x;
+ if( res < val.neg ) {
+ res = x.dur + res;
+ vidx = vidx + 1;
+ lastdur = x.dur;
+ }
+ };
+ self.notes[0].virtual_start_idx = vidx -1;
+ self.notes[0].virtual_start_dur = res - val.neg;
+ }
+ }
+ },
+
+ get_first_note_dur: { arg self;
+ self.notes.size.debug("get_first_note_dur self.notes.size");
+ if( self.notes.size > 0) {
+ self.notes[0].dur;
+ } {
+ nil
+ }
+ },
+
+ set_notequant: { arg self, val;
+ self.notequant = val;
+ self.changed(\notes);
+ },
+
+ tick: { arg idx;
+ "£££££££££££££££££££££££££££££££££££££TICK"
+ //"TICK!".postln;
+ },
+
+ mute: { arg self, val;
+ self.muted = val;
+ },
+
+ toggle_cell: { arg self, idx;
+ var oldsel;
+ [idx, self.get_cells].debug("make_control_param.select_cell idx, selg.get_cells");
+ if( idx < self.get_cells.size, {
+ //oldsel = self.selected_cell;
+ self.selected_cell = idx;
+ //self.changed(\selected_cell, oldsel);
+ self.seq.val[ idx ] = ~toggle_value.(self.seq.val[ idx ]);
+ self.changed(\val, self.selected_cell);
+ })
+ },
+ refresh: { arg self;
+ self.update_note_dur;
+ self.get_notes.debug("noteline param refresh: get_notes");
+ self.changed(\notes);
+ self.changed(\selected);
+ },
+ vpattern: { arg self;
+ //"YE SOUI PREMIER!!!!".debug;
+ "--------making vpattern of sampleline".debug;
+ ~pdynarray.( { arg idx;
+ self.tick;
+ [idx, self.get_note(idx)].debug("4444444444444444444444444444444444444 sampleline vpattern: note");
+ self.get_note(idx);
+ }, \sampleline );
+ //self.get_note(0);
+ };
+
+ );
+ ret;
+};
View
12 score.sc
@@ -225,11 +225,7 @@
//node.debug("get_paramlist:node");
node = main.get_node(nodename);
if(node.kind == \player) {
- if( node.noteline == true, {
- list.add(node -> node.get_arg(\noteline));
- },{
- list.add(node -> node.get_arg(\stepline));
- });
+ list.add(node -> node.get_arg(node.get_mode));
}
});
};
@@ -292,12 +288,12 @@
main.commands.array_add_enable([\score, \select_param], [\kb, ~keycode.mod.alt], ~keycode.kbnumline, { arg i; self.select_param(i) });
main.commands.add_enable([\score, \set_noteline_mode], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["n"]], {
- self.get_selected_player.set_noteline(true);
+ self.get_selected_player.set_mode(\noteline);
self.changed(\paramlist);
});
- main.commands.add_enable([\score, \unset_noteline_mode], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["b"]], {
- self.get_selected_player.set_noteline(false);
+ main.commands.add_enable([\score, \set_stepline_mode], [\kb, ~keycode.mod.alt, ~keycode.kbaalphanum["b"]], {
+ self.get_selected_player.set_mode(\stepline);
self.changed(\paramlist);
});
Please sign in to comment.
Something went wrong with that request. Please try again.