diff --git a/Resources/oscilloscope/juce/check_native_interop.js b/Resources/oscilloscope/juce/check_native_interop.js deleted file mode 100644 index 6e270881..00000000 --- a/Resources/oscilloscope/juce/check_native_interop.js +++ /dev/null @@ -1,146 +0,0 @@ -/* - ============================================================================== - - This file is part of the JUCE framework. - Copyright (c) Raw Material Software Limited - - JUCE is an open source framework subject to commercial or open source - licensing. - - By downloading, installing, or using the JUCE framework, or combining the - JUCE framework with any other source code, object code, content or any other - copyrightable work, you agree to the terms of the JUCE End User Licence - Agreement, and all incorporated terms including the JUCE Privacy Policy and - the JUCE Website Terms of Service, as applicable, which will bind you. If you - do not agree to the terms of these agreements, we will not license the JUCE - framework to you, and you must discontinue the installation or download - process and cease use of the JUCE framework. - - JUCE End User Licence Agreement: https://juce.com/legal/juce-8-licence/ - JUCE Privacy Policy: https://juce.com/juce-privacy-policy - JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/ - - Or: - - You may also use this code under the terms of the AGPLv3: - https://www.gnu.org/licenses/agpl-3.0.en.html - - THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL - WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF - MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. - - ============================================================================== -*/ - -if ( - typeof window.__JUCE__ !== "undefined" && - typeof window.__JUCE__.getAndroidUserScripts !== "undefined" && - typeof window.inAndroidUserScriptEval === "undefined" -) { - window.inAndroidUserScriptEval = true; - eval(window.__JUCE__.getAndroidUserScripts()); - delete window.inAndroidUserScriptEval; -} - -{ - if (typeof window.__JUCE__ === "undefined") { - console.warn( - "The 'window.__JUCE__' object is undefined." + - " Native integration features will not work." + - " Defining a placeholder 'window.__JUCE__' object." - ); - - window.__JUCE__ = { - postMessage: function () {}, - }; - } - - if (typeof window.__JUCE__.initialisationData === "undefined") { - window.__JUCE__.initialisationData = { - __juce__platform: [], - __juce__functions: [], - __juce__registeredGlobalEventIds: [], - __juce__sliders: [], - __juce__toggles: [], - __juce__comboBoxes: [], - }; - } - - class ListenerList { - constructor() { - this.listeners = new Map(); - this.listenerId = 0; - } - - addListener(fn) { - const newListenerId = this.listenerId++; - this.listeners.set(newListenerId, fn); - return newListenerId; - } - - removeListener(id) { - if (this.listeners.has(id)) { - this.listeners.delete(id); - } - } - - callListeners(payload) { - for (const [, value] of this.listeners) { - value(payload); - } - } - } - - class EventListenerList { - constructor() { - this.eventListeners = new Map(); - } - - addEventListener(eventId, fn) { - if (!this.eventListeners.has(eventId)) - this.eventListeners.set(eventId, new ListenerList()); - - const id = this.eventListeners.get(eventId).addListener(fn); - - return [eventId, id]; - } - - removeEventListener([eventId, id]) { - if (this.eventListeners.has(eventId)) { - this.eventListeners.get(eventId).removeListener(id); - } - } - - emitEvent(eventId, object) { - if (this.eventListeners.has(eventId)) - this.eventListeners.get(eventId).callListeners(object); - } - } - - class Backend { - constructor() { - this.listeners = new EventListenerList(); - } - - addEventListener(eventId, fn) { - return this.listeners.addEventListener(eventId, fn); - } - - removeEventListener([eventId, id]) { - this.listeners.removeEventListener(eventId, id); - } - - emitEvent(eventId, object) { - window.__JUCE__.postMessage( - JSON.stringify({ eventId: eventId, payload: object }) - ); - } - - emitByBackend(eventId, object) { - this.listeners.emitEvent(eventId, JSON.parse(object)); - } - } - - if (typeof window.__JUCE__.backend === "undefined") - window.__JUCE__.backend = new Backend(); -} diff --git a/Resources/oscilloscope/juce/index.js b/Resources/oscilloscope/juce/index.js deleted file mode 100644 index ddeaea8d..00000000 --- a/Resources/oscilloscope/juce/index.js +++ /dev/null @@ -1,492 +0,0 @@ -/* - ============================================================================== - - This file is part of the JUCE framework. - Copyright (c) Raw Material Software Limited - - JUCE is an open source framework subject to commercial or open source - licensing. - - By downloading, installing, or using the JUCE framework, or combining the - JUCE framework with any other source code, object code, content or any other - copyrightable work, you agree to the terms of the JUCE End User Licence - Agreement, and all incorporated terms including the JUCE Privacy Policy and - the JUCE Website Terms of Service, as applicable, which will bind you. If you - do not agree to the terms of these agreements, we will not license the JUCE - framework to you, and you must discontinue the installation or download - process and cease use of the JUCE framework. - - JUCE End User Licence Agreement: https://juce.com/legal/juce-8-licence/ - JUCE Privacy Policy: https://juce.com/juce-privacy-policy - JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/ - - Or: - - You may also use this code under the terms of the AGPLv3: - https://www.gnu.org/licenses/agpl-3.0.en.html - - THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL - WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF - MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. - - ============================================================================== -*/ - -import "./check_native_interop.js"; - -class PromiseHandler { - constructor() { - this.lastPromiseId = 0; - this.promises = new Map(); - - window.__JUCE__.backend.addEventListener( - "__juce__complete", - ({ promiseId, result }) => { - if (this.promises.has(promiseId)) { - this.promises.get(promiseId).resolve(result); - this.promises.delete(promiseId); - } - } - ); - } - - createPromise() { - const promiseId = this.lastPromiseId++; - const result = new Promise((resolve, reject) => { - this.promises.set(promiseId, { resolve: resolve, reject: reject }); - }); - return [promiseId, result]; - } -} - -const promiseHandler = new PromiseHandler(); - -/** - * Returns a function object that calls a function registered on the JUCE backend and forwards all - * parameters to it. - * - * The provided name should be the same as the name argument passed to - * WebBrowserComponent::Options.withNativeFunction() on the backend. - * - * @param {String} name - */ -function getNativeFunction(name) { - if (!window.__JUCE__.initialisationData.__juce__functions.includes(name)) - console.warn( - `Creating native function binding for '${name}', which is unknown to the backend` - ); - - const f = function () { - const [promiseId, result] = promiseHandler.createPromise(); - - window.__JUCE__.backend.emitEvent("__juce__invoke", { - name: name, - params: Array.prototype.slice.call(arguments), - resultId: promiseId, - }); - - return result; - }; - - return f; -} - -//============================================================================== - -class ListenerList { - constructor() { - this.listeners = new Map(); - this.listenerId = 0; - } - - addListener(fn) { - const newListenerId = this.listenerId++; - this.listeners.set(newListenerId, fn); - return newListenerId; - } - - removeListener(id) { - if (this.listeners.has(id)) { - this.listeners.delete(id); - } - } - - callListeners(payload) { - for (const [, value] of this.listeners) { - value(payload); - } - } -} - -const BasicControl_valueChangedEventId = "valueChanged"; -const BasicControl_propertiesChangedId = "propertiesChanged"; - -class SliderState { - constructor(name) { - if (!window.__JUCE__.initialisationData.__juce__sliders.includes(name)) - console.warn( - "Creating SliderState for '" + - name + - "', which is unknown to the backend" - ); - - this.name = name; - this.identifier = "__juce__slider" + this.name; - this.scaledValue = 0; - this.properties = { - start: 0, - end: 1, - skew: 1, - name: "", - label: "", - numSteps: 100, - interval: 0, - parameterIndex: -1, - }; - this.valueChangedEvent = new ListenerList(); - this.propertiesChangedEvent = new ListenerList(); - - window.__JUCE__.backend.addEventListener(this.identifier, (event) => - this.handleEvent(event) - ); - - window.__JUCE__.backend.emitEvent(this.identifier, { - eventType: "requestInitialUpdate", - }); - } - - setNormalisedValue(newValue) { - this.scaledValue = this.snapToLegalValue( - this.normalisedToScaledValue(newValue) - ); - - window.__JUCE__.backend.emitEvent(this.identifier, { - eventType: BasicControl_valueChangedEventId, - value: this.scaledValue, - }); - } - - sliderDragStarted() {} - - sliderDragEnded() {} - - handleEvent(event) { - if (event.eventType == BasicControl_valueChangedEventId) { - this.scaledValue = event.value; - this.valueChangedEvent.callListeners(); - } - if (event.eventType == BasicControl_propertiesChangedId) { - // eslint-disable-next-line no-unused-vars - let { eventType: _, ...rest } = event; - this.properties = rest; - this.propertiesChangedEvent.callListeners(); - } - } - - getScaledValue() { - return this.scaledValue; - } - - getNormalisedValue() { - return Math.pow( - (this.scaledValue - this.properties.start) / - (this.properties.end - this.properties.start), - this.properties.skew - ); - } - - normalisedToScaledValue(normalisedValue) { - return ( - Math.pow(normalisedValue, 1 / this.properties.skew) * - (this.properties.end - this.properties.start) + - this.properties.start - ); - } - - snapToLegalValue(value) { - const interval = this.properties.interval; - - if (interval == 0) return value; - - const start = this.properties.start; - const clamp = (val, min = 0, max = 1) => Math.max(min, Math.min(max, val)); - - return clamp( - start + interval * Math.floor((value - start) / interval + 0.5), - this.properties.start, - this.properties.end - ); - } -} - -const sliderStates = new Map(); - -for (const sliderName of window.__JUCE__.initialisationData.__juce__sliders) - sliderStates.set(sliderName, new SliderState(sliderName)); - -/** - * Returns a SliderState object that is connected to the backend WebSliderRelay object that was - * created with the same name argument. - * - * To register a WebSliderRelay object create one with the right name and add it to the - * WebBrowserComponent::Options struct using withOptionsFrom. - * - * @param {String} name - */ -function getSliderState(name) { - if (!sliderStates.has(name)) sliderStates.set(name, new SliderState(name)); - - return sliderStates.get(name); -} - -class ToggleState { - constructor(name) { - if (!window.__JUCE__.initialisationData.__juce__toggles.includes(name)) - console.warn( - "Creating ToggleState for '" + - name + - "', which is unknown to the backend" - ); - - this.name = name; - this.identifier = "__juce__toggle" + this.name; - this.value = false; - this.properties = { - name: "", - parameterIndex: -1, - }; - this.valueChangedEvent = new ListenerList(); - this.propertiesChangedEvent = new ListenerList(); - - window.__JUCE__.backend.addEventListener(this.identifier, (event) => - this.handleEvent(event) - ); - - window.__JUCE__.backend.emitEvent(this.identifier, { - eventType: "requestInitialUpdate", - }); - } - - getValue() { - return this.value; - } - - setValue(newValue) { - this.value = newValue; - - window.__JUCE__.backend.emitEvent(this.identifier, { - eventType: BasicControl_valueChangedEventId, - value: this.value, - }); - } - - handleEvent(event) { - if (event.eventType == BasicControl_valueChangedEventId) { - this.value = event.value; - this.valueChangedEvent.callListeners(); - } - if (event.eventType == BasicControl_propertiesChangedId) { - // eslint-disable-next-line no-unused-vars - let { eventType: _, ...rest } = event; - this.properties = rest; - this.propertiesChangedEvent.callListeners(); - } - } -} - -const toggleStates = new Map(); - -for (const name of window.__JUCE__.initialisationData.__juce__toggles) - toggleStates.set(name, new ToggleState(name)); - -/** - * Returns a ToggleState object that is connected to the backend WebToggleButtonRelay object that was - * created with the same name argument. - * - * To register a WebToggleButtonRelay object create one with the right name and add it to the - * WebBrowserComponent::Options struct using withOptionsFrom. - * - * @param {String} name - */ -function getToggleState(name) { - if (!toggleStates.has(name)) toggleStates.set(name, new ToggleState(name)); - - return toggleStates.get(name); -} - -class ComboBoxState { - constructor(name) { - if (!window.__JUCE__.initialisationData.__juce__comboBoxes.includes(name)) - console.warn( - "Creating ComboBoxState for '" + - name + - "', which is unknown to the backend" - ); - - this.name = name; - this.identifier = "__juce__comboBox" + this.name; - this.value = 0.0; - this.properties = { - name: "", - parameterIndex: -1, - choices: [], - }; - this.valueChangedEvent = new ListenerList(); - this.propertiesChangedEvent = new ListenerList(); - - window.__JUCE__.backend.addEventListener(this.identifier, (event) => - this.handleEvent(event) - ); - - window.__JUCE__.backend.emitEvent(this.identifier, { - eventType: "requestInitialUpdate", - }); - } - - getChoiceIndex() { - return Math.round(this.value * (this.properties.choices.length - 1)); - } - - setChoiceIndex(index) { - const numItems = this.properties.choices.length; - this.value = numItems > 1 ? index / (numItems - 1) : 0.0; - - window.__JUCE__.backend.emitEvent(this.identifier, { - eventType: BasicControl_valueChangedEventId, - value: this.value, - }); - } - - handleEvent(event) { - if (event.eventType == BasicControl_valueChangedEventId) { - this.value = event.value; - this.valueChangedEvent.callListeners(); - } - if (event.eventType == BasicControl_propertiesChangedId) { - // eslint-disable-next-line no-unused-vars - let { eventType: _, ...rest } = event; - this.properties = rest; - this.propertiesChangedEvent.callListeners(); - } - } -} - -const comboBoxStates = new Map(); - -for (const name of window.__JUCE__.initialisationData.__juce__comboBoxes) - comboBoxStates.set(name, new ComboBoxState(name)); - -/** - * Returns a ComboBoxState object that is connected to the backend WebComboBoxRelay object that was - * created with the same name argument. - * - * To register a WebComboBoxRelay object create one with the right name and add it to the - * WebBrowserComponent::Options struct using withOptionsFrom. - * - * @param {String} name - */ -function getComboBoxState(name) { - if (!comboBoxStates.has(name)) - comboBoxStates.set(name, new ComboBoxState(name)); - - return comboBoxStates.get(name); -} - -/** - * Appends a platform-specific prefix to the path to ensure that a request sent to this address will - * be received by the backend's ResourceProvider. - * @param {String} path - */ -function getBackendResourceAddress(path) { - const platform = - window.__JUCE__.initialisationData.__juce__platform.length > 0 - ? window.__JUCE__.initialisationData.__juce__platform[0] - : ""; - - if (platform == "windows" || platform == "android") - return "https://juce.backend/" + path; - - if (platform == "macos" || platform == "ios" || platform == "linux") - return "juce://juce.backend/" + path; - - console.warn( - "getBackendResourceAddress() called, but no JUCE native backend is detected." - ); - return path; -} - -/** - * This helper class is intended to aid the implementation of - * AudioProcessorEditor::getControlParameterIndex() for editors using a WebView interface. - * - * Create an instance of this class and call its handleMouseMove() method in each mousemove event. - * - * This class can be used to continuously report the controlParameterIndexAnnotation attribute's - * value related to the DOM element that is currently under the mouse pointer. - * - * This value is defined at all times as follows - * * the annotation attribute's value for the DOM element directly under the mouse, if it has it, - * * the annotation attribute's value for the first parent element, that has it, - * * -1 otherwise. - * - * Whenever there is a change in this value, an event is emitted to the frontend with the new value. - * You can use a ControlParameterIndexReceiver object on the backend to listen to these events. - * - * @param {String} controlParameterIndexAnnotation - */ -class ControlParameterIndexUpdater { - constructor(controlParameterIndexAnnotation) { - this.controlParameterIndexAnnotation = controlParameterIndexAnnotation; - this.lastElement = null; - this.lastControlParameterIndex = null; - } - - handleMouseMove(event) { - const currentElement = document.elementFromPoint( - event.clientX, - event.clientY - ); - - if (currentElement === this.lastElement) return; - this.lastElement = currentElement; - - let controlParameterIndex = -1; - - if (currentElement !== null) - controlParameterIndex = this.#getControlParameterIndex(currentElement); - - if (controlParameterIndex === this.lastControlParameterIndex) return; - this.lastControlParameterIndex = controlParameterIndex; - - window.__JUCE__.backend.emitEvent( - "__juce__controlParameterIndexChanged", - controlParameterIndex - ); - } - - //============================================================================== - #getControlParameterIndex(element) { - const isValidNonRootElement = (e) => { - return e !== null && e !== document.documentElement; - }; - - while (isValidNonRootElement(element)) { - if (element.hasAttribute(this.controlParameterIndexAnnotation)) { - return element.getAttribute(this.controlParameterIndexAnnotation); - } - - element = element.parentElement; - } - - return -1; - } -} - -export { - getNativeFunction, - getSliderState, - getToggleState, - getComboBoxState, - getBackendResourceAddress, - ControlParameterIndexUpdater, -}; diff --git a/Resources/oscilloscope/juce/package.json b/Resources/oscilloscope/juce/package.json deleted file mode 100644 index 49409b41..00000000 --- a/Resources/oscilloscope/juce/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "juce-framework-frontend", - "version": "7.0.7" -} diff --git a/Resources/oscilloscope/oscilloscope.html b/Resources/oscilloscope/oscilloscope.html deleted file mode 100644 index c1743731..00000000 --- a/Resources/oscilloscope/oscilloscope.html +++ /dev/null @@ -1,517 +0,0 @@ - - - - - - - - - -
-
- - - - - -
-
Paused
- -
- - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Resources/oscilloscope/oscilloscope.js b/Resources/oscilloscope/oscilloscope.js deleted file mode 100644 index 33faa462..00000000 --- a/Resources/oscilloscope/oscilloscope.js +++ /dev/null @@ -1,770 +0,0 @@ -// THIS CODE HAS BEEN HEAVILY ADAPTED FROM https://dood.al/oscilloscope/ AS PERMITTED BY THE AUTHOR - -import * as Juce from "./index.js"; - -var AudioSystem = -{ - microphoneActive : false, - - init : function (bufferSize) - { - this.bufferSize = bufferSize; - this.timePerSample = 1/externalSampleRate; - this.oldXSamples = new Float32Array(this.bufferSize); - this.oldYSamples = new Float32Array(this.bufferSize); - this.oldZSamples = new Float32Array(this.bufferSize); - this.smoothedXSamples = new Float32Array(Filter.nSmoothedSamples); - this.smoothedYSamples = new Float32Array(Filter.nSmoothedSamples); - this.smoothedZSamples = new Float32Array(Filter.nSmoothedSamples); - }, - - startSound : function() - { - window.__JUCE__.backend.addEventListener("audioUpdated", doScriptProcessor); - } -} - -var Filter = -{ - lanczosTweak : 1.5, - - init : function(bufferSize, a, steps) - { - this.bufferSize = bufferSize; - this.a = a; - this.steps = steps; - this.radius = a * steps; - this.nSmoothedSamples = this.bufferSize*this.steps + 1; - this.allSamples = new Float32Array(2*this.bufferSize); - - this.createLanczosKernel(); - }, - - - generateSmoothedSamples : function (oldSamples, samples, smoothedSamples) - { - var bufferSize = this.bufferSize; - var allSamples = this.allSamples; - var nSmoothedSamples = this.nSmoothedSamples; - var a = this.a; - var steps = this.steps; - var K = this.K; - - for (var i=0; i 300) - { - nEdgesThisTime *= 300/this.totalLength; - nEdgesThisTime = Math.floor(nEdgesThisTime); - }*/ - - gl.drawElements(gl.TRIANGLES, nEdgesThisTime * 6, gl.UNSIGNED_SHORT, 0); - - gl.disableVertexAttribArray(program.aStart); - gl.disableVertexAttribArray(program.aEnd); - gl.disableVertexAttribArray(program.aIdx); - }, - - fade : function(alpha) - { - this.setNormalBlending(); - - var program = this.simpleShader; - gl.useProgram(program); - gl.enableVertexAttribArray(program.vertexPosition); - gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); - gl.bufferData(gl.ARRAY_BUFFER, this.fullScreenQuad, gl.STATIC_DRAW); - gl.vertexAttribPointer(program.vertexPosition, 2, gl.FLOAT, false, 0, 0); - gl.bindBuffer(gl.ARRAY_BUFFER, null); - gl.uniform4fv(program.colour, [0.0, 0.0, 0.0, this.fadeAmount]); - gl.drawArrays(gl.TRIANGLES, 0, 6); - gl.disableVertexAttribArray(program.vertexPosition); - }, - - loadTexture : function(src) - { - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - // Fill with grey pixel, as placeholder until loaded - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, - new Uint8Array([128, 128, 128, 255])); - // Asynchronously load an image - var image = new Image(); - image.crossOrigin = "anonymous"; - image.src = src; - image.addEventListener('load', function() - { - // Now that the image has loaded make copy it to the texture. - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - //gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR); - gl.generateMipmap(gl.TEXTURE_2D); - //hardcoded: - texture.width = texture.height = 512; - if (controls.grid) Render.drawGrid(texture); - }); - return texture; - }, - - drawGrid : function(texture) - { - this.activateTargetTexture(texture); - this.setNormalBlending(); - this.setShader(this.simpleShader); - gl.colorMask(true, false, false, true); - - var data = []; - - for (var i=0; i<11; i++) - { - var step = 45; - var s = i*step; - data.splice(0,0, 0, s, 10*step, s); - data.splice(0,0, s, 0, s, 10*step); - if (i!=0 && i!=10) - { - for (var j=0; j<51; j++) - { - t = j*step/5; - if (i!=5) - { - data.splice(0,0, t, s-2, t, s+1); - data.splice(0,0, s-2, t, s+1, t); - } - else - { - data.splice(0,0, t, s-5, t, s+4); - data.splice(0,0, s-5, t, s+4, t); - } - } - } - } - - for (var j=0; j<51; j++) - { - var t = j*step/5; - if (t%5 == 0) continue; - data.splice(0,0, t-2, 2.5*step, t+2, 2.5*step); - data.splice(0,0, t-2, 7.5*step, t+2, 7.5*step); - } - - - var vertices = new Float32Array(data); - for (var i=0; i { - Render.canvas.toBlob(blob => { - var reader = new FileReader(); - reader.readAsDataURL(blob); - reader.onloadend = function() { - var dataUrl = reader.result; - var base64 = dataUrl.split(',')[1]; - sendVideoDataCallback(base64); - } - - controls.brightness = settings.brightness; - controls.intensity = settings.intensity; - controls.persistence = settings.persistence; - controls.saturation = settings.saturation; - controls.focus = settings.focus; - controls.hue = settings.hue; - controls.disableFilter = !settings.upsampling; - let numChannels = settings.numChannels; - - if (controls.grid !== settings.graticule) { - controls.grid = settings.graticule; - const image = controls.noise ? 'noise.jpg' : 'empty.jpg'; - Render.screenTexture = Render.loadTexture(image); - } - - if (controls.noise !== settings.smudges) { - controls.noise = settings.smudges; - const image = controls.noise ? 'noise.jpg' : 'empty.jpg'; - Render.screenTexture = Render.loadTexture(image); - } - - var dataView = new DataView(e.target.response); - - const stride = 4 * numChannels; - for (var i = 0; i < xSamples.length; i++) { - xSamples[i] = dataView.getFloat32(i * stride, true); - ySamples[i] = dataView.getFloat32(i * stride + 4, true); - if (numChannels === 3) { - zSamples[i] = dataView.getFloat32(i * stride + 8, true); - } else { - zSamples[i] = 1; - } - } - - if (controls.sweepOn) { - var gain = Math.pow(2.0, controls.mainGain); - var sweepMinTime = controls.sweepMsDiv * 10 / 1000; - var triggerValue = controls.sweepTriggerValue; - for (var i = 0; i < xSamples.length; i++) { - xSamples[i] = sweepPosition / gain; - sweepPosition += 2 * AudioSystem.timePerSample / sweepMinTime; - if (sweepPosition > 1.1 && belowTrigger && ySamples[i] >= triggerValue) - sweepPosition = -1.3; - belowTrigger = ySamples[i] < triggerValue; - } - } - - if (!controls.freezeImage) { - if (!controls.disableFilter) { - Filter.generateSmoothedSamples(AudioSystem.oldXSamples, xSamples, AudioSystem.smoothedXSamples); - Filter.generateSmoothedSamples(AudioSystem.oldYSamples, ySamples, AudioSystem.smoothedYSamples); - if (numChannels === 3) { - Filter.generateSmoothedSamples(AudioSystem.oldZSamples, zSamples, AudioSystem.smoothedZSamples); - } else { - AudioSystem.smoothedZSamples.fill(1); - } - - if (!controls.swapXY) Render.drawLineTexture(AudioSystem.smoothedXSamples, AudioSystem.smoothedYSamples, AudioSystem.smoothedZSamples); - else Render.drawLineTexture(AudioSystem.smoothedYSamples, AudioSystem.smoothedXSamples, AudioSystem.smoothedZSamples); - } - else { - if (!controls.swapXY) Render.drawLineTexture(xSamples, ySamples, zSamples); - else Render.drawLineTexture(ySamples, xSamples, zSamples); - } - } - - for (var i = 0; i < xSamples.length; i++) { - AudioSystem.oldXSamples[i] = xSamples[i]; - AudioSystem.oldYSamples[i] = ySamples[i]; - AudioSystem.oldZSamples[i] = zSamples[i]; - } - - requestAnimationFrame(drawCRTFrame); - }); - }); - } - req.send(); -} - -function drawCRTFrame(timeStamp) { - Render.drawCRT(); -} - -var xSamples = new Float32Array(externalBufferSize); -var ySamples = new Float32Array(externalBufferSize); -var zSamples = new Float32Array(externalBufferSize); - -Juce.getNativeFunction("bufferSize")().then(bufferSize => { - externalBufferSize = bufferSize; - Juce.getNativeFunction("sampleRate")().then(sampleRate => { - externalSampleRate = sampleRate; - xSamples = new Float32Array(externalBufferSize); - ySamples = new Float32Array(externalBufferSize); - zSamples = new Float32Array(externalBufferSize); - Render.init(); - Filter.init(externalBufferSize, 8, 6); - AudioSystem.init(externalBufferSize); - Render.setupArrays(Filter.nSmoothedSamples); - AudioSystem.startSound(); - requestAnimationFrame(drawCRTFrame); - }); -}); - - diff --git a/osci-render.jucer b/osci-render.jucer index 1c7dc9ae..39da163a 100644 --- a/osci-render.jucer +++ b/osci-render.jucer @@ -26,17 +26,8 @@ - - - - - - - diff --git a/sosci.jucer b/sosci.jucer index 641c1fdc..3d6537ce 100644 --- a/sosci.jucer +++ b/sosci.jucer @@ -16,17 +16,8 @@ - - - - - - -