From 2644c34e7afac4e5bfdec68f8a243142a0c1c822 Mon Sep 17 00:00:00 2001 From: Miika Alonen Date: Tue, 19 Sep 2023 00:07:04 +0300 Subject: [PATCH 1/2] Fix ziffers chords --- src/classes/SoundEvent.ts | 10 +++++----- src/classes/ZPlayer.ts | 17 +++++------------ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/classes/SoundEvent.ts b/src/classes/SoundEvent.ts index 3ca63e2..a007a33 100644 --- a/src/classes/SoundEvent.ts +++ b/src/classes/SoundEvent.ts @@ -230,7 +230,7 @@ export class SoundEvent extends AudibleEvent { // Frequency management public sound = (value: string) => this.updateValue("s", value); - public chord = (value: number[]) => this.updateValue("chord", value); + public chord = (value: object[]) => this.updateValue("chord", value); public snd = this.sound; public nudge = (value: number) => this.updateValue("nudge", value); public cut = (value: number) => this.updateValue("cut", value); @@ -292,11 +292,11 @@ export class SoundEvent extends AudibleEvent { out = (): void => { if (this.values.chord) { - this.values.chord.forEach((freq: number) => { - const copy = { ...this.values }; - copy.freq = freq; + 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, this.values.dur * 2, this.values.dur); + superdough(copy, copy.dur*2, copy.dur); }); } else { // This is pure non-sense but I need to adapt somehow diff --git a/src/classes/ZPlayer.ts b/src/classes/ZPlayer.ts index 4a5bbfa..d69d7de 100644 --- a/src/classes/ZPlayer.ts +++ b/src/classes/ZPlayer.ts @@ -137,19 +137,12 @@ export class Player extends Event { if (this.areWeThereYet()) { const event = this.next() as Pitch | Chord | ZRest; if (event instanceof Pitch) { - const obj = event.getExisting( - "freq", - "pitch", - "key", - "scale", - "octave", - "parsedScale" - ); - obj.dur = event.duration; - return new SoundEvent(obj, this.app).sound(name); + return new SoundEvent({dur: event.duration, freq: event.freq}, this.app).sound(name); } else if (event instanceof Chord) { - const pitches = event.freqs(); - return new SoundEvent(event, this.app).chord(pitches).sound(name); + const pitches = event.pitches.map((p) => { + return {freq: p.freq} + }); + return new SoundEvent({dur: event.duration}, this.app).chord(pitches).sound(name); } else if (event instanceof ZRest) { return RestEvent.createRestProxy(event.duration, this.app); } From 4e4a2ac0bfb167a10254de6d5b7b6e7506a574a9 Mon Sep 17 00:00:00 2001 From: Miika Alonen Date: Tue, 19 Sep 2023 00:20:57 +0300 Subject: [PATCH 2/2] Fix for ziffers chord fix --- src/classes/ZPlayer.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/classes/ZPlayer.ts b/src/classes/ZPlayer.ts index d69d7de..7a03692 100644 --- a/src/classes/ZPlayer.ts +++ b/src/classes/ZPlayer.ts @@ -137,10 +137,26 @@ export class Player extends Event { if (this.areWeThereYet()) { const event = this.next() as Pitch | Chord | ZRest; if (event instanceof Pitch) { - return new SoundEvent({dur: event.duration, freq: event.freq}, this.app).sound(name); + const obj = event.getExisting( + "freq", + "pitch", + "key", + "scale", + "octave", + "parsedScale" + ); + obj.dur = event.duration; + return new SoundEvent(obj, this.app).sound(name); } else if (event instanceof Chord) { const pitches = event.pitches.map((p) => { - return {freq: p.freq} + return p.getExisting( + "freq", + "pitch", + "key", + "scale", + "octave", + "parsedScale" + ); }); return new SoundEvent({dur: event.duration}, this.app).chord(pitches).sound(name); } else if (event instanceof ZRest) {