better debug behavior + optional analyze

This commit is contained in:
2023-11-30 22:54:40 +01:00
parent 49f7998425
commit c192988e70

View File

@ -110,6 +110,10 @@ export class SoundEvent extends AudibleEvent {
self.updateValue("release", 0.0); self.updateValue("release", 0.0);
return self; return self;
}, },
analyze: function(self: SoundEvent) {
self.updateValue("analyze", true)
return self
},
debug: function(self: SoundEvent, callback?: Function) { debug: function(self: SoundEvent, callback?: Function) {
self.updateValue("debug", true) self.updateValue("debug", true)
if (callback) { if (callback) {
@ -382,12 +386,10 @@ export class SoundEvent extends AudibleEvent {
s, s,
n: n.length > 0 ? n : undefined, n: n.length > 0 ? n : undefined,
dur: this.app.clock.convertPulseToSecond(this.app.clock.ppqn), dur: this.app.clock.convertPulseToSecond(this.app.clock.ppqn),
analyze: true,
}; };
} else if (typeof sound === "object") { } else if (typeof sound === "object") {
const validatedObj: SoundParams = { const validatedObj: SoundParams = {
dur: this.app.clock.convertPulseToSecond(this.app.clock.ppqn), dur: this.app.clock.convertPulseToSecond(this.app.clock.ppqn),
analyze: true,
...(sound as Partial<SoundParams>), ...(sound as Partial<SoundParams>),
}; };
return validatedObj; return validatedObj;
@ -400,10 +402,9 @@ export class SoundEvent extends AudibleEvent {
s, s,
n, n,
dur: this.app.clock.convertPulseToSecond(this.app.clock.ppqn), dur: this.app.clock.convertPulseToSecond(this.app.clock.ppqn),
analyze: true,
}; };
} else { } else {
return { s: sound, dur: 0.5, analyze: true }; return { s: sound, dur: 0.5 };
} }
} }
}; };
@ -467,8 +468,9 @@ export class SoundEvent extends AudibleEvent {
if (this.values["debug"]) { if (this.values["debug"]) {
if (this.values["debugFunction"]) { if (this.values["debugFunction"]) {
this.values["debugFunction"](filteredEvent) this.values["debugFunction"](filteredEvent)
} else {
console.log(filteredEvent)
} }
console.log(filteredEvent)
} }
superdough( superdough(
filteredEvent, filteredEvent,