diff --git a/app.js b/app.js deleted file mode 100644 index 8b5d540..0000000 --- a/app.js +++ /dev/null @@ -1,9 +0,0 @@ -const express = require('express') -const app = express() -const port = process.env.PORT || 5000 - -app.use(express.static("pub")); - -app.listen(port, () => { - console.log(`Static express server listening on port ${port}`) -}); \ No newline at end of file diff --git a/pub/Elektronomia - Collide.mp3 b/pub/Elektronomia - Collide.mp3 deleted file mode 100644 index 012819e..0000000 Binary files a/pub/Elektronomia - Collide.mp3 and /dev/null differ diff --git a/pub/audioshowkit.js b/pub/audioshowkit.js deleted file mode 100644 index 0db3e9c..0000000 --- a/pub/audioshowkit.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; - -function VisualizerCore(mediaSource, fftSize = 1024) { - this._stream = mediaSource; - this._analyzing = false; - this._updateListeners = []; - this._audioCtx = new window.AudioContext(); - this._source = null; // Prepare for either a MediaStream or a MediaElement. - try { - this.source = this._audioCtx.createMediaStreamSource(this._stream); - } catch (e) { - this._source = this._audioCtx.createMediaElementSource(this._stream); - } - this._analyzer = this._audioCtx.createAnalyser(); - this._analyzer.fftSize = fftSize; - this._source.connect(this._analyzer); - this._analyzer.connect(this._audioCtx.destination); - this._buffer = new Uint8Array(this._analyzer.frequencyBinCount); - - this.lastUpdate = null; - - this.analyze = function () { - if (this._analyzing) { - return; - } - this._analyzing = true; - requestAnimationFrame(this.update); - }; - - let vcore = this; // since calling from requestAnimationFrame means "this" is no longer set to produced object. - this.update = function (timestamp) { - if (!vcore._analyzing) return; - - requestAnimationFrame(vcore.update); - if (!vcore.lastUpdate) { - vcore.lastUpdate = timestamp; - } - let delta = timestamp - vcore.lastUpdate; - vcore._analyzer.getByteFrequencyData(vcore._buffer); - - vcore._updateListeners.forEach(listener => { - listener(delta, vcore._buffer); - }); - }; - this.stop = function () { - this._analyzing = false; - }; - this.addUpdateListener = function (listener) { - this._updateListeners.push(listener); - }; - this.getNumberOfBins = function () { - return this._buffer.length; - }; -} diff --git a/pub/examples.html b/pub/examples.html deleted file mode 100644 index a287ed0..0000000 --- a/pub/examples.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - AudioShowKit visual test - - - - - - - - - -

Hit start to see demo!

- - -

Horizontal Bar Pattern

-

Below is a canvas that has all bin values being drawn live using the built-in horizontal bar pattern.

- Canvases don't seem to be supported! Please try a different browser. - -

Binding frequency bin values to element styles

-

Has never been this easy! Here we bind the width of a div to a frequency bin.

-
- -

Here we bind a frequency to the colour of a div.

-
- - - \ No newline at end of file diff --git a/pub/examples.js b/pub/examples.js deleted file mode 100644 index fc929d0..0000000 --- a/pub/examples.js +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; - -// We will see if the visualizers core and event systems are working correctly. -let startBtn = document.getElementById("startbtn"); -startBtn.addEventListener("click", async (ev) => { - let mediaStream = new Audio("Elektronomia - Collide.mp3"); - mediaStream.addEventListener("canplaythrough", (ev) => { - let visCore = new VisualizerCore(mediaStream, 128); - let coreAndEventCanvas = document.getElementById("horizontal"); - coreAndEventCanvas.width = 640; - coreAndEventCanvas.height = 200; - - mediaStream.play(); - visCore.analyze(); - - bindHorizontalBar(coreAndEventCanvas, visCore); // Pre-made simple horizontal bar visualizer. - - let widthDiv = document.getElementById("widthDiv"); - widthDiv.style.height = "20px"; - widthDiv.style.backgroundColor = "orange"; - visCore.addUpdateListener((delta, bins) => { - widthDiv.style.width = bins[3] + "px"; - }) - - let colourDiv = document.getElementById("colourDiv"); - colourDiv.style.height = "20px"; - visCore.addUpdateListener((delta, bins) => { - colourDiv.style.backgroundColor = "rgb(" + bins[0] + "," + bins[1] + ", " + bins[4] + ")"; - }) - }); - -}); \ No newline at end of file diff --git a/pub/patterns/HorizontalBar.js b/pub/patterns/HorizontalBar.js deleted file mode 100644 index d5a5d65..0000000 --- a/pub/patterns/HorizontalBar.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; - -function bindHorizontalBar(canvasElement, visualizerCore) { - let _width = canvasElement.width; - let _height = canvasElement.height; - let _canvasCtx = canvasElement.getContext("2d"); - let _visualizerCore = visualizerCore; - let update = function (delta, bins) { - _canvasCtx.clearRect(0, 0, _width, _height); // clear canvas. - let barWidth = Math.floor(_width / bins.length) - 1; // -1 for 1 pixel gap between bars. - let barIndex = 0; - bins.forEach(bin => { - let normalBin = bin / 255.0; - _canvasCtx.fillStyle = "rgb(" + 0 + "," + bin + "," + bin + ")"; - let barHeight = _height * normalBin; - _canvasCtx.fillRect(barIndex * barWidth, _height - barHeight, barWidth, barHeight); - barIndex += 1; - }); - }; - _visualizerCore.addUpdateListener(update); -} \ No newline at end of file