Last changes: trying to integrate Pmini
This commit is contained in:
@ -1,5 +1,76 @@
|
||||
EventShortener {
|
||||
|
||||
*process {
|
||||
arg pattern, key, other_keys;
|
||||
if (pattern.includes('pat'), {
|
||||
pattern = this.patternize(pattern);
|
||||
});
|
||||
pattern = this.findShortcuts(pattern);
|
||||
pattern = this.functionsToNdef(pattern, key);
|
||||
pattern = pattern ++ other_keys ;
|
||||
^pattern
|
||||
}
|
||||
|
||||
*patternize {
|
||||
arg pattern;
|
||||
var delta_index = nil;
|
||||
var new_pattern = List();
|
||||
pattern.doAdjacentPairs({
|
||||
arg a, b, index;
|
||||
if (index % 2 == 0, {
|
||||
if (a === 'pat', {
|
||||
var temp = Pmini(b);
|
||||
temp.pattern.postln;
|
||||
new_pattern = new_pattern ++ [
|
||||
[\trig, \delta, \dur, \str, \num],
|
||||
temp
|
||||
];
|
||||
new_pattern = new_pattern ++ [
|
||||
degree: Pfunc({ |e|
|
||||
if (e.trig > 0, {
|
||||
e.str.asInteger
|
||||
}, {
|
||||
\rest
|
||||
}
|
||||
)});
|
||||
];
|
||||
if (pattern.includes('i') || pattern.includes('instrument') == false, {
|
||||
new_pattern = new_pattern ++ [
|
||||
sp: Pkey(\str),
|
||||
nb: Pkey(\num),
|
||||
fast: 1,
|
||||
];
|
||||
});
|
||||
}, {
|
||||
new_pattern.add(a);
|
||||
new_pattern.add(b);
|
||||
});
|
||||
})
|
||||
});
|
||||
^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();
|
||||
pattern.do({
|
||||
| element, i |
|
||||
if (element.isKindOf(Function), {
|
||||
new_pattern.add(Ndef((key ++ pattern[i - 1]).asSymbol, element))
|
||||
}, {
|
||||
new_pattern.add(element)
|
||||
});
|
||||
})
|
||||
^new_pattern
|
||||
}
|
||||
|
||||
*findShortcuts {
|
||||
arg pattern;
|
||||
var short, correctedPattern;
|
||||
@ -38,13 +109,13 @@ EventShortener {
|
||||
\scl, \scale,
|
||||
]);
|
||||
|
||||
// shortcuts are turned into regular keys;
|
||||
pattern.do({| element |
|
||||
pattern.do({| element, i |
|
||||
if (short.includesKey(element),
|
||||
{correctedPattern.add(short[element])},
|
||||
{correctedPattern.add(element)}
|
||||
);
|
||||
});
|
||||
|
||||
^correctedPattern;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user