@blibliki/engine
Advanced tools
Comparing version 0.1.13 to 0.1.14
@@ -18,3 +18,2 @@ import Module, { DummnyInternalModule } from "./Base"; | ||
private part; | ||
private barParts; | ||
constructor(name: string, props: Partial<ISequencer>); | ||
@@ -39,4 +38,3 @@ get props(): ISequencer; | ||
private onPartEvent; | ||
private onSequenceEvent; | ||
} | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import { now, Part, Time } from "tone"; | ||
import { now, Part } from "tone"; | ||
import Module, { DummnyInternalModule } from "./Base"; | ||
@@ -13,3 +13,2 @@ import MidiEvent from "../MidiEvent"; | ||
part; | ||
barParts = []; | ||
constructor(name, props) { | ||
@@ -68,5 +67,2 @@ super(new DummnyInternalModule(), { | ||
this.part.loopEnd = this.loopEnd; | ||
this.sequences.forEach((_, i) => { | ||
this.part.add(`${i}:0:0`, i); | ||
}); | ||
} | ||
@@ -112,3 +108,3 @@ adjust() { | ||
const index = sequences.length; | ||
sequences.push({ active: false, time: `0:0:${index}`, notes: [] }); | ||
sequences.push({ active: false, time: `${bar}:0:${index}`, notes: [] }); | ||
} | ||
@@ -120,10 +116,5 @@ allSequences[bar] = sequences; | ||
updateBarParts() { | ||
this.barParts = this.sequences.map((barSeqs, _) => { | ||
const part = new Part(this.onSequenceEvent, []); | ||
barSeqs.forEach((seq) => part.add(seq.time, seq)); | ||
return part; | ||
}); | ||
this.part.clear(); | ||
this.barParts.forEach((_, bar) => { | ||
this.part.add(`${bar}:0:0`, bar); | ||
this.sequences.forEach((barSeqs, i) => { | ||
barSeqs.forEach((seq) => this.part.add(seq.time, seq)); | ||
}); | ||
@@ -135,12 +126,3 @@ this.part.loopEnd = this.loopEnd; | ||
} | ||
onPartEvent = (time, bar) => { | ||
if (bar === null) | ||
return; | ||
const part = this.barParts[bar]; | ||
if (!part) | ||
return; | ||
part.start(time); | ||
part.stop(time + Time("1m").toSeconds()); | ||
}; | ||
onSequenceEvent = (time, sequence) => { | ||
onPartEvent = (time, sequence) => { | ||
if (!sequence.active) | ||
@@ -147,0 +129,0 @@ return; |
{ | ||
"name": "@blibliki/engine", | ||
"version": "0.1.13", | ||
"version": "0.1.14", | ||
"main": "build/index.js", | ||
@@ -5,0 +5,0 @@ "types": "build/index.d.ts", |
@@ -30,4 +30,3 @@ import { now, Part, Time } from "tone"; | ||
midiOutput: Output; | ||
private part: Part<number>; | ||
private barParts: Part<ISequence>[] = []; | ||
private part: Part<ISequence>; | ||
@@ -97,9 +96,5 @@ constructor(name: string, props: Partial<ISequencer>) { | ||
private initializePart() { | ||
this.part = new Part(this.onPartEvent, [] as number[]); | ||
this.part = new Part(this.onPartEvent, [] as ISequence[]); | ||
this.part.loop = true; | ||
this.part.loopEnd = this.loopEnd; | ||
this.sequences.forEach((_, i) => { | ||
this.part.add(`${i}:0:0`, i); | ||
}); | ||
} | ||
@@ -150,3 +145,3 @@ | ||
const index = sequences.length; | ||
sequences.push({ active: false, time: `0:0:${index}`, notes: [] }); | ||
sequences.push({ active: false, time: `${bar}:0:${index}`, notes: [] }); | ||
} | ||
@@ -160,13 +155,8 @@ allSequences[bar] = sequences; | ||
private updateBarParts() { | ||
this.barParts = this.sequences.map((barSeqs, _) => { | ||
const part = new Part(this.onSequenceEvent, [] as Array<ISequence>); | ||
barSeqs.forEach((seq) => part.add(seq.time, seq)); | ||
this.part.clear(); | ||
return part; | ||
this.sequences.forEach((barSeqs, i) => { | ||
barSeqs.forEach((seq) => this.part.add(seq.time, seq)); | ||
}); | ||
this.part.clear(); | ||
this.barParts.forEach((_, bar) => { | ||
this.part.add(`${bar}:0:0`, bar); | ||
}); | ||
this.part.loopEnd = this.loopEnd; | ||
@@ -179,13 +169,3 @@ } | ||
private onPartEvent = (time: number, bar: number | null) => { | ||
if (bar === null) return; | ||
const part = this.barParts[bar]; | ||
if (!part) return; | ||
part.start(time); | ||
part.stop(time + Time("1m").toSeconds()); | ||
}; | ||
private onSequenceEvent = (time: number, sequence: ISequence) => { | ||
private onPartEvent = (time: number, sequence: ISequence) => { | ||
if (!sequence.active) return; | ||
@@ -192,0 +172,0 @@ |
Sorry, the diff of this file is not supported yet
217086
5081