No more segfaults ?

This commit is contained in:
2024-05-14 16:46:57 +02:00
parent f07e560322
commit afebd967d2
4 changed files with 52 additions and 26 deletions

View File

@ -95,19 +95,17 @@ Boot {
Event.addEventType(\buboLoopEvent, { Event.addEventType(\buboLoopEvent, {
arg server; arg server;
[~sp, ~nb].postln;
~sp = BuboUtils.cleanSampleName(~sp); ~sp = BuboUtils.cleanSampleName(~sp);
~nb = BuboUtils.cleanSampleIndex(~nb); ~nb = BuboUtils.cleanSampleIndex(~nb);
[~sp, ~nb].postln;
if (~sp.notNil && ~nb.notNil, { if (~sp.notNil && ~nb.notNil, {
~sp = ~sp ?? 'default'; if (~sp != "", {
~nb = ~nb ?? 0; ~buf = Bank(~sp)[~nb % Bank(~sp).paths.size];
~buf = Bank(~sp)[~nb % Bank(~sp).paths.size]; if (Bank(~sp).metadata[~nb % Bank(~sp).size][\numChannels] == 1) {
if (Bank(~sp).metadata[~nb % Bank(~sp).size][\numChannels] == 1) { ~instrument = \looperMono;
~instrument = \looperMono; } {
} { ~instrument = \looperStereo;
~instrument = \looperStereo; };
}; })
}); });
~type = \note; ~type = \note;
currentEnvironment.play; currentEnvironment.play;
@ -115,17 +113,20 @@ Boot {
Event.addEventType(\buboEvent, { Event.addEventType(\buboEvent, {
arg server; arg server;
~sp = BuboUtils.cleanSampleName(~sp); [~sp, ~nb, ~instrument].postln;
~nb = BuboUtils.cleanSampleIndex(~nb); if (BuboUtils.stringIsNumber(~sp), {}, {
if (~sp.notNil && ~nb.notNil, { ~sp = BuboUtils.cleanSampleName(~sp);
if (~sp != "", { ~nb = BuboUtils.cleanSampleIndex(~nb);
~buf = Bank(~sp)[~nb % Bank(~sp).paths.size]; if (~sp.notNil && ~nb.notNil, {
if (Bank(~sp).metadata[~nb % Bank(~sp).size][\numChannels] == 1) { if (~sp !== "", {
~instrument = \player; ~buf = Bank(~sp)[~nb % Bank(~sp).paths.size];
} { if (Bank(~sp).metadata[~nb % Bank(~sp).size][\numChannels] == 1) {
~instrument = \splayer; ~instrument = \player;
}; } {
}) ~instrument = \splayer;
};
})
});
}); });
~type = \note; ~type = \note;
currentEnvironment.play; currentEnvironment.play;

View File

@ -15,7 +15,7 @@ BuboUtils {
*cleanSampleName { *cleanSampleName {
arg str; arg str;
var good_string; var good_string;
if (str == nil, { ^nil }); if (str == nil, { ^"" });
good_string = str.asList.collect({ good_string = str.asList.collect({
|char| |char|
if (char.isAlphaNum, char, "") if (char.isAlphaNum, char, "")
@ -23,6 +23,14 @@ BuboUtils {
^good_string ^good_string
} }
*stringIsNumber {
arg string;
if (string == nil, { ^true });
string = string.asList.collect({arg char; char.ascii});
string = (48..57).includesAll(string);
^string
}
*cleanSampleIndex { *cleanSampleIndex {
arg number; arg number;
if (number.isKindOf(Number), { ^number }, { ^0 }); if (number.isKindOf(Number), { ^number }, { ^0 });

View File

@ -54,9 +54,8 @@ EventShortener {
if (type !== 'midi', { if (type !== 'midi', {
if (pattern.includes('i') || pattern.includes('instrument') == false, { if (pattern.includes('i') || pattern.includes('instrument') == false, {
new_pattern = new_pattern ++ [ new_pattern = new_pattern ++ [
sp: Pfunc { |e| e.str ? 'default' }, sp: Pfunc { |e| e.str ? "" },
nb: Pfunc(\num), nb: Pfunc { |e| e.num ? 0 },
instrument: 'default',
fast: 1, fast: 1,
]; ];
}); });

View File

@ -37,7 +37,25 @@ m = MIDIOut.newByName("MIDI", "Bus 1");
~plop.play; ~plop.play;
) )
Bank.list
// TEST: Cinquième test
(
~testInstrument => [
instrument: 'default',
pat: "0 2 3 4"
];
~testInstrument.play;
)
// TEST: Sixième test
// WARNING: celui-ci crashe !
(
~testInstrument => [
pat: "0 2 3 4"
];
~testInstrument.play;
)
Sweep.help Sweep.help