Fix operator overriding mess

This commit is contained in:
2024-05-15 16:23:28 +02:00
parent 461cfcbd7a
commit 39ed936b75
4 changed files with 84 additions and 36 deletions

View File

@ -46,8 +46,8 @@
/* Syntax for sending MIDI messages */ /* Syntax for sending MIDI messages */
>> { >> {
arg pattern; arg pattern;
var quant = this.getQuantFromPattern(pattern); var quant = BuboUtils.getQuantFromPattern(pattern);
var fade = this.getFadeFromPattern(pattern); var fade = BuboUtils.getFadeFromPattern(pattern);
pattern = EventShortener.process( pattern = EventShortener.process(
pattern, this.key, \midi, 0 pattern, this.key, \midi, 0
); );
@ -59,14 +59,12 @@
/* MIDI CC Operator */ /* MIDI CC Operator */
>>+ { >>+ {
arg pattern; arg pattern;
var quant = this.getQuantFromPattern(pattern); var quant = BuboUtils.getQuantFromPattern(pattern);
var fade = this.getFadeFromPattern(pattern); var fade = BuboUtils.getFadeFromPattern(pattern);
"Fonction Control Change".postln;
pattern = EventShortener.process( pattern = EventShortener.process(
pattern, this.key, 'midicc', 0 pattern, this.key, 'midicc', 0
); );
this[0] = Pbind(*pattern); this[0] = Pbind(*pattern);
this[0].patternpairs.postln;
this.prepareToPlay(this, quant, fade); this.prepareToPlay(this, quant, fade);
^this ^this
} }
@ -74,8 +72,8 @@
/* Player syntax sugar */ /* Player syntax sugar */
=> { => {
arg pattern; arg pattern;
var quant = this.getQuantFromPattern(pattern); var quant = BuboUtils.getQuantFromPattern(pattern);
var fade = this.getFadeFromPattern(pattern); var fade = BuboUtils.getFadeFromPattern(pattern);
pattern = EventShortener.process(pattern, this.key, 'buboEvent', 1); pattern = EventShortener.process(pattern, this.key, 'buboEvent', 1);
pattern = EffectChain.process(pattern, this.key); pattern = EffectChain.process(pattern, this.key);
this[0] = Pbind(*pattern); this[0] = Pbind(*pattern);
@ -86,8 +84,8 @@
/* Pmono player */ /* Pmono player */
-> { -> {
arg pattern; arg pattern;
var quant = this.getQuantFromPattern(pattern); var quant = BuboUtils.getQuantFromPattern(pattern);
var fade = this.getFadeFromPattern(pattern); var fade = BuboUtils.getFadeFromPattern(pattern);
pattern = EventShortener.process(pattern, this.key, 'pmono', 1); pattern = EventShortener.process(pattern, this.key, 'pmono', 1);
this[0] = Pmono(*pattern); this[0] = Pmono(*pattern);
this.prepareToPlay(this, quant, fade); this.prepareToPlay(this, quant, fade);
@ -95,11 +93,11 @@
} }
/* Audio Looper (sample playback) */ /* Audio Looper (sample playback) */
== { ==> {
// TODO: fix this terrible mess // TODO: fix this terrible mess
arg pattern; arg pattern;
var quant = this.getQuantFromPattern(pattern); var quant = BuboUtils.getQuantFromPattern(pattern);
var fade = this.getFadeFromPattern(pattern); var fade = BuboUtils.getFadeFromPattern(pattern);
var nbSlices = this.getValueFromPattern(pattern, 'slices', 1); var nbSlices = this.getValueFromPattern(pattern, 'slices', 1);
var time = (Pkey(\dur) / Pfunc { currentEnvironment.clock.tempo }) / nbSlices; var time = (Pkey(\dur) / Pfunc { currentEnvironment.clock.tempo }) / nbSlices;
pattern = EventShortener.process( pattern = EventShortener.process(
@ -109,25 +107,4 @@
this.prepareToPlay(this, quant, fade); this.prepareToPlay(this, quant, fade);
^this ^this
} }
getValueFromPattern {
arg pattern, key, default;
var keyIndex = pattern.indexOf(key);
if (keyIndex.notNil) {
^pattern[keyIndex + 1]
} {
^default
}
}
getQuantFromPattern {
arg pattern;
^this.getValueFromPattern(pattern, 'quant', 4)
}
getFadeFromPattern {
arg pattern;
^this.getValueFromPattern(pattern, 'fade', 0.01)
}
} }

View File

@ -71,4 +71,35 @@ BuboUtils {
each.postln; each.postln;
}); });
} }
*getValueFromPattern {
arg pattern, key, default;
var keyIndex;
try {
if (pattern == nil, {
^default
});
keyIndex = pattern.indexOf(key);
if (keyIndex.notNil) {
^pattern[keyIndex + 1]
} {
^default
}
} {
^default
}
}
*getQuantFromPattern {
arg pattern;
^this.getValueFromPattern(pattern, 'quant', 4)
}
*getFadeFromPattern {
arg pattern;
^this.getValueFromPattern(pattern, 'fade', 0.01)
}
} }

View File

@ -76,7 +76,7 @@ I personally dislike the `Pbind(\qdklsj)` or `Ndef(\qkljsdf)` syntax. The `\` sy
- Operators for creating SuperCollider patterns on-the-fly: - Operators for creating SuperCollider patterns on-the-fly:
- `=>` (Pbind): basic musical pattern - `=>` (Pbind): basic musical pattern
- `->` (Pmono): monophonic expression pattern - `->` (Pmono): monophonic expression pattern
- `==` (Looper): looper/sampler (**WIP**, currently broken) - `==>` (Looper): looper/sampler (**WIP**, currently broken)
- `>>` (Note): MIDI Note Pattern - `>>` (Note): MIDI Note Pattern
- `>>+` (CC): MIDI CC Pattern - `>>+` (CC): MIDI CC Pattern
@ -348,4 +348,4 @@ Contributions are welcome! If you have a technique/method that you think is wort
## About the website ## About the website
There is a [small companion website](https://bubobubobubobubo.github.io/BuboQuark/#/) that initially came with the repo but it is not really important. It will be used to host a few tutorials when everything will take shape in the future. There is a [small companion website](https://bubobubobubobubo.github.io/BuboQuark/#/) that initially came with the repo but it is not really important. It will be used to host a few tutorials when everything will take shape in the future.

40
test.scd Normal file
View File

@ -0,0 +1,40 @@
(
p = ProxySpace.push(s.boot, p);
"abcde".do { |k| p[k.asSymbol].ar };
m = ProxyMixer(p, 8);
m.parent.alwaysOnTop_(true); // show mixer in front of IDE
)
(
p = ProxySpace.push(s.waitForBoot({
~a = {
SinOsc.ar([199, 201, 199/1.75] * [1, 8, 2, 4].choose) * SinOsc.ar(
LFNoise2.kr(1 /4).range(1,8)
).range(0.01, 0.125);
};
~a.play;
}), p);
)
Boot()
(
~a = {
SinOsc.ar([200, 400] ! 2) * 0.125
};
)
~a.play;
(
~b.fadeTime = 4;
~b => [
i: "Panalog", pat: "0 2 3 4", octave: 6,
];
~b.play;
)
p.gui