Added some drawing methods

This commit is contained in:
2023-12-15 22:13:22 +02:00
parent 04dd6c079d
commit cad9fdbb40
11 changed files with 189 additions and 9 deletions

View File

@ -463,6 +463,16 @@ export abstract class AudibleEvent extends AbstractEvent {
return this;
}
public draw = (lambda: Function) => {
lambda(this.values);
return this;
}
public clear = () => {
this.app.api.clear();
return this;
}
freq = (value: number | number[], ...kwargs: number[]): this => {
/*
* This function is used to set the frequency of the Event.

View File

@ -6,6 +6,7 @@ import {
filterObject,
arrayOfObjectsToObjectWithArrays,
objectWithArraysToArrayOfObjects,
maybeAtomic,
} from "../Utils/Generic";
export type MidiParams = {
@ -110,8 +111,8 @@ export class MidiEvent extends AudibleEvent {
const newArrays = arrayOfObjectsToObjectWithArrays(events) as MidiParams;
this.values.note = newArrays.note;
if (newArrays.bend) this.values.bend = newArrays.bend;
this.values.note = maybeAtomic(newArrays.note);
if (newArrays.bend) this.values.bend = maybeAtomic(newArrays.bend);
};
out = (): void => {

View File

@ -5,6 +5,7 @@ import {
filterObject,
arrayOfObjectsToObjectWithArrays,
objectWithArraysToArrayOfObjects,
maybeAtomic,
} from "../Utils/Generic";
import { midiToFreq, resolvePitchClass } from "zifferjs";
@ -414,11 +415,11 @@ export class SoundEvent extends AudibleEvent {
const newArrays = arrayOfObjectsToObjectWithArrays(events) as SoundParams;
this.values.note = newArrays.note;
this.values.freq = newArrays.freq;
this.values.pitch = newArrays.pitch;
this.values.octave = newArrays.octave;
this.values.pitchOctave = newArrays.pitchOctave;
this.values.note = maybeAtomic(newArrays.note);
this.values.freq = maybeAtomic(newArrays.freq);
this.values.pitch = maybeAtomic(newArrays.pitch);
this.values.octave = maybeAtomic(newArrays.octave);
this.values.pitchOctave = maybeAtomic(newArrays.pitchOctave);
};