Brute force MIDI notes

This commit is contained in:
2024-05-12 23:45:11 +02:00
parent 25745504b2
commit f98a22f3a0
2 changed files with 51 additions and 19 deletions

View File

@ -4,7 +4,7 @@ EventShortener {
arg pattern, key, type, time; arg pattern, key, type, time;
var additionalKeys = Dictionary.newFrom([ var additionalKeys = Dictionary.newFrom([
\midi, [ \midi, [
type: \midi type: \midi,
], ],
\buboEvent, [ \buboEvent, [
type: \buboEvent, type: \buboEvent,
@ -18,26 +18,31 @@ EventShortener {
]); ]);
pattern = this.findShortcuts(pattern); pattern = this.findShortcuts(pattern);
pattern = this.functionsToNdef(pattern, key); pattern = this.functionsToNdef(pattern, key);
pattern = pattern ++ additionalKeys[type] ; pattern = pattern ++ additionalKeys[type];
if (pattern.includes('pat'), { if (pattern.includes('pat'), {
pattern = this.patternize(pattern); pattern = this.patternize(pattern, type);
}); });
pattern.postln;
^pattern ^pattern
} }
*patternize { *patternize {
arg pattern; arg pattern, type;
var delta_index = nil;
var new_pattern = List(); var new_pattern = List();
pattern.doAdjacentPairs({ pattern.doAdjacentPairs({
arg a, b, index; arg a, b, index;
if (index % 2 == 0, { if (index % 2 == 0, {
if (a === 'pat', { if (a === 'pat', {
var temp = Pmini(b); var temp = Pmini(b);
temp.pattern.postln; var additionalKeys;
if (type == 'midi', {
additionalKeys = [\trig, \delta, \dur, \str];
new_pattern = new_pattern ++ [\type, 'midi'];
}, {
additionalKeys = [\trig, \delta, \dur, \str, \num];
});
new_pattern = new_pattern ++ [ new_pattern = new_pattern ++ [
[\trig, \delta, \dur, \str, \num], additionalKeys, temp
temp
]; ];
new_pattern = new_pattern ++ [ new_pattern = new_pattern ++ [
degree: Pfunc({ |e| degree: Pfunc({ |e|
@ -48,20 +53,21 @@ EventShortener {
} }
)}); )});
]; ];
if (pattern.includes(\midi) || pattern.includes('i') || pattern.includes('instrument') == false, { if (type !== 'midi', {
new_pattern = new_pattern ++ [ if (pattern.includes('i') || pattern.includes('instrument') == false, {
sp: Pkey(\str), new_pattern = new_pattern ++ [
nb: Pkey(\num), sp: Pkey(\str),
fast: 1, nb: Pkey(\num),
]; fast: 1,
}); ];
});
})
}, { }, {
new_pattern.add(a); new_pattern.add(a);
new_pattern.add(b); new_pattern.add(b);
}); });
}) })
}); });
new_pattern.postln;
^new_pattern ^new_pattern
} }

View File

@ -1,12 +1,14 @@
MIDIClient.destinations; // NOTE: ajouter un truc pour tuer tout le MIDI quand j'appuie sur F12
m
// NOTE: Pattern rythmique de base
( (
~test => [ sp: "kick", nb: 0 ]; ~test => [ sp: "kick", nb: 0 ];
~test.play; ~test.play;
) )
// NOTE: Pattern de base, explicite (sans clés magiques)
( (
~test = Pbind( ~test = Pbind(
\instrument, 'splayer', \instrument, 'splayer',
@ -15,6 +17,7 @@ m
~test.play; ~test.play;
) )
( (
~test >> [ ~test >> [
pat: "0 2 3 4", pat: "0 2 3 4",
@ -29,10 +32,33 @@ m = MIDIOut.newByName("MIDI", "Bus 1");
~test.play; ~test.play;
) )
// NOTE: Sans pattern Pmini
(
m = MIDIOut.newByName("MIDI", "Bus 1");
~test >> [ degree: [0, 2, 3, 4].pseq(inf), midiout: m ];
~test.play;
)
// NOTE: Avec Pmini + type explicite
(
m = MIDIOut.newByName("MIDI", "Bus 1");
~test >> [type: 'midi', pat: "0 1 2 3", midiout: m];
~test.play;
)
// NOTE: Avec Pmini, sans type explicite
(
m = MIDIOut.newByName("MIDI", "Bus 1");
~test >> [pat: "0 1 2 3", midiout: m];
~test.play;
)
// NOTE: : Pattern de démonstration
( (
~baba = Pbind( ~baba = Pbind(
\type, \midi, \type, \midi,
[\trig, \delta, \dur, \str, \num], Pmini("[1 2 3 4]/2"), [\trig, \delta, \dur, \str, \num], Pmini("[1 ~ 2 3 4]/2").trace,
\degree, Pfunc({ |e| if(e.trig > 0) { e.str.asInteger } { \rest } }), \degree, Pfunc({ |e| if(e.trig > 0) { e.str.asInteger } { \rest } }),
\midiout, m \midiout, m
); );