Improve pattern detection logic

This commit is contained in:
2024-05-15 12:30:04 +02:00
parent 27cbb48c98
commit f1781c745f
2 changed files with 130 additions and 9 deletions

View File

@ -49,8 +49,28 @@ EventShortener {
*patternBuboEvent {
arg pattern;
var new_pattern = List();
new_pattern = new_pattern ++ [\type, 'buboEvent'];
var sp_position = nil;
var nb_position = nil;
// Check if the sp key already exists in the pattern
if (pattern.includes('sp'), {
pattern.do({ arg e, i;
if (e == 'sp', {
sp_position = i;
})
});
});
// Check if the nb key already exists in the pattern
if (pattern.includes('nb'), {
pattern.do({ arg e, i;
if (e == 'nb', {
nb_position = i;
})
});
});
new_pattern = new_pattern ++ [\type, 'buboEvent'];
pattern.doAdjacentPairs({ | a, b, index |
if (index % 2 == 0, {
if (a === 'pat', {
@ -67,10 +87,17 @@ EventShortener {
});
});
];
if (sp_position.notNil, {
new_pattern = new_pattern ++ [
sp: pattern[sp_position + 1],
nb: pattern[nb_position + 1],
];
}, {
new_pattern = new_pattern ++ [
sp: Pfunc { |e| e.str ? "" },
nb: Pfunc { |e| e.num ? 0 }
];
});
}, {
new_pattern = new_pattern ++ [a, b];
});

View File

@ -2,11 +2,20 @@
Boot(samplePath: "/Users/bubo/.config/livecoding/samples");
)
// ================ SAMPLING (~SP et ~NB) ================
// TEST: [X] ça passe
(
~basic => [pat: "kick snare"];
~basic.play;
~hat => [pat: "hat:2 hat:4!3"];
~hat.play;
)
// TEST: [X] ça passe
(
~basic => [pat: "kick:4 snare:8"];
~basic.play;
~hat => [pat: "hat:2 hat:4!3"];
~hat.play;
)
@ -18,10 +27,95 @@ Boot(samplePath: "/Users/bubo/.config/livecoding/samples");
nb: [0, 2, 3].pseq(inf),
];
~basic.play;
)
(
~hat => [sp: "hat", dur: 1/2, nb: [0, 2, 3].pseq(inf)];
~hat => [sp: ["hat", "casio"].pseq(inf), dur: 1/2, nb: [0, 2, 3].pseq(inf)];
~hat.play;
)
// TEST: [X] ça passe
(
~basic => [
sp: ["kick", "synthi"].pseq(inf),
nb: 10, // Change moi
pat: "[0 7 0 7]/2",
test: Pfunc {
|e|
e.postln;
e
}
];
~basic.play;
)
// ================ SYNTHETISEURS TYPE PBIND ================
// TEST: [X] ça passe
(
~instrument => [
instrument: 'Panalog',
octave: 6,
degree: [0, 4].pseq(inf)
];
~instrument.play;
)
// TEST: [X] ça passe
(
~instrument => [
instrument: 'Panalog',
pat: "0 2 3 4 5",
octave: 6,
];
~instrument.play;
)
// TEST: [X] ça passe
(
~instrument => [
instrument: 'Panalog',
deg: "0 2 3 4".p,
octave: 6,
];
~instrument.play;
)
// ================ SYNTHETISEURS TYPE PMONO ================
// NOTE: SynthDef de test
(
SynthDef('acid', {
var freq = \freq.kr(100).varlag(\glide.kr(0.05));
var signal = PulseDPW.ar([freq / 2, freq / 1.99])
+ SawDPW.ar([freq, freq / 1.99]);
var env = Env.perc(
\attack.kr(0.1),
\release.kr(0.125)).ar(0);
var synth = signal * env;
synth = RLPF.ar(signal,
\ffreq.kr(1500).lag(\glide.kr),
\res.kr(0.2).lag(\glide.kr));
synth = Pan2.ar(synth, \pan.kr(0));
OffsetOut.ar(\out.kr(0), synth * \amp.kr(-24.dbamp));
}).add;
)
// TEST: [X] ça passe !
(
~acid -> ['acid', dur: (1/2), amp: 0.5, pat: "[0 2 4 5]/2"];
~acid.play;
)
// TEST: [X] ça passe !
(
~acid -> ['acid', dur: (1/2), amp: 0.5, degree: [0, 4].pseq(inf)];
~acid.play;
)
// TEST: [X] ça passe !
(
~acid -> ['acid', dur: (1/2), amp: 0.5, degree: "0 2 3 4".p];
~acid.play;
)
// ================ SCRATCHPAD ================