From f98a22f3a0004c3442ae3b6b66fc0480a5ab94da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Forment?= Date: Sun, 12 May 2024 23:45:11 +0200 Subject: [PATCH] Brute force MIDI notes --- Classes/EventShortener.sc | 38 ++++++++++++++++++++++---------------- with_midi.scd | 32 +++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 19 deletions(-) diff --git a/Classes/EventShortener.sc b/Classes/EventShortener.sc index 189258b..ee1b5b7 100644 --- a/Classes/EventShortener.sc +++ b/Classes/EventShortener.sc @@ -4,7 +4,7 @@ EventShortener { arg pattern, key, type, time; var additionalKeys = Dictionary.newFrom([ \midi, [ - type: \midi + type: \midi, ], \buboEvent, [ type: \buboEvent, @@ -18,26 +18,31 @@ EventShortener { ]); pattern = this.findShortcuts(pattern); pattern = this.functionsToNdef(pattern, key); - pattern = pattern ++ additionalKeys[type] ; + pattern = pattern ++ additionalKeys[type]; if (pattern.includes('pat'), { - pattern = this.patternize(pattern); + pattern = this.patternize(pattern, type); }); + pattern.postln; ^pattern } *patternize { - arg pattern; - var delta_index = nil; + arg pattern, type; var new_pattern = List(); pattern.doAdjacentPairs({ arg a, b, index; if (index % 2 == 0, { if (a === 'pat', { 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 ++ [ - [\trig, \delta, \dur, \str, \num], - temp + additionalKeys, temp ]; new_pattern = new_pattern ++ [ degree: Pfunc({ |e| @@ -48,20 +53,21 @@ EventShortener { } )}); ]; - if (pattern.includes(\midi) || pattern.includes('i') || pattern.includes('instrument') == false, { - new_pattern = new_pattern ++ [ - sp: Pkey(\str), - nb: Pkey(\num), - fast: 1, - ]; - }); + if (type !== 'midi', { + 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.postln; ^new_pattern } diff --git a/with_midi.scd b/with_midi.scd index 9d23880..f7e8cd0 100644 --- a/with_midi.scd +++ b/with_midi.scd @@ -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.play; ) +// NOTE: Pattern de base, explicite (sans clés magiques) ( ~test = Pbind( \instrument, 'splayer', @@ -15,6 +17,7 @@ m ~test.play; ) + ( ~test >> [ pat: "0 2 3 4", @@ -29,10 +32,33 @@ m = MIDIOut.newByName("MIDI", "Bus 1"); ~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( \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 } }), \midiout, m );