From 74642bd1f4856009d4755b2a97f6f05d5e84a732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Forment?= Date: Tue, 14 May 2024 15:21:50 +0200 Subject: [PATCH] fixing some of the current issues with pat --- Classes/Bank.sc | 109 +++++++++++++++------------- Classes/BuboBoot.sc | 23 ++++-- Classes/BuboUtils.sc | 15 +++- Classes/Configuration/Synthdefs.scd | 4 +- Classes/EventShortener.sc | 6 +- dev_sessions/with_midi.scd | 67 ++++++++++++++--- 6 files changed, 151 insertions(+), 73 deletions(-) diff --git a/Classes/Bank.sc b/Classes/Bank.sc index 3301116..3244707 100644 --- a/Classes/Bank.sc +++ b/Classes/Bank.sc @@ -2,7 +2,7 @@ Bank : Singleton { classvar <>root, <>extensions, <>lazyLoading=true; var buffers.size) { buffers = buffers.extend(paths.size) }; - + paths.do { |path, i| var buffer; - + buffer = buffers[i]; - + if (path.notNil) { if (lazyLoading.not) { this.bufferAt(i) @@ -338,7 +349,7 @@ Bank : Singleton { } } }; - + buffers[paths.size..].do { |b| b.free; @@ -346,7 +357,7 @@ Bank : Singleton { buffers.extend(paths.size); } } - + doOnServerBoot { if (paths.size > 0) { buffers = []; @@ -354,27 +365,27 @@ Bank : Singleton { "***Loaded samples for %***".format(this.asString).postln; } } - + doOnServerQuit { buffers = []; } - + pat { |keyPat| ^Pindex(Pseq([this], inf), keyPat) } - + // Single buffer support asBuffer { ^this.singleSampleWrap(nil) } asControlInput { |...args| ^this.prSingleSampleWrap(\asControlInput, *args) } play { |...args| ^this.prSingleSampleWrap(\play, *args) } - + prSingleSampleWrap { |method ...args| var buffer; if (buffers.size == 1) { buffer = this.bufferAt(0); - + if (method.isNil) { ^buffer } { diff --git a/Classes/BuboBoot.sc b/Classes/BuboBoot.sc index 5433992..04cff5a 100644 --- a/Classes/BuboBoot.sc +++ b/Classes/BuboBoot.sc @@ -95,6 +95,10 @@ Boot { Event.addEventType(\buboLoopEvent, { arg server; + [~sp, ~nb].postln; + ~sp = BuboUtils.cleanSampleName(~sp); + ~nb = BuboUtils.cleanSampleIndex(~nb); + [~sp, ~nb].postln; if (~sp.notNil && ~nb.notNil, { ~sp = ~sp ?? 'default'; ~nb = ~nb ?? 0; @@ -111,18 +115,21 @@ Boot { Event.addEventType(\buboEvent, { arg server; + ~sp = BuboUtils.cleanSampleName(~sp); + ~nb = BuboUtils.cleanSampleIndex(~nb); if (~sp.notNil && ~nb.notNil, { - ~sp = ~sp ?? 'default'; - ~nb = ~nb ?? 0; - ~buf = Bank(~sp)[~nb % Bank(~sp).paths.size]; - if (Bank(~sp).metadata[~nb % Bank(~sp).size][\numChannels] == 1) { - ~instrument = \player; - } { - ~instrument = \splayer; - }; + if (~sp != "", { + ~buf = Bank(~sp)[~nb % Bank(~sp).paths.size]; + if (Bank(~sp).metadata[~nb % Bank(~sp).size][\numChannels] == 1) { + ~instrument = \player; + } { + ~instrument = \splayer; + }; + }) }); ~type = \note; currentEnvironment.play; }); } + } diff --git a/Classes/BuboUtils.sc b/Classes/BuboUtils.sc index fb970e8..14ebd66 100644 --- a/Classes/BuboUtils.sc +++ b/Classes/BuboUtils.sc @@ -12,6 +12,20 @@ BuboUtils { ) } + *cleanSampleName { + arg str; + if (str == nil, { ^nil }); + ^str.asList.collect({ + |char| + if (char.isAlpha, char, "") + }).join + } + + *cleanSampleIndex { + arg number; + if (number.isKindOf(Number), { ^number }, { ^0 }); + } + *banner { var banner = "┳┓ ┓ ┳┓ ┓ ┳┓\n" "┣┫┓┏┣┓┏┓┣┫┓┏┣┓┏┓ ┣┫┏┓┏┓╋\n" @@ -39,4 +53,3 @@ BuboUtils { }); } } - diff --git a/Classes/Configuration/Synthdefs.scd b/Classes/Configuration/Synthdefs.scd index 3b4ff5d..88269da 100644 --- a/Classes/Configuration/Synthdefs.scd +++ b/Classes/Configuration/Synthdefs.scd @@ -19,7 +19,7 @@ d.list = { arg obj; obj.keys.do({arg i; i.postln}); }; trigger: 1, startPos:startPos, loop:\loop.kr(0), doneAction: 2); sig = sig * \amp.kr(-6).dbamp; - sig = Pan2.ar(sig * env, \pan.kr(0)); + sig = Pan2.ar(sig * env, \pan.kr(0.0)); OffsetOut.ar(out, sig) }).add; d.player = z; @@ -47,7 +47,7 @@ d.list = { arg obj; obj.keys.do({arg i; i.postln}); }; trigger: 1, startPos:startPos, loop:\loop.kr(0), doneAction: 2); sig = sig * \amp.kr(-6).dbamp; - sig = Pan2.ar(sig * env, \pan.kr(0)); + sig = Pan2.ar(sig * env, \pan.kr(0.0)); OffsetOut.ar(out, sig) }).add; d.splayer = z; diff --git a/Classes/EventShortener.sc b/Classes/EventShortener.sc index 3ed391b..13e9a0c 100644 --- a/Classes/EventShortener.sc +++ b/Classes/EventShortener.sc @@ -54,9 +54,9 @@ EventShortener { if (type !== 'midi', { if (pattern.includes('i') || pattern.includes('instrument') == false, { new_pattern = new_pattern ++ [ - sp: Pfunc { |e| e.str ? "kick" }, - nb: Pfunc { |e| e.num ? 0 }, - instrument: Pfunc { |e| e.str.isNil && e.num.isNil ? "default" }, + sp: Pfunc { |e| e.str ? 'default' }, + nb: Pfunc(\num), + instrument: 'default', fast: 1, ]; }); diff --git a/dev_sessions/with_midi.scd b/dev_sessions/with_midi.scd index ace3831..c57df75 100644 --- a/dev_sessions/with_midi.scd +++ b/dev_sessions/with_midi.scd @@ -6,16 +6,16 @@ // BUG: Evalue moi m = MIDIOut.newByName("MIDI", "Bus 1"); -// NOTE: Pattern rythmique de base ( -~test => [ sp: "kick", nb: 0]; +~test => [ sp: "kick", nb: 0 ]; ~test.play; ) -// NOTE: Pattern avec Pmini +~test.source.patternpairs + ( -~test => [ pat: "kick:4 snare:3" ]; -~test.play; +~fun => [ pat: "kick:4 snare:3" ]; +~fun.play; ) // NOTE: Pattern sans numéro maintenant ! @@ -40,8 +40,6 @@ Sweep.help sound }); ~rhythm.play; -) - ~basse => [ pat: "0(5,8)/2", i: "kraut", @@ -156,15 +154,32 @@ m = MIDIOut.newByName("MIDI", "Bus 1"); ( -~ground => [pat: "[kick:2(5,16)/16, fgood:11/2]", release: 4, quant: 4]; +~ground => [ + pat: "[kick:2(5,16)/16, cgood:11/2 lgood:13]*2", + release: [4, 2, 1].pseq(inf), + quant: 4, + // test: Pfunc { |e| e.postln; }, + // finish: { currentEnvironment.keysValuesDo { + // |key, val| + // "%: %".format(key, val).postln} + // }, +]; +~ground.play; +) + +( ~snare => [pat: "[~ snare]/16", release: 4, quant: 4]; ~snare.fx1(0.7, {arg in; MiVerb.ar(in, time: 0.7)}); +~snare.play; +) + +( ~hat => [pat: "[sound:2|hat:5] hat:2 hat:3!2", release: 1/32, amp: [0.0,-12.0].pwhite(inf), quant: 4 ]; ~hat.play; -~snare.play; -~ground.play; +) + ~vorb => [ instrument: 'kraut', octave: 4, @@ -190,3 +205,35 @@ m = MIDIOut.newByName("MIDI", "Bus 1"); }); ~apply.play; ) + + +Bank("default")[0].play + +// NOTE: absolute crash (attention !) +( +~other => [ + sp: "synthi", nb: 2, + release: 1/4, rate: 0.75, + pan: [0.0, 1.0].pwhite, +]; +~other.mold(2); +~other.play; +) + +// Faire le point sur la situation : qu'est-ce qui marche et ne marche pas ? + + +// NOTE: Pattern le plus basique +~a => [sp: "kick", nb: 4]; +~a.play; +~a.clear; + +// NOTE: Pattern avec Pmini +~a => [pat: "[kick hat snare hat]/2"]; +~a.play; +~a.clear; + +// NOTE: pattern de base, sample mal formée +// WARNING: le crash se produit ici ! +~a => [sp: "kick:2", nb: 4]; +~a.play;