Skip to content

Commit

Permalink
Line in and demos are now mutually exclusive.
Browse files Browse the repository at this point in the history
  • Loading branch information
PoneyClairDeLune committed Sep 26, 2023
1 parent 1b4ba94 commit afeece0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/basic/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ let RootDisplay = class extends CustomEventSource {
upThis.dispatchEvent("tempo", upThis.#noteTempo);
upThis.dispatchEvent("title", upThis.#titleName);
};
init() {
this.reset();
this.#midiPool = undefined;
};
async loadFile(blob) {
this.#midiPool = rawToPool(MidiParser.parse(new Uint8Array(await blob.arrayBuffer())));
};
Expand Down
9 changes: 7 additions & 2 deletions src/cambiare/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,13 @@ let Cambiare = class extends RootDisplay {
upThis.#sectInfo.events.innerText = `${sum.eventCount}`.padStart(3, "0");
upThis.#sectInfo.curPoly.innerText = `${curPoly}`.padStart(3, "0");
upThis.#sectInfo.maxPoly.innerText = `${upThis.#maxPoly}`.padStart(3, "0");
upThis.#sectInfo.barCount.innerText = sum.noteBar + 1;
upThis.#sectInfo.barNote.innerText = Math.floor(sum.noteBeat) + 1;
if (upThis.#clockSource?.realtime) {
upThis.#sectInfo.barCount.innerText = "LIVE";
upThis.#sectInfo.barNote.innerText = "0";
} else {
upThis.#sectInfo.barCount.innerText = sum.noteBar + 1;
upThis.#sectInfo.barNote.innerText = Math.floor(sum.noteBeat) + 1;
};
upThis.#scrollMeta(true);
let renderPortMax = upThis.#renderPort + upThis.#renderRange;
for (let part = 0; part < allocated.ch; part ++) {
Expand Down
27 changes: 23 additions & 4 deletions src/cambiare_demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,22 @@ self.Alpine = Alpine;

let useMidiBus = false;
let audioFilePlayer = $e("#audioFilePlayer");
let timePlexer = {};
Object.defineProperty(timePlexer, "currentTime", {
let timeMuxer = {};
Object.defineProperty(timeMuxer, "currentTime", {
get: () => {
return audioFilePlayer.currentTime || (Date.now() / 1000);
if (useMidiBus) {
return audioFilePlayer.currentTime || (Date.now() / 1000);
} else {
return audioFilePlayer.currentTime;
};
}
});
Object.defineProperty(timeMuxer, "realtime", {
get: () => {
return useMidiBus && !audioFilePlayer.currentTime;
}
});
let visualizer = new Cambiare($e(".cambiare"), timePlexer);
let visualizer = new Cambiare($e(".cambiare"), timeMuxer);
visualizer.reset();

Alpine.store("play", "smf");
Expand Down Expand Up @@ -90,6 +99,14 @@ self.gDemo = async function ({file, id, artist, title}) {
URL.revokeObjectURL(audioUri);
};
audioFilePlayer.src = "";
if (!file) {
Alpine.store("activeDemo", -1);
console.debug(`Cleared out demos.`);
return;
} else {
useMidiBus = false;
Alpine.store("useMidiBus", false);
};
visualizer.dispatchEvent("title", `Loading demo: ${artist} - ${title} ... (MIDI)`);
let midiBlob = await(await getBlobFrom(`${file}.mid`)).blob();
visualizer.dispatchEvent("title", `Loading demo: ${artist} - ${title} ... (audio)`);
Expand Down Expand Up @@ -158,6 +175,8 @@ self.gOpenSnd = async function () {
audioFilePlayer.src = audioUri;
};
self.gOpenLni = function () {
gDemo({});
visualizer.init();
useMidiBus = !useMidiBus;
Alpine.store("useMidiBus", useMidiBus);
visualizer.device.initOnReset = useMidiBus;
Expand Down

0 comments on commit afeece0

Please sign in to comment.