Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@blibliki/engine

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blibliki/engine - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

build/Module/Sequencer.d.ts

5

build/Engine.d.ts
import MidiDeviceManager from "./MidiDeviceManager";
import { EType } from "./MidiEvent";
import { AudioModule } from "./Module";

@@ -44,2 +45,3 @@ import { RouteInterface, RouteProps } from "./routes";

};
unregisterModule(id: string): string[];
updateNameModule(id: string, name: string): {

@@ -79,8 +81,9 @@ id: string;

};
triggerVirtualMidi(id: string, noteName: string, type: string): void;
triggerVirtualMidi(id: string, noteName: string, type: EType): void;
dispose(): void;
findById(id: string): AudioModule;
private applyRoutesRequired;
private moduleRouteIds;
}
declare const _default: Engine;
export default _default;

@@ -42,2 +42,10 @@ import { Context, setContext } from "tone";

}
unregisterModule(id) {
this.modules[id].dispose();
const moduleRouteIds = this.moduleRouteIds(id);
moduleRouteIds.forEach((routeId) => delete this.routes[routeId]);
applyRoutes(Object.values(this.routes));
delete this.modules[id];
return moduleRouteIds;
}
updateNameModule(id, name) {

@@ -106,4 +114,12 @@ const audioModule = this.findById(id);

}
moduleRouteIds(id) {
const cloneRoutes = { ...this.routes };
const routeIds = Object.keys(cloneRoutes).filter((routeId) => {
const { sourceId, destinationId } = cloneRoutes[routeId];
return sourceId === id || destinationId === id;
});
return routeIds;
}
}
export default Engine.getInstance();
//# sourceMappingURL=Engine.js.map

1

build/index.d.ts

@@ -5,4 +5,5 @@ export { default } from "./Engine";

export { default as Note } from "./Note";
export type { INote } from "./Note";
export type { MidiDeviceInterface } from "./MidiDevice";
export type { ModuleInterface, AudioModule } from "./Module";
export type { SerializeInterface as IOProps } from "./Module/IO";

@@ -1,13 +0,14 @@

import Note from "./Note";
import Note, { INote } from "./Note";
export declare type EType = "noteOn" | "noteOff";
export default class MidiEvent {
note?: Note;
readonly triggeredAt: number;
_type: string;
_type: EType;
private data;
private event;
static fromNote(noteName: string, type: string): MidiEvent;
constructor(event: MIDIMessageEvent);
get type(): string;
static fromNote(noteName: string | Note | INote, type: EType, triggeredAt?: number): MidiEvent;
constructor(event: MIDIMessageEvent, triggeredAt?: number);
get type(): EType;
get isNote(): boolean;
defineNote(): void;
}

@@ -13,11 +13,16 @@ import { now } from "tone";

event;
static fromNote(noteName, type) {
const event = new MidiEvent(new MIDIMessageEvent("", { data: new Uint8Array([0, 0, 0]) }));
event.note = new Note(noteName);
static fromNote(noteName, type, triggeredAt) {
const event = new MidiEvent(new MIDIMessageEvent("", { data: new Uint8Array([0, 0, 0]) }), triggeredAt);
if (noteName instanceof Note) {
event.note = noteName;
}
else {
event.note = new Note(noteName);
}
event._type = type;
return event;
}
constructor(event) {
constructor(event, triggeredAt) {
this.event = event;
this.triggeredAt = now();
this.triggeredAt = triggeredAt || now();
this.data = event.data;

@@ -24,0 +29,0 @@ this.defineNote();

@@ -13,2 +13,3 @@ import { InputNode } from "tone";

triggerRelease: Function;
triggerAttackRelease: Function;
}

@@ -48,5 +49,6 @@ export interface Voicable {

dispose(): void;
triggerAttack(midiEvent: MidiEvent): void;
triggerAttack(midiEvent: MidiEvent, duration?: number): void;
triggerRelease(midiEvent: MidiEvent): void;
midiTriggered: (midiEvent: MidiEvent) => void;
triggerAttackRelease(midiEvent: MidiEvent): void;
midiTriggered: (midiEvent: MidiEvent, duration?: number) => void;
serialize(): {

@@ -53,0 +55,0 @@ id: string;

@@ -70,3 +70,3 @@ import { v4 as uuidv4 } from "uuid";

}
triggerAttack(midiEvent) {
triggerAttack(midiEvent, duration) {
throw Error("triggerAttack not implemented");

@@ -77,6 +77,9 @@ }

}
midiTriggered = (midiEvent) => {
triggerAttackRelease(midiEvent) {
throw Error("triggerAttackRelease not implemented");
}
midiTriggered = (midiEvent, duration) => {
switch (midiEvent.type) {
case "noteOn":
this.triggerAttack(midiEvent);
this.triggerAttack(midiEvent, duration);
break;

@@ -83,0 +86,0 @@ case "noteOff":

@@ -63,3 +63,8 @@ import { Envelope as Env } from "tone";

this.triggeredAt = triggeredAt;
this.internalModule.triggerAttack(triggeredAt);
if (note?.duration) {
this.internalModule.triggerAttackRelease(note.duration, triggeredAt);
}
else {
this.internalModule.triggerAttack(triggeredAt);
}
}

@@ -66,0 +71,0 @@ triggerRelease(midiEvent) {

@@ -14,2 +14,3 @@ import { camelCase, upperFirst } from "lodash";

import BitCrusher from "./BitCrusher";
import Sequencer from "./Sequencer";
export { default } from "./Base";

@@ -55,2 +56,4 @@ export { default as PolyModule } from "./PolyModule";

return BitCrusher;
case Sequencer.moduleName:
return Sequencer;
default:

@@ -57,0 +60,0 @@ throw Error(`Unknown module type ${type}`);

@@ -23,2 +23,3 @@ import { v4 as uuidv4 } from "uuid";

plug(io) {
this.connections.push(io);
if (this.onPlug)

@@ -28,3 +29,2 @@ this.onPlug(io);

io.plug(this);
this.connections.push(io);
}

@@ -31,0 +31,0 @@ unPlug(io) {

@@ -0,1 +1,8 @@

import { TimeClass } from "tone";
export interface INote {
note: string;
time: string;
velocity?: number;
duration?: string;
}
export default class Note {

@@ -5,3 +12,6 @@ static _notes: Note[];

octave: number;
constructor(eventOrString: MIDIMessageEvent | string);
time: TimeClass;
velocity?: number;
duration?: string;
constructor(eventOrString: INote | MIDIMessageEvent | string, duration?: string);
static notes(octave?: number): Note[];

@@ -12,4 +22,6 @@ get isSemi(): boolean;

valueOf(): string;
serialize(): INote;
private fromString;
private fromEvent;
private fromProps;
}

@@ -0,1 +1,2 @@

import { Time } from "tone";
import frequencyTable from "./frequencyTable";

@@ -8,9 +9,16 @@ const Notes = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];

octave;
constructor(eventOrString) {
time = Time("0:0:0");
velocity = 1;
duration;
constructor(eventOrString, duration) {
this.duration = duration;
if (typeof eventOrString === "string") {
this.fromString(eventOrString);
}
else {
else if (eventOrString instanceof MIDIMessageEvent) {
this.fromEvent(eventOrString);
}
else {
this.fromProps(eventOrString);
}
}

@@ -44,2 +52,10 @@ static notes(octave = 3) {

}
serialize() {
return {
time: this.time.toBarsBeatsSixteenths(),
note: this.fullName,
duration: this.duration,
velocity: 1,
};
}
fromString(string) {

@@ -54,3 +70,10 @@ const matches = string.match(/(\w#?)(\d)?/) || [];

}
fromProps(props) {
const { note, time, duration, velocity } = props;
this.fromString(note);
this.time = Time(time);
this.duration = duration;
this.velocity = velocity;
}
}
//# sourceMappingURL=index.js.map
{
"name": "@blibliki/engine",
"version": "0.1.8",
"version": "0.1.9",
"main": "build/index.js",

@@ -5,0 +5,0 @@ "types": "build/index.d.ts",

import { Context, setContext } from "tone";
import MidiDeviceManager from "./MidiDeviceManager";
import MidiEvent from "./MidiEvent";
import MidiEvent, { EType } from "./MidiEvent";

@@ -71,2 +71,13 @@ import { AudioModule, createModule } from "./Module";

unregisterModule(id: string) {
this.modules[id].dispose();
const moduleRouteIds = this.moduleRouteIds(id);
moduleRouteIds.forEach((routeId) => delete this.routes[routeId]);
applyRoutes(Object.values(this.routes));
delete this.modules[id];
return moduleRouteIds;
}
updateNameModule(id: string, name: string) {

@@ -121,3 +132,3 @@ const audioModule = this.findById(id);

triggerVirtualMidi(id: string, noteName: string, type: string) {
triggerVirtualMidi(id: string, noteName: string, type: EType) {
const virtualMidi = this.findById(id) as VirtualMidi;

@@ -153,4 +164,16 @@

}
private moduleRouteIds(id: string) {
const cloneRoutes = { ...this.routes };
const routeIds = Object.keys(cloneRoutes).filter((routeId) => {
const { sourceId, destinationId } = cloneRoutes[routeId];
return sourceId === id || destinationId === id;
});
return routeIds;
}
}
export default Engine.getInstance();

@@ -6,2 +6,3 @@ export { default } from "./Engine";

export type { INote } from "./Note";
export type { MidiDeviceInterface } from "./MidiDevice";

@@ -8,0 +9,0 @@ export type { ModuleInterface, AudioModule } from "./Module";

import { now } from "tone";
import Note from "./Note";
import Note, { INote } from "./Note";
const EventType: { [key: number]: string } = {
const EventType: { [key: number]: EType } = {
8: "noteOff",

@@ -9,14 +9,26 @@ 9: "noteOn",

export type EType = "noteOn" | "noteOff";
export default class MidiEvent {
note?: Note;
readonly triggeredAt: number;
_type: string;
_type: EType;
private data: Uint8Array;
private event: MIDIMessageEvent;
static fromNote(noteName: string, type: string) {
static fromNote(
noteName: string | Note | INote,
type: EType,
triggeredAt?: number
) {
const event = new MidiEvent(
new MIDIMessageEvent("", { data: new Uint8Array([0, 0, 0]) })
new MIDIMessageEvent("", { data: new Uint8Array([0, 0, 0]) }),
triggeredAt
);
event.note = new Note(noteName);
if (noteName instanceof Note) {
event.note = noteName;
} else {
event.note = new Note(noteName);
}
event._type = type;

@@ -27,5 +39,5 @@

constructor(event: MIDIMessageEvent) {
constructor(event: MIDIMessageEvent, triggeredAt?: number) {
this.event = event;
this.triggeredAt = now();
this.triggeredAt = triggeredAt || now();
this.data = event.data;

@@ -32,0 +44,0 @@ this.defineNote();

@@ -17,2 +17,3 @@ import { v4 as uuidv4 } from "uuid";

triggerRelease: Function;
triggerAttackRelease: Function;
}

@@ -125,3 +126,3 @@

triggerAttack(midiEvent: MidiEvent) {
triggerAttack(midiEvent: MidiEvent, duration?: number) {
throw Error("triggerAttack not implemented");

@@ -134,6 +135,10 @@ }

midiTriggered = (midiEvent: MidiEvent) => {
triggerAttackRelease(midiEvent: MidiEvent) {
throw Error("triggerAttackRelease not implemented");
}
midiTriggered = (midiEvent: MidiEvent, duration?: number) => {
switch (midiEvent.type) {
case "noteOn":
this.triggerAttack(midiEvent);
this.triggerAttack(midiEvent, duration);
break;

@@ -140,0 +145,0 @@ case "noteOff":

@@ -96,3 +96,8 @@ import { Envelope as Env } from "tone";

this.triggeredAt = triggeredAt;
this.internalModule.triggerAttack(triggeredAt);
if (note?.duration) {
this.internalModule.triggerAttackRelease(note.duration, triggeredAt);
} else {
this.internalModule.triggerAttack(triggeredAt);
}
}

@@ -99,0 +104,0 @@

@@ -16,2 +16,3 @@ import { camelCase, upperFirst } from "lodash";

import BitCrusher from "./BitCrusher";
import Sequencer from "./Sequencer";

@@ -77,2 +78,4 @@ export { default } from "./Base";

return BitCrusher;
case Sequencer.moduleName:
return Sequencer;
default:

@@ -79,0 +82,0 @@ throw Error(`Unknown module type ${type}`);

@@ -42,7 +42,7 @@ import { v4 as uuidv4 } from "uuid";

plug(io: IO) {
this.connections.push(io);
if (this.onPlug) this.onPlug(io);
if (this.ioType === IOType.Output) io.plug(this);
this.connections.push(io);
}

@@ -49,0 +49,0 @@

@@ -0,1 +1,3 @@

import { TimeClass, Time } from "tone";
import MidiEvent from "../MidiEvent";
import frequencyTable from "./frequencyTable";

@@ -7,2 +9,9 @@

export interface INote {
note: string;
time: string;
velocity?: number;
duration?: string;
}
export default class Note {

@@ -12,8 +21,18 @@ static _notes: Note[];

octave: number;
time: TimeClass = Time("0:0:0");
velocity?: number = 1;
duration?: string;
constructor(eventOrString: MIDIMessageEvent | string) {
constructor(
eventOrString: INote | MIDIMessageEvent | string,
duration?: string
) {
this.duration = duration;
if (typeof eventOrString === "string") {
this.fromString(eventOrString);
} else if (eventOrString instanceof MIDIMessageEvent) {
this.fromEvent(eventOrString);
} else {
this.fromEvent(eventOrString);
this.fromProps(eventOrString);
}

@@ -56,2 +75,11 @@ }

serialize(): INote {
return {
time: this.time.toBarsBeatsSixteenths(),
note: this.fullName,
duration: this.duration,
velocity: 1,
};
}
private fromString(string: string) {

@@ -68,2 +96,11 @@ const matches = string.match(/(\w#?)(\d)?/) || [];

}
private fromProps(props: INote) {
const { note, time, duration, velocity } = props;
this.fromString(note);
this.time = Time(time);
this.duration = duration;
this.velocity = velocity;
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc