refactor eventshortener
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
|
||||
+ NodeProxy {
|
||||
|
||||
/* Simple FX chain management */
|
||||
|
||||
fx {
|
||||
arg number=1, wet=1, function = {|in| in};
|
||||
this[number] = \filter -> function;
|
||||
@ -51,9 +49,7 @@
|
||||
var quant = this.getQuantFromPattern(pattern);
|
||||
var fade = this.getFadeFromPattern(pattern);
|
||||
pattern = EventShortener.process(
|
||||
pattern,
|
||||
this.key,
|
||||
[type: 'midi']
|
||||
pattern, this.key, \midi, 0
|
||||
);
|
||||
this[0] = Pbind(*pattern);
|
||||
this.prepareToPlay(this, quant, fade);
|
||||
@ -66,9 +62,7 @@
|
||||
var quant = this.getQuantFromPattern(pattern);
|
||||
var fade = this.getFadeFromPattern(pattern);
|
||||
pattern = EventShortener.process(
|
||||
pattern,
|
||||
this.key,
|
||||
[\type, \buboEvent]
|
||||
pattern, this.key, \buboEvent, 0
|
||||
);
|
||||
this[0] = Pbind(*pattern);
|
||||
this.prepareToPlay(this, quant, fade);
|
||||
@ -84,13 +78,7 @@
|
||||
var nbSlices = this.getValueFromPattern(pattern, 'slices', 1);
|
||||
var time = (Pkey(\dur) / Pfunc { currentEnvironment.clock.tempo }) / nbSlices;
|
||||
pattern = EventShortener.process(
|
||||
pattern,
|
||||
this.key,
|
||||
[
|
||||
\type, \buboLoopEvent,
|
||||
\legato, 1,
|
||||
\time, time
|
||||
]
|
||||
pattern, this.key, \looper, time
|
||||
);
|
||||
this[0] = Pmono(*pattern);
|
||||
this.prepareToPlay(this, quant, fade);
|
||||
@ -102,41 +90,14 @@
|
||||
arg pattern;
|
||||
var quant = this.getQuantFromPattern(pattern);
|
||||
var fade = this.getFadeFromPattern(pattern);
|
||||
pattern = EventShortener.processPmono(
|
||||
pattern,
|
||||
this.key
|
||||
pattern = EventShortener.process(
|
||||
pattern, this.key, 'pmono', 0
|
||||
);
|
||||
this[0] = Pmono(*pattern);
|
||||
this.prepareToPlay(this; quant, fade);
|
||||
^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 {
|
||||
arg pattern, key, default;
|
||||
var keyIndex = pattern.indexOf(key);
|
||||
@ -156,6 +117,4 @@
|
||||
arg pattern;
|
||||
^this.getValueFromPattern(pattern, 'fade', 0.01)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,27 @@
|
||||
EventShortener {
|
||||
|
||||
*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'), {
|
||||
pattern = this.patternize(pattern);
|
||||
});
|
||||
pattern = this.findShortcuts(pattern);
|
||||
pattern = this.functionsToNdef(pattern, key);
|
||||
pattern = pattern ++ other_keys ;
|
||||
^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 ++ [
|
||||
sp: Pkey(\str),
|
||||
nb: Pkey(\num),
|
||||
@ -47,16 +61,10 @@ EventShortener {
|
||||
});
|
||||
})
|
||||
});
|
||||
new_pattern.postln;
|
||||
^new_pattern
|
||||
}
|
||||
|
||||
*processPmono {
|
||||
arg pattern, key;
|
||||
pattern = this.findShortcuts(pattern);
|
||||
pattern = this.functionsToNdef(pattern, key);
|
||||
^pattern
|
||||
}
|
||||
|
||||
*functionsToNdef {
|
||||
arg pattern, key;
|
||||
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