Rewrite part of evaluation logic, run prettier

This commit is contained in:
2023-11-26 01:49:34 +01:00
parent 22b52456fc
commit eb8ef879e7
56 changed files with 2037 additions and 2568 deletions

View File

@ -293,7 +293,10 @@ export class SoundEvent extends AudibleEvent {
},
};
constructor(sound: string | string[] | SoundParams, public app: Editor) {
constructor(
sound: string | string[] | SoundParams,
public app: Editor,
) {
super(app);
this.nudge = app.dough_nudge / 100;
@ -312,7 +315,7 @@ export class SoundEvent extends AudibleEvent {
}
private processSound = (
sound: string | string[] | SoundParams | SoundParams[]
sound: string | string[] | SoundParams | SoundParams[],
): SoundParams => {
if (Array.isArray(sound) && typeof sound[0] === "string") {
const s: string[] = [];
@ -356,7 +359,7 @@ export class SoundEvent extends AudibleEvent {
private updateValue<T>(
key: string,
value: T | T[] | SoundParams[] | null
value: T | T[] | SoundParams[] | null,
): this {
if (value == null) return this;
this.values[key] = value;
@ -392,7 +395,7 @@ export class SoundEvent extends AudibleEvent {
(event.key as number) || "C4",
(event.pitch as number) || 0,
(event.parsedScale as number[]) || event.scale || "MAJOR",
(event.octave as number) || 0
(event.octave as number) || 0,
);
event.note = note;
event.freq = midiToFreq(note);
@ -412,7 +415,7 @@ export class SoundEvent extends AudibleEvent {
public invert = (howMany: number = 0) => {
if (this.values.chord) {
let notes = this.values.chord.map(
(obj: { [key: string]: number }) => obj.note
(obj: { [key: string]: number }) => obj.note,
);
notes = howMany < 0 ? [...notes].reverse() : notes;
for (let i = 0; i < Math.abs(howMany); i++) {
@ -448,8 +451,14 @@ export class SoundEvent extends AudibleEvent {
// const filteredEvent = filterObject(event, ["analyze","note","dur","freq","s"]);
const filteredEvent = event;
// No need for note if there is freq
if (filteredEvent.freq) { delete filteredEvent.note; }
superdough(filteredEvent, this.nudge - this.app.clock.deviation, filteredEvent.dur);
if (filteredEvent.freq) {
delete filteredEvent.note;
}
superdough(
filteredEvent,
this.nudge - this.app.clock.deviation,
filteredEvent.dur,
);
}
};
}