From 2367312a002b02bab50e724961f91b506ec450b4 Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Wed, 20 Sep 2023 20:56:00 +0200 Subject: [PATCH 1/5] Discard Numerology from demo songs --- src/examples/excerpts.ts | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/examples/excerpts.ts b/src/examples/excerpts.ts index 8c916de..fb29854 100644 --- a/src/examples/excerpts.ts +++ b/src/examples/excerpts.ts @@ -25,22 +25,6 @@ beat(.5) :: sound('STA6').cut(1).vel(0.4) binrhythm(.5, 50) :: sound('shaker').out() binrhythm(.5, 52) :: sound('808bd').n(3).out() rhythm(.25, 6, 8) :: sound('808sd').out()`, - `// Numerology - Bubobubobubo -bpm(130); -let mel = [ - "0.125 _ (0 3 7 0 3 5 0 3 9)+(0 2)", "0.125 (0 7 0 10 0 5)+(0 3)", - "0.125 (0 3 7 0 3 5 0 3 9)+(0 2)", "0.125 (0 2 4 5 9 10)+(0 2)", -].beat(4); -z0(mel) - .scale('minor').sound('wt_piano').cutoff(800 + usine(.5) * 5000) - .fmi([2, 4, 8].beat(2)).fmh(flip(2) ? 2 : 4) - .delay(bpm() / 60 / 9).delayt(0.25).delayfb(0.5) - .fmsus(0.3).fmrel(0.3).rel(rand(0.5,0.8)) - .sus(rand(0.05, 0.1)).out(); -beat(1) :: sound(flip(2) ? 'kick' : ['sd', 'cp'].beat(3)).out(); -beat([.25, .5].beat(4)) :: flip(6) && sound('dr') - .room(0.85).size(0.85).vel($(1) % 10 / 8) - .n([1, 2, 7].pick()).out();`, `// Harmonic Leaps and Gaps -- Bubobubobubo let oscillation = quant(usine(.25) * 20, [35, 40, 38, 50, 55]); let tonal = [0, 5, 0, 0, 7].palindrome().bar() + 40 - 24; @@ -219,4 +203,22 @@ beat([.25,.125, .5].beat(4))::snd('arpy:4') .resonance(5).gain(0.4).end(0.8).room(0.9).size(0.9).n(3).out(); beat(.5) :: snd('arpy').note([30, 33, 35].repeatAll(4).beat(1) - [24,12].beat(0.5)) .cutoff(500).lpadsr(8, 0.05, .125, 0, 0).out()`, + /* + `// Numerology - Bubobubobubo +bpm(130); +let mel = [ + "0.125 _ (0 3 7 0 3 5 0 3 9)+(0 2)", "0.125 (0 7 0 10 0 5)+(0 3)", + "0.125 (0 3 7 0 3 5 0 3 9)+(0 2)", "0.125 (0 2 4 5 9 10)+(0 2)", +].beat(4); +z0(mel) + .scale('minor').sound('wt_piano').cutoff(800 + usine(.5) * 5000) + .fmi([2, 4, 8].beat(2)).fmh(flip(2) ? 2 : 4) + .delay(bpm() / 60 / 9).delayt(0.25).delayfb(0.5) + .fmsus(0.3).fmrel(0.3).rel(rand(0.5,0.8)) + .sus(rand(0.05, 0.1)).out(); +beat(1) :: sound(flip(2) ? 'kick' : ['sd', 'cp'].beat(3)).out(); +beat([.25, .5].beat(4)) :: flip(6) && sound('dr') + .room(0.85).size(0.85).vel($(1) % 10 / 8) + .n([1, 2, 7].pick()).out();`, + */ ]; From ae82dcf0135c7cb9c3658902ff49d5700ad2fbee Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Wed, 20 Sep 2023 22:06:49 +0200 Subject: [PATCH 2/5] revert to buggy but better version --- src/classes/SoundEvent.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/classes/SoundEvent.ts b/src/classes/SoundEvent.ts index a007a33..700246e 100644 --- a/src/classes/SoundEvent.ts +++ b/src/classes/SoundEvent.ts @@ -292,15 +292,13 @@ export class SoundEvent extends AudibleEvent { out = (): void => { if (this.values.chord) { - this.values.chord.forEach((obj: {[key: string]: number}) => { - const copy = {...this.values}; + this.values.chord.forEach((obj: { [key: string]: number }) => { + const copy = { ...this.values }; copy.freq = obj.freq - // This is pure non-sense but I need to adapt somehow - superdough(copy, copy.dur*2, copy.dur); + superdough(copy, 1 / 4, this.values.dur || 0.5); }); } else { - // This is pure non-sense but I need to adapt somehow - superdough(this.values, this.values.dur * 2, this.values.dur); + superdough(this.values, 1 / 4, this.values.dur || 0.5); } }; } From ae7c9d8cb6c10cbf9fe3e41b307f991284ef4692 Mon Sep 17 00:00:00 2001 From: Miika Alonen Date: Thu, 21 Sep 2023 00:00:45 +0300 Subject: [PATCH 3/5] Fix sync problem --- src/classes/SoundEvent.ts | 4 ++-- src/classes/ZPlayer.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/classes/SoundEvent.ts b/src/classes/SoundEvent.ts index 700246e..4b8580c 100644 --- a/src/classes/SoundEvent.ts +++ b/src/classes/SoundEvent.ts @@ -295,10 +295,10 @@ export class SoundEvent extends AudibleEvent { this.values.chord.forEach((obj: { [key: string]: number }) => { const copy = { ...this.values }; copy.freq = obj.freq - superdough(copy, 1 / 4, this.values.dur || 0.5); + superdough(copy, this.values.dur*2, this.values.dur); }); } else { - superdough(this.values, 1 / 4, this.values.dur || 0.5); + superdough(this.values, this.values.dur*2, this.values.dur); } }; } diff --git a/src/classes/ZPlayer.ts b/src/classes/ZPlayer.ts index 7a03692..89ba073 100644 --- a/src/classes/ZPlayer.ts +++ b/src/classes/ZPlayer.ts @@ -134,8 +134,10 @@ export class Player extends Event { }; sound(name: string) { + if (this.areWeThereYet()) { const event = this.next() as Pitch | Chord | ZRest; + const noteLengthInSeconds = this.app.clock.convertPulseToSecond(event.duration*4*this.app.clock.ppqn); if (event instanceof Pitch) { const obj = event.getExisting( "freq", @@ -145,7 +147,7 @@ export class Player extends Event { "octave", "parsedScale" ); - obj.dur = event.duration; + obj.dur = noteLengthInSeconds; return new SoundEvent(obj, this.app).sound(name); } else if (event instanceof Chord) { const pitches = event.pitches.map((p) => { @@ -158,7 +160,7 @@ export class Player extends Event { "parsedScale" ); }); - return new SoundEvent({dur: event.duration}, this.app).chord(pitches).sound(name); + return new SoundEvent({dur: noteLengthInSeconds}, this.app).chord(pitches).sound(name); } else if (event instanceof ZRest) { return RestEvent.createRestProxy(event.duration, this.app); } From 35a0a69cce1b5541632f2680a74d359adb77ac05 Mon Sep 17 00:00:00 2001 From: Miika Alonen Date: Thu, 21 Sep 2023 00:19:06 +0300 Subject: [PATCH 4/5] Cleaning ziffers timing --- src/classes/ZPlayer.ts | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/classes/ZPlayer.ts b/src/classes/ZPlayer.ts index 89ba073..4c3a862 100644 --- a/src/classes/ZPlayer.ts +++ b/src/classes/ZPlayer.ts @@ -101,28 +101,26 @@ export class Player extends Event { this.skipIndex = 0; } - // Main logic - const howAboutNow = - // If pattern is just starting - (this.notStarted() && - (this.pulse() === 0 || this.origin() >= this.nextBeatInTicks()) && - this.origin() >= this.waitTime) || - // If pattern is already playing - (this.current && - this.pulseToSecond(this.origin()) >= - this.pulseToSecond(this.lastCallTime) + - this.current.duration * - 4 * - this.pulseToSecond(this.app.api.ppqn()) && - this.origin() >= this.waitTime); + const patternIsStarting = (this.notStarted() && + (this.pulse() === 0 || this.origin() >= this.nextBeatInTicks()) && + this.origin() >= this.waitTime); + + const timeToPlayNext = (this.current && + this.pulseToSecond(this.origin()) >= + this.pulseToSecond(this.lastCallTime) + + this.pulseToSecond(this.current.duration*4*this.app.clock.ppqn) && + this.origin() >= this.waitTime); + // If pattern is starting or it's time to play next event + const areWeThereYet = patternIsStarting || timeToPlayNext; + // Increment index of how many times call is skipped - this.skipIndex = howAboutNow ? 0 : this.skipIndex + 1; + this.skipIndex = areWeThereYet ? 0 : this.skipIndex + 1; // Increment index of how many times sound/midi have been called - this.index = howAboutNow ? this.index + 1 : this.index; + this.index = areWeThereYet ? this.index + 1 : this.index; - if (howAboutNow && this.notStarted()) { + if (areWeThereYet && this.notStarted()) { this.initCallTime = this.app.clock.pulses_since_origin; } @@ -130,7 +128,7 @@ export class Player extends Event { this.startCallTime = this.app.clock.pulses_since_origin; } - return howAboutNow; + return areWeThereYet; }; sound(name: string) { From 21d600d4ef26fb7883707e0d21a5a65f214e4f38 Mon Sep 17 00:00:00 2001 From: Miika Alonen Date: Thu, 21 Sep 2023 01:18:17 +0300 Subject: [PATCH 5/5] Adding deadline back to 0.25 --- src/classes/SoundEvent.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/classes/SoundEvent.ts b/src/classes/SoundEvent.ts index 4b8580c..ccacdba 100644 --- a/src/classes/SoundEvent.ts +++ b/src/classes/SoundEvent.ts @@ -295,10 +295,10 @@ export class SoundEvent extends AudibleEvent { this.values.chord.forEach((obj: { [key: string]: number }) => { const copy = { ...this.values }; copy.freq = obj.freq - superdough(copy, this.values.dur*2, this.values.dur); + superdough(copy, 0.25, this.values.dur); }); } else { - superdough(this.values, this.values.dur*2, this.values.dur); + superdough(this.values, 0.25, this.values.dur); } }; }