Fixing more conditional logic

This commit is contained in:
2024-05-15 12:13:34 +02:00
parent 5bc1cd641f
commit 27cbb48c98
7 changed files with 60 additions and 34 deletions

View File

@ -105,10 +105,10 @@ Boot {
Event.addEventType(\buboEvent, {
arg server;
if (BuboUtils.stringIsNumber(~sp), {}, {
~sp = BuboUtils.cleanSampleName(~sp);
~nb = BuboUtils.cleanSampleIndex(~nb);
if (~sp.notNil && ~nb.notNil, {
if (~sp.notNil, {
if (BuboUtils.stringIsNumber(~sp), {}, {
~sp = BuboUtils.cleanSampleName(~sp);
~nb = BuboUtils.cleanSampleIndex(~nb);
if (~sp !== "", {
~buf = Bank(~sp)[~nb % Bank(~sp).paths.size];
if (Bank(~sp).metadata[~nb % Bank(~sp).size][\numChannels] == 1) {
@ -116,7 +116,7 @@ Boot {
} {
~instrument = \splayer;
};
})
});
});
});
~type = \note;

3
Classes/BuboEvents.sc Normal file
View File

@ -0,0 +1,3 @@
BuboEvents {
}

View File

@ -25,7 +25,7 @@ BuboUtils {
*stringIsNumber {
arg string;
if (string == nil, { ^true });
if (string == nil || string == "", { ^false });
string = string.asList.collect({arg char; char.ascii});
string = (48..57).includesAll(string);
^string

View File

@ -1,6 +1,5 @@
// Setting up MIDI for hardware performances
"Initialising MIDI...".postln;
MIDIClient.init;
p = currentEnvironment;
c = currentEnvironment.clock;

View File

@ -271,26 +271,25 @@ d.list = { arg obj; obj.keys.do({arg i; i.postln}); };
d.tides = z;
);
(
z = SynthDef('pink', {
arg out;
var pink = PinkTrombone.ar(
noiseSource: BPF.ar(WhiteNoise.ar(), \noiseFilter.kr(2000)),
freq: \freq.kr(800),
tenseness: \tenseness.kr(0.4),
tongueIndex: \tongueIndex.kr(30),
tongueDiameter: \tongueDiameter.kr(3.5),
constrictionX: \constrictionX.kr(1.5),
constrictionY: \constrictionY.kr(2.5),
fricativeIntens: \fricativeIntens.kr(1.5)
);
var env = Env.perc(\attack.kr(0.01), releaseTime: \release.kr(2.0)).kr(doneAction: 2);
var sound = pink * env;
OffsetOut.ar(out, Pan2.ar(sound, pos: \pan.kr(0.0)))
}).add;
d.pink = z;
);
// (
// z = SynthDef('pink', {
// arg out;
// var pink = PinkTrombone.ar(
// noiseSource: BPF.ar(WhiteNoise.ar(), \noiseFilter.kr(2000)),
// freq: \freq.kr(800),
// tenseness: \tenseness.kr(0.4),
// tongueIndex: \tongueIndex.kr(30),
// tongueDiameter: \tongueDiameter.kr(3.5),
// constrictionX: \constrictionX.kr(1.5),
// constrictionY: \constrictionY.kr(2.5),
// fricativeIntens: \fricativeIntens.kr(1.5)
// );
// var env = Env.perc(\attack.kr(0.01), releaseTime: \release.kr(2.0)).kr(doneAction: 2);
// var sound = pink * env;
// OffsetOut.ar(out, Pan2.ar(sound, pos: \pan.kr(0.0)))
// }).add;
// d.pink = z;
// );
(
z = SynthDef('kick', {

View File

@ -67,18 +67,16 @@ EventShortener {
});
});
];
new_pattern = new_pattern ++ [
sp: Pfunc { |e| e.str ? "" },
nb: Pfunc { |e| e.num ? 0 }
];
}, {
new_pattern = new_pattern ++ [a, b];
});
});
});
if (pattern.includes('i') || pattern.includes('instrument') == false, {
new_pattern = new_pattern ++ [
sp: Pfunc { |e| e.str ? "" },
nb: Pfunc { |e| e.num ? 0 }
];
});
new_pattern.postln;
^new_pattern
}

View File

@ -0,0 +1,27 @@
(
Boot(samplePath: "/Users/bubo/.config/livecoding/samples");
)
// TEST: [X] ça passe
(
~basic => [pat: "kick snare"];
~basic.play;
~hat => [pat: "hat:2 hat:4!3"];
~hat.play;
)
// TEST: [X] ça passe
(
~basic => [
sp: "kick",
nb: [0, 2, 3].pseq(inf),
];
~basic.play;
)
(
~hat => [sp: "hat", dur: 1/2, nb: [0, 2, 3].pseq(inf)];
~hat.play;
)