Added freq method to note
This commit is contained in:
@ -37,7 +37,7 @@
|
||||
"tailwindcss": "^3.3.3",
|
||||
"tone": "^14.8.49",
|
||||
"vite-plugin-markdown": "^2.1.0",
|
||||
"zifferjs": "^0.0.9",
|
||||
"zifferjs": "^0.0.10",
|
||||
"zzfx": "^1.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
12
src/Note.ts
12
src/Note.ts
@ -1,6 +1,8 @@
|
||||
import { Event } from './Event';
|
||||
import { type Editor } from './main';
|
||||
import { MidiConnection } from "./IO/MidiConnection";
|
||||
import { freqToMidi, resolvePitchBend } from 'zifferjs';
|
||||
|
||||
export class Note extends Event {
|
||||
values: { [key: string]: any };
|
||||
midiConnection: MidiConnection;
|
||||
@ -49,9 +51,15 @@ export class Note extends Event {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add bend
|
||||
freq = (value: number): this => {
|
||||
this.values['freq'] = value;
|
||||
const midiNote = freqToMidi(value);
|
||||
if(midiNote % 1 !== 0) {
|
||||
this.values['note'] = Math.floor(midiNote);
|
||||
this.values['bend'] = resolvePitchBend(midiNote)[1];
|
||||
} else {
|
||||
this.values['note'] = midiNote;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -83,7 +91,7 @@ export class Note extends Event {
|
||||
this.midiConnection.getCurrentMidiPortIndex();
|
||||
|
||||
if (bend) this.midiConnection.sendPitchBend(bend, channel);
|
||||
this.midiConnection.sendMidiNote(note, channel, velocity, duration, port);
|
||||
this.midiConnection.sendMidiNote(note, channel, velocity, duration, port, bend);
|
||||
//if (bend) this.midiConnection.sendPitchBend(8192, channel);
|
||||
}
|
||||
|
||||
|
||||
@ -1441,10 +1441,10 @@ yaml@^2.1.1:
|
||||
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.3.1.tgz#02fe0975d23cd441242aa7204e09fc28ac2ac33b"
|
||||
integrity sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==
|
||||
|
||||
zifferjs@^0.0.9:
|
||||
version "0.0.9"
|
||||
resolved "https://registry.yarnpkg.com/zifferjs/-/zifferjs-0.0.9.tgz#47037cee6dd161838dd236bdbc3eda9b099e2281"
|
||||
integrity sha512-XS/JAc9nkmoiRaT/YFuX7r1ROvApQnY5BxOKyenAeDATvKZ80sIoXUw48U27KTsuJIsiPInNm5RieJGCJkoVmQ==
|
||||
zifferjs@^0.0.10:
|
||||
version "0.0.10"
|
||||
resolved "https://registry.yarnpkg.com/zifferjs/-/zifferjs-0.0.10.tgz#b8c2617f5fc8fb4422f311702785c47b752a920e"
|
||||
integrity sha512-kaMWRZcsAXXpPFjDoVtS3sQ5bZs+S7t3ejd8+WZV/nc52y/vXe/QcKAjT+jYCHGq8J1WMCITDn6OnVfswqJ8Ig==
|
||||
dependencies:
|
||||
lru-cache "^10.0.0"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user