refactor eventshortener

This commit is contained in:
2024-05-12 23:02:39 +02:00
parent 18487a52f5
commit 25745504b2
3 changed files with 65 additions and 58 deletions

View File

@ -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();