refactor eventshortener
This commit is contained in:
@ -1,8 +1,6 @@
|
|||||||
|
|
||||||
+ NodeProxy {
|
+ NodeProxy {
|
||||||
|
|
||||||
/* Simple FX chain management */
|
|
||||||
|
|
||||||
fx {
|
fx {
|
||||||
arg number=1, wet=1, function = {|in| in};
|
arg number=1, wet=1, function = {|in| in};
|
||||||
this[number] = \filter -> function;
|
this[number] = \filter -> function;
|
||||||
@ -51,9 +49,7 @@
|
|||||||
var quant = this.getQuantFromPattern(pattern);
|
var quant = this.getQuantFromPattern(pattern);
|
||||||
var fade = this.getFadeFromPattern(pattern);
|
var fade = this.getFadeFromPattern(pattern);
|
||||||
pattern = EventShortener.process(
|
pattern = EventShortener.process(
|
||||||
pattern,
|
pattern, this.key, \midi, 0
|
||||||
this.key,
|
|
||||||
[type: 'midi']
|
|
||||||
);
|
);
|
||||||
this[0] = Pbind(*pattern);
|
this[0] = Pbind(*pattern);
|
||||||
this.prepareToPlay(this, quant, fade);
|
this.prepareToPlay(this, quant, fade);
|
||||||
@ -66,9 +62,7 @@
|
|||||||
var quant = this.getQuantFromPattern(pattern);
|
var quant = this.getQuantFromPattern(pattern);
|
||||||
var fade = this.getFadeFromPattern(pattern);
|
var fade = this.getFadeFromPattern(pattern);
|
||||||
pattern = EventShortener.process(
|
pattern = EventShortener.process(
|
||||||
pattern,
|
pattern, this.key, \buboEvent, 0
|
||||||
this.key,
|
|
||||||
[\type, \buboEvent]
|
|
||||||
);
|
);
|
||||||
this[0] = Pbind(*pattern);
|
this[0] = Pbind(*pattern);
|
||||||
this.prepareToPlay(this, quant, fade);
|
this.prepareToPlay(this, quant, fade);
|
||||||
@ -84,13 +78,7 @@
|
|||||||
var nbSlices = this.getValueFromPattern(pattern, 'slices', 1);
|
var nbSlices = this.getValueFromPattern(pattern, 'slices', 1);
|
||||||
var time = (Pkey(\dur) / Pfunc { currentEnvironment.clock.tempo }) / nbSlices;
|
var time = (Pkey(\dur) / Pfunc { currentEnvironment.clock.tempo }) / nbSlices;
|
||||||
pattern = EventShortener.process(
|
pattern = EventShortener.process(
|
||||||
pattern,
|
pattern, this.key, \looper, time
|
||||||
this.key,
|
|
||||||
[
|
|
||||||
\type, \buboLoopEvent,
|
|
||||||
\legato, 1,
|
|
||||||
\time, time
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
this[0] = Pmono(*pattern);
|
this[0] = Pmono(*pattern);
|
||||||
this.prepareToPlay(this, quant, fade);
|
this.prepareToPlay(this, quant, fade);
|
||||||
@ -102,41 +90,14 @@
|
|||||||
arg pattern;
|
arg pattern;
|
||||||
var quant = this.getQuantFromPattern(pattern);
|
var quant = this.getQuantFromPattern(pattern);
|
||||||
var fade = this.getFadeFromPattern(pattern);
|
var fade = this.getFadeFromPattern(pattern);
|
||||||
pattern = EventShortener.processPmono(
|
pattern = EventShortener.process(
|
||||||
pattern,
|
pattern, this.key, 'pmono', 0
|
||||||
this.key
|
|
||||||
);
|
);
|
||||||
this[0] = Pmono(*pattern);
|
this[0] = Pmono(*pattern);
|
||||||
this.prepareToPlay(this; quant, fade);
|
this.prepareToPlay(this; quant, fade);
|
||||||
^this
|
^this
|
||||||
}
|
}
|
||||||
|
|
||||||
f {
|
|
||||||
arg value;
|
|
||||||
this.fadeTime = value;
|
|
||||||
^this
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
arg quant, fade;
|
|
||||||
this.quant = quant;
|
|
||||||
this.fadeTime = fade;
|
|
||||||
this.play(fadeTime: fade);
|
|
||||||
^this
|
|
||||||
}
|
|
||||||
|
|
||||||
s {
|
|
||||||
arg duration;
|
|
||||||
this.stop(fadeTime: duration)
|
|
||||||
^this
|
|
||||||
}
|
|
||||||
|
|
||||||
/ {
|
|
||||||
arg pattern;
|
|
||||||
this.stop(1);
|
|
||||||
^this
|
|
||||||
}
|
|
||||||
|
|
||||||
getValueFromPattern {
|
getValueFromPattern {
|
||||||
arg pattern, key, default;
|
arg pattern, key, default;
|
||||||
var keyIndex = pattern.indexOf(key);
|
var keyIndex = pattern.indexOf(key);
|
||||||
@ -156,6 +117,4 @@
|
|||||||
arg pattern;
|
arg pattern;
|
||||||
^this.getValueFromPattern(pattern, 'fade', 0.01)
|
^this.getValueFromPattern(pattern, 'fade', 0.01)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,27 @@
|
|||||||
EventShortener {
|
EventShortener {
|
||||||
|
|
||||||
*process {
|
*process {
|
||||||
arg pattern, key, other_keys;
|
arg pattern, key, type, time;
|
||||||
|
var additionalKeys = Dictionary.newFrom([
|
||||||
|
\midi, [
|
||||||
|
type: \midi
|
||||||
|
],
|
||||||
|
\buboEvent, [
|
||||||
|
type: \buboEvent,
|
||||||
|
],
|
||||||
|
\looper, [
|
||||||
|
type: \buboLoopEvent,
|
||||||
|
legato: 1,
|
||||||
|
time: time
|
||||||
|
],
|
||||||
|
\pmono, [],
|
||||||
|
]);
|
||||||
|
pattern = this.findShortcuts(pattern);
|
||||||
|
pattern = this.functionsToNdef(pattern, key);
|
||||||
|
pattern = pattern ++ additionalKeys[type] ;
|
||||||
if (pattern.includes('pat'), {
|
if (pattern.includes('pat'), {
|
||||||
pattern = this.patternize(pattern);
|
pattern = this.patternize(pattern);
|
||||||
});
|
});
|
||||||
pattern = this.findShortcuts(pattern);
|
|
||||||
pattern = this.functionsToNdef(pattern, key);
|
|
||||||
pattern = pattern ++ other_keys ;
|
|
||||||
^pattern
|
^pattern
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +48,7 @@ EventShortener {
|
|||||||
}
|
}
|
||||||
)});
|
)});
|
||||||
];
|
];
|
||||||
if (pattern.includes('i') || pattern.includes('instrument') == false, {
|
if (pattern.includes(\midi) || pattern.includes('i') || pattern.includes('instrument') == false, {
|
||||||
new_pattern = new_pattern ++ [
|
new_pattern = new_pattern ++ [
|
||||||
sp: Pkey(\str),
|
sp: Pkey(\str),
|
||||||
nb: Pkey(\num),
|
nb: Pkey(\num),
|
||||||
@ -47,16 +61,10 @@ EventShortener {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
new_pattern.postln;
|
||||||
^new_pattern
|
^new_pattern
|
||||||
}
|
}
|
||||||
|
|
||||||
*processPmono {
|
|
||||||
arg pattern, key;
|
|
||||||
pattern = this.findShortcuts(pattern);
|
|
||||||
pattern = this.functionsToNdef(pattern, key);
|
|
||||||
^pattern
|
|
||||||
}
|
|
||||||
|
|
||||||
*functionsToNdef {
|
*functionsToNdef {
|
||||||
arg pattern, key;
|
arg pattern, key;
|
||||||
var new_pattern = List.new();
|
var new_pattern = List.new();
|
||||||
|
|||||||
40
with_midi.scd
Normal file
40
with_midi.scd
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
MIDIClient.destinations;
|
||||||
|
|
||||||
|
m
|
||||||
|
|
||||||
|
(
|
||||||
|
~test => [ sp: "kick", nb: 0 ];
|
||||||
|
~test.play;
|
||||||
|
)
|
||||||
|
|
||||||
|
(
|
||||||
|
~test = Pbind(
|
||||||
|
\instrument, 'splayer',
|
||||||
|
\sp, Bank("kick")[0],
|
||||||
|
);
|
||||||
|
~test.play;
|
||||||
|
)
|
||||||
|
|
||||||
|
(
|
||||||
|
~test >> [
|
||||||
|
pat: "0 2 3 4",
|
||||||
|
midiout: m
|
||||||
|
];
|
||||||
|
~test.play;
|
||||||
|
)
|
||||||
|
|
||||||
|
(
|
||||||
|
m = MIDIOut.newByName("MIDI", "Bus 1");
|
||||||
|
~test >> [ pat: "0 2 3 4", midiout: m ];
|
||||||
|
~test.play;
|
||||||
|
)
|
||||||
|
|
||||||
|
(
|
||||||
|
~baba = Pbind(
|
||||||
|
\type, \midi,
|
||||||
|
[\trig, \delta, \dur, \str, \num], Pmini("[1 2 3 4]/2"),
|
||||||
|
\degree, Pfunc({ |e| if(e.trig > 0) { e.str.asInteger } { \rest } }),
|
||||||
|
\midiout, m
|
||||||
|
);
|
||||||
|
~baba.play;
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user