3D Audio Analyzer 0.2

Size
8,929 Kb
Views
24,288

How do I make an 3d audio analyzer 0.2?

What is a 3d audio analyzer 0.2? How do you make a 3d audio analyzer 0.2? This script and codes were developed by Josep Antoni Bover Comas on 27 August 2022, Saturday.

3D Audio Analyzer 0.2 Previews

3D Audio Analyzer 0.2 - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>3D Audio Analyzer 0.2</title>
</head>
<body> <!-- THREE.JS 84 -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/three.js/84/three.min.js'></script>
<!-- Simplified object for 2D and THREE.js canvas (designed for my web page banners and for doing tests with them) -->
<!-- Can work in 2 ways, normal / test mode, and banner mode (for my web page headers) -->
<script src='https://devildrey33.es/Ejemplos/Utils/ObjetoCanvas.js'></script>
<link rel='stylesheet' href='https://devildrey33.es/Ejemplos/Utils/ObjetoCanvas.css'></link>
<!-- Create time animations like Tween.js with less feautres but with my own style -->
<script src='https://devildrey33.es/Ejemplos/Utils/ObjetoAnimacion.js'></script>
<!-- Create test windows like DAT.GUI.js with less feautres but with my own style -->
<script src='https://devildrey33.es/Ejemplos/Utils/ObjetoTest.js'></script>
<link rel='stylesheet' href='https://devildrey33.es/Ejemplos/Utils/ObjetoTest.css'></link> <script src="js/index.js"></script>
</body>
</html>

3D Audio Analyzer 0.2 - Script Codes JS Codes

/* Test para el API de Audio creado por Josep Antoni Bover Comas el 29-10-2016 Vista por defecto en el Laboratorio de pruebas	devildrey33_Lab->Opciones->Vista = Filas; Ultima modificación el 05/11/2016
*/
var EspectroAudible = function() { // Llamo al constructor del ObjetoBanner if (ObjetoCanvas.call(this, { Tipo : 'THREE', Ancho : 'Auto', Alto : 'Auto', Entorno : 'Normal', Idioma : 'en', MostrarFPS : true, ElementoRaiz : document.body, Pausar : false // Pausa el canvas si la pestaña no tiene el foco del teclado
// ColorFondo : 0xFFFFFF }) === false) { return false; } // Se ha creado el canvas, inicio los valores de la animación ... this.Iniciar(); // Esconde la ventana que informa al usuario de que se está cargando la animación. (REQUERIDO)
// this.Cargando(false);
};
EspectroAudible.prototype = Object.assign( Object.create(ObjetoCanvas.prototype) , { constructor : EspectroAudible, // Función que se llama al redimensionar el documento Redimensionar : function() { }, // Función que se llama al hacer scroll en el documento Scroll : function() { }, // Función que se llama al mover el mouse por el canvas MouseMove : function(Evento) { }, // Función que se llama al presionar un botón del mouse por el canvas MousePresionado : function(Evento) { }, // Función que se llama al soltar un botón del mouse por el canvas MouseSoltado : function(Evento) { if (this.EsMovil() === true) { this.PlayPausa(); } }, // Función que se llama al entrar con el mouse en el canvas MouseEnter : function(Evento) { }, // Función que se llama al salir con el mouse del canvas MouseLeave : function(Evento) { }, // Función que se llama al presionar una tecla TeclaPresionada : function(Evento) { }, // Función que se llama al soltar una tecla TeclaSoltada : function(Evento) { }, // Función que se llama al pausar el banner Pausa : function() { this.Cancion.pause(); }, // Función que se llama al reanudar el banner Reanudar : function() { this.Cancion.play(); }, Cubos : [], Uniforms : [], Animaciones : new ObjetoAnimacion(), Volumen : 1, UltimaCancion : "", // Función que inicia el ejemplo Iniciar : function() {
// THREE.ShaderLib.phong.uniforms // THREE.MeshStandardMaterial this.IniciarAudio(); this.Context.shadowMap.enabled = true; this.Escena = new THREE.Scene(); this.Camara = new THREE.PerspectiveCamera(75, this.Ancho / this.Alto, 0.5, 1000); this.Camara.Rotacion = { Grados : -305 * (Math.PI / 180), Avance : (Math.PI / 180) / 5, Distancia : 40, MirarHacia : new THREE.Vector3(0, 0, 0), Animacion : true }; this.Camara.position.set(0, 20, this.Camara.Rotacion.Distancia); // Función para que la cámara rote alrededor de la escena this.Camara.Rotar = function() { if (this.Rotacion.Animacion === true) { this.Rotacion.Grados += this.Rotacion.Avance; this.position.x = this.Rotacion.Distancia * Math.cos(this.Rotacion.Grados); this.position.z = this.Rotacion.Distancia * Math.sin(this.Rotacion.Grados); this.lookAt(this.Rotacion.MirarHacia); } }; this.Escena.add(this.Camara); this.Camara.lookAt(this.Camara.Rotacion.MirarHacia); // Creo el suelo this.Suelo = new THREE.Mesh( new THREE.PlaneGeometry(300, 300), new THREE.MeshPhongMaterial({ color: 0x665544, specular : 0xeeeeee })); //new THREE.MeshStandardMaterial({ color: 0x665544, roughness: 0.5, metalness: 1.0 })); this.Suelo.rotation.x = -Math.PI / 2; this.Suelo.castShadow = false; this.Suelo.receiveShadow = true; this.Escena.add(this.Suelo); // Fog this.Escena.fog = new THREE.Fog(0x888888, 10.1, 150); this.IniciarPantalla();
// this.FuncionPintarPantalla = this.PintarPantalla_Topos; this.FuncionPintarPantalla = this.PintarPantalla_Circular;
// this.IniciarPantalla_Circular(); this.IniciarLuces(); this.ReIniciar(Math.sqrt(this.Analizador.fftSize / 2)); this.IniciarTest(); }, ReIniciar : function(TamLado) {
// var TamLado = Math.sqrt(TamBuffer);
// console.log (TamLado); this.Analizador.fftSize = (TamLado * TamLado) * 2; this.DatosAnalizador = new Uint8Array(this.Analizador.frequencyBinCount); this.BufferDatosAnalizador = new Uint8Array(this.Analizador.frequencyBinCount); // Elimino los cubos de la escena anterior for (var i = 0; i < this.Cubos.length; i++) { this.Escena.remove(this.Cubos[i]); } this.Cubos = []; this.Uniforms = []; var Tam = 0.8; if (TamLado === 32) { Tam = 1; } if (TamLado === 16) { Tam = 2; } if (TamLado === 8) { Tam = 4; } if (TamLado === 4) { Tam = 8; } if (TamLado === 2) { Tam = 16; } // Creo una parrilla de cubos del tamaño especificado var CuboGeo = new THREE.BoxBufferGeometry(Tam * 0.7, 1, Tam * 0.7); var CuboMat = new THREE.MeshPhongMaterial({ color: 0x553322 , specular : 0xff9288, wireframe : false, transparent : false, opacity: 0.8 }); // var Contador = 0;
// console.log("-" + Tam + "-----------------------------------------------------------------------------------------"); for (var z = 0; z < TamLado; z++) { for (var x = 0; x < TamLado; x++) {
/* this.Uniforms[Contador] = THREE.UniformsUtils.merge([ THREE.UniformsLib['lights'], { EscalaY : { type : "1f", value : 1.0 } } ]); var MaterialShader = new THREE.ShaderMaterial({ uniforms : this.Uniforms[Contador], vertexShader : document.getElementById('VertexShader').innerHTML, fragmentShader : document.getElementById('FragmentShader').innerHTML, transparent : true, lights : true });*/ this.Cubos[Contador] = new THREE.Mesh(CuboGeo, CuboMat); var nx = (x - (TamLado / 2) + 0.5) * Tam;
// var nx = (x * Tam) - ((TamLado / 2) * Tam) + (Tam * 0.5); var nz = (z - (TamLado / 2) + 0.5) * Tam; this.Cubos[Contador].position.set(nx, 0, nz);
// console.log(this.Cubos[Contador].position); this.Cubos[Contador].castShadow = true; this.Cubos[Contador].receiveShadow = false; this.Escena.add(this.Cubos[Contador++]); } } }, IniciarAudio : function() { var Compatibilidad = AudioContext = window.AudioContext || window.webkitAudioContext; this.AudioContext = new Compatibilidad(); this.Analizador = this.AudioContext.createAnalyser(); if (this.EsMovil() === true) { this.Analizador.fftSize = 128; } // Para movil la verión de 64 columnas else { this.Analizador.fftSize = 2048; } // Para PC la versión de 1024 columnas
/* this.Analizador.minDecibels = -90; this.Analizador.maxDecibels = -10; */ this.Analizador.smoothingTimeConstant = 0.85; // ?¿?¿?
// console.log(this.Analizador.frequencyBinCount);
// this.DatosAnalizador = new Uint8Array(this.Analizador.frequencyBinCount); this.Canciones = [ "OneChance.mp3", "FromTheOutsideLookingIn.mp3", "QuantumOcean.mp3", "BattleTrance.mp3", "GuitarSolo.mp3", "BatleHymn.mp3", "Painkiller.mp3", "WelcomeBack.mp3", "SweepTone_16-256hz.ogg", "SweepTone_256-2000hz.ogg", "SweepTone_20-20000hz.ogg", "SweepTone_2000-16000hz.ogg", ]; this.CargarCancion(this.Canciones[0]);
// this.Cancion.src = "WelcomeBack.mp3";
// this.Cancion.src = "SweepTone_16-256hz.ogg";
// this.Cancion.src = "SweepTone_256-2000hz.ogg";
// this.Cancion.src = "SweepTone_20-20000hz.ogg";
// this.Cancion.src = "SweepTone_2000-16000hz.ogg"; // Enlazo el evento drop del body para poder arrastrar y soltar canciones. this.Canvas.addEventListener("dragenter", function(e) { return false; }); this.Canvas.addEventListener("dragover", function(e) { return e.preventDefault(); }); this.Canvas.addEventListener("drop", function(e) { this.CargarCancionDrop(e.dataTransfer.files); e.stopPropagation(); e.preventDefault(); }.bind(this)); }, CargarCancionDrop : function(Archivos) { this.Cargando(true); if (this.Cancion) { this.Cancion.pause(); } var Archivo = Archivos[0]; if (Archivo.type.match(/audio.*/)) { var Lector = new FileReader(); Lector.onload = function(Archivo) { this.Cancion = new Audio(); this.Cancion.controls = false; this.Cancion.src = Archivo.target.result;
// this.Cancion.setAttribute("autoplay", true); this.Cancion.addEventListener('canplay', function() { this.Cargando(false); this.AudioSource = this.Audio.createMediaElementSource(this.Cancion); this.AudioSource.connect(this.Analizador); this.Analizador.connect(this.Audio.destination); this.Cancion.play(); }.bind(this)); }.bind(this); Lector.readAsDataURL(Archivo); } /* var Lector = new FileReader(); Lector.onload = function(Archivo) { return function(e) { this.Cancion = new Audio(); this.Cancion.controls = false; this.Cancion.src = e.target.result; this.Cancion.addEventListener('canplay', function() { this.Cargando(false); this.AudioSource = this.Audio.createMediaElementSource(this.Cancion); this.AudioSource.connect(this.Analizador); this.Analizador.connect(this.Audio.destination); this.Cancion.play(); }.bind(this)); }.bind(this); }.bind(this, [Archivo])(); Lector.readAsArrayBuffer(Archivo);*/
// this.Cancion.src = "/Ejemplos/BannerTest/" + Nombre; }, CargarCancion : function(Nombre) { if (Nombre === this.UltimaCancion) { this.Cancion.play(); return; } this.UltimaCancion = Nombre; this.Cargando(true); if (this.Cancion) { this.Cancion.pause(); } this.Cancion = new Audio(); this.Cancion.controls = true; this.Cancion.crossOrigin = "anonymous";
// this.Cancion.setAttribute("autoplay", true); this.Cancion.src = "http://devildrey33.es/Ejemplos/BannerTest/Canciones/" + Nombre; this.Cancion.addEventListener('canplay', function() { this.Cargando(false); this.AudioSource = this.AudioContext.createMediaElementSource(this.Cancion); this.AudioSource.connect(this.Analizador); this.Analizador.connect(this.AudioContext.destination); this.Cancion.volume = this.Volumen; this.Cancion.play(); }.bind(this)); }, IniciarLuces : function() { this.SpotLight = new THREE.SpotLight( 0xffffff,0.7); this.SpotLight.position.set(40,20,100); // this.SpotLight.castShadow = true; this.SpotLight.target.position.set(0, 15, -50); // = this.Pantalla; this.Escena.add(this.SpotLight); this.Splhelper = new THREE.CameraHelper(this.SpotLight.shadow.camera); this.Splhelper.visible = false; this.Escena.add(this.Splhelper); this.SpotLight2 = new THREE.SpotLight( 0xffffff ,0.7); this.SpotLight2.position.set(-40,20,-100);
// this.SpotLight2.castShadow = true; this.SpotLight2.target.position.set(0, 15, 50); // = this.Pantalla2; this.Escena.add(this.SpotLight2); this.Splhelper2 = new THREE.CameraHelper(this.SpotLight2.shadow.camera); this.Splhelper2.visible = false; this.Escena.add(this.Splhelper2); // DirectionalLight this.DirLight = new THREE.DirectionalLight( 0xffffff, 0 ); this.DirLight.color.setHSL( 0.1, 1, 0.95 ); this.DirLight.position.set( 45, 35, 50 ).normalize(); this.DirLight.position.multiplyScalar( 50 ); this.Escena.add( this.DirLight ); this.DirLight.castShadow = true; this.DirLight.shadow.mapSize.width = 2048; this.DirLight.shadow.mapSize.height = 2048; var d = 80; this.DirLight.shadow.camera.left = -d; this.DirLight.shadow.camera.right = d; this.DirLight.shadow.camera.top = d; this.DirLight.shadow.camera.bottom = -d; this.DirLight.shadow.camera.far = 3500;
// this.DirLight.target = this.Pantalla; this.Dlhelper = new THREE.CameraHelper(this.DirLight.shadow.camera); this.Escena.add(this.Dlhelper); this.Dlhelper.visible = false; /* this.DirLight2 = new THREE.DirectionalLight( 0xffffff, 0 ); this.DirLight2.color.setHSL( 0.1, 1, 0.95 ); this.DirLight2.position.set( -66, 100, -115 ).normalize(); this.DirLight2.position.multiplyScalar( 50 ); this.Escena.add( this.DirLight2 ); this.DirLight2.castShadow = true; this.DirLight2.shadow.mapSize.width = 2048; this.DirLight2.shadow.mapSize.height = 2048; var d = 80; this.DirLight2.shadow.camera.left = -d; this.DirLight2.shadow.camera.right = d; this.DirLight2.shadow.camera.top = d; this.DirLight2.shadow.camera.bottom = -d; this.DirLight2.shadow.camera.far = 3500;
// this.DirLight2.target = this.Pantalla; this.Dlhelper2 = new THREE.CameraHelper(this.DirLight2.shadow.camera); this.Escena.add(this.Dlhelper2); this.Dlhelper2.visible = false; */ // SpotLight
/*	this.SpotLight	= new THREE.SpotLight( 0xCCFFFF, 0 );	this.SpotLight.position.set( 25, 100, 750 );	this.SpotLight.shadow.camera.near	= 0.01;	this.SpotLight.shadow.camera.far	= 1000;	this.SpotLight.shadow.camera.visible	= true;	this.SpotLight.castShadow	= true; this.SpotLight.target = this.Pantalla; this.Escena.add( this.SpotLight ); this.Splhelper = new THREE.CameraHelper(this.SpotLight.shadow.camera); this.Splhelper.visible = false; this.Escena.add(this.Splhelper);*/ // HemisphereLight this.HemiLight = new THREE.HemisphereLight( 0xeeeeee, 0xffffff, 0.2 ); this.HemiLight.color.setHSL( 0.6, 0.6, 0.6 ); this.HemiLight.groundColor.setHSL( 0.095, 1, 0.75 ); this.HemiLight.position.set( 0, 0, 0 ); this.Escena.add( this.HemiLight ); this.AnimacionEncenderLuz(); this.AniEncenderLuz.Iniciar(); }, AnimacionEncenderLuz : function() { if (typeof this.AniEncenderLuz !== 'undefined') this.AniEncenderLuz.Terminar(); this.AniEncenderLuz = this.Animaciones.CrearAnimacion([ { Paso : { Intensidad : 0 }}, { Paso : { Intensidad : 0.9 }, Tiempo : 60, FuncionTiempo : FuncionesTiempo.SinInOut, Retraso : 200 }, { Paso : { Intensidad : 0 }, Tiempo : 60, FuncionTiempo : FuncionesTiempo.SinInOut }, { Paso : { Intensidad : 0.5 }, Tiempo : 60, FuncionTiempo : FuncionesTiempo.SinInOut }, { Paso : { Intensidad : 0.4 }, Tiempo : 60, FuncionTiempo : FuncionesTiempo.SinInOut }, { Paso : { Intensidad : 0.6 }, Tiempo : 1850, FuncionTiempo : FuncionesTiempo.SinInOut }, { Paso : { Intensidad : 1 }, Tiempo : 2500, FuncionTiempo : FuncionesTiempo.SinInOut } ], { FuncionActualizar : function(Valores) { this.SpotLight.intensity = Valores.Intensidad * 1.0; this.SpotLight2.intensity = Valores.Intensidad * 1.0; this.DirLight.intensity = Valores.Intensidad * 0.9;
// this.DirLight2.intensity = Valores.Intensidad * 0.5; this.HemiLight.intensity = Valores.Intensidad * 0.4; }.bind(this) }); }, ActualizarCubos : function() { this.Analizador.getByteFrequencyData(this.DatosAnalizador); for (var i = 0; i < this.Cubos.length; i++) {
// this.Uniforms[i].EscalaY.value = 1 + (this.DatosAnalizador[i] / 20); this.Cubos[i].scale.y = 1 + (this.DatosAnalizador[i] / 20); this.Cubos[i].position.y = this.Cubos[i].scale.y / 2; }
/* this.SpotLight.intensity = this.DatosAnalizador[4] / 255; this.SpotLight2.intensity = this.DatosAnalizador[5] / 255;*/ }, // Inicia las pantallas y el backbuffer que se utilizará para pintar las visualizaciones (onda y circular) IniciarPantalla : function() { this.BufferPantalla = new BufferCanvas(1024,512); this.BufferPantalla.Context.fillStyle = '#752222'; this.BufferPantalla.Context.strokeStyle = '#ffffff';
// this.BufferPantalla.Context.lineWidth = 1; this.TexturaPantalla = new THREE.Texture(this.BufferPantalla.Canvas); this.Pantalla = new THREE.Mesh( new THREE.PlaneGeometry(48, 24), new THREE.MeshStandardMaterial( { map: this.TexturaPantalla, roughness: 0.5, metalness: 1.0, transparent : true, opacity:0.5 } )); this.Pantalla.position.set(0, 15, -50);
// this.Pantalla.castShadow = true; this.Escena.add(this.Pantalla); this.Pantalla2 = new THREE.Mesh( new THREE.PlaneGeometry(48, 24), new THREE.MeshStandardMaterial( { map: this.TexturaPantalla, roughness: 0.5, metalness: 1.0, transparent : true, opacity:0.5 } )); this.Pantalla2.position.set(0, 15, 50);
// this.Pantalla2.castShadow = true;
// this.Pantalla2.material.side = THREE.DoubleSide; this.Pantalla2.rotation.y += Math.PI; this.Escena.add(this.Pantalla2);
/* this.Topos = []; for (var i = 0; i < 64; i++) { this.Topos.push(new this.PintarPantalla_Topo()); }*/ }, // Función que pinta en la pantalla la onda PintarPantalla_OndaSin : function() {
// console.log(Math.abs(Math.floor((Math.sin(this.Tick / 1000) * 360)))); this.BufferPantalla.Context.fillStyle = 'hsla(' + Math.abs(Math.floor((Math.sin(this.Tick / 20000) * 360))) + ', 100%, 20%, 0.33)';
// this.BufferPantalla.Context.strokeStyle = 'hsl(' + Math.abs(Math.floor((Math.sin((this.Tick + 1000) / 1000) * 360))) + ', 100%, 50%)';
// this.BufferPantalla.Context.strokeStyle = '#ffffff'; this.Analizador.getByteTimeDomainData(this.BufferDatosAnalizador); this.BufferPantalla.Context.fillRect(0, 0, this.BufferPantalla.Ancho, this.BufferPantalla.Alto); var Avance = 1024 / (this.Analizador.fftSize / 2);
// console.log(Avance); this.BufferPantalla.Context.beginPath(); this.BufferPantalla.Context.moveTo(0, this.BufferPantalla.Alto / 2); var x = 0, y = 0; for (var i = 0; i < this.Analizador.fftSize / 2; i++) {
// y = (this.BufferDatosAnalizador[i] / (this.BufferPantalla.Alto / 2)) * this.BufferPantalla.Alto / 2; y = (this.BufferPantalla.Alto / 4) + this.BufferDatosAnalizador[i];
// y = ((this.DatosAnalizador[i] / (this.Alto / 2)) * this.Alto / 2) - 256; this.BufferPantalla.Context.lineTo(x, y); x += Avance; } // Parche para bajas precisiones que no terminan la onda al final del canvas this.BufferPantalla.Context.lineTo(this.Ancho, y); // Pinto la onda this.BufferPantalla.Context.stroke(); // Actualizo la textura this.TexturaPantalla.needsUpdate = true; }, PintarPantalla_Circular : function() { this.BufferPantalla.Context.fillStyle = 'hsla(' + Math.abs(Math.floor((Math.sin(this.Tick / 20000) * 360))) + ', 100%, 20%, 0.13)';
// this.BufferPantalla.Context.fillStyle = 'hsl(' + Math.abs(Math.floor((Math.sin(this.Tick / 20000) * 360))) + ', 100%, 20%)'; this.BufferPantalla.Context.fillRect(0, 0, this.BufferPantalla.Ancho, this.BufferPantalla.Alto); this.BufferPantalla.Context.fillStyle = 'rgb(255, 255, 255)'; var TamBuffer = this.Analizador.fftSize; var RadAvance = (Math.PI * 2) / TamBuffer; var Rad = -Math.PI / 2, x = 0, y = 0; this.BufferPantalla.Context.beginPath(); var ix = (this.BufferPantalla.Ancho / 2) + (155 + (this.DatosAnalizador[0] / 1.5)) * Math.cos(Rad); var iy = ((this.BufferPantalla.Alto / 2) + 80) + (155 + (this.DatosAnalizador[0] / 1.5)) * Math.sin(Rad); this.BufferPantalla.Context.moveTo(ix, iy); for (var i = 0; i < TamBuffer / 2; i++) { x = (this.BufferPantalla.Ancho / 2) + (155 + (this.DatosAnalizador[i] / 1.5)) * Math.cos(Rad); y = ((this.BufferPantalla.Alto / 2) + 80) + (155 + (this.DatosAnalizador[i] / 1.5)) * Math.sin(Rad); this.BufferPantalla.Context.lineTo(x, y); Rad += RadAvance; } for (var i = TamBuffer / 2; i > 0; i--) { x = (this.BufferPantalla.Ancho / 2) + (155 + (this.DatosAnalizador[i] / 1.5)) * Math.cos(Rad); y = ((this.BufferPantalla.Alto / 2) + 80) + (155 + (this.DatosAnalizador[i] / 1.5)) * Math.sin(Rad); this.BufferPantalla.Context.lineTo(x, y); Rad += RadAvance; } this.BufferPantalla.Context.lineTo(ix, iy);
// this.BufferPantalla.Context.stroke();
// this.BufferPantalla.Context.scale(-1, 1); this.BufferPantalla.Context.stroke(); // Actualizo la textura this.TexturaPantalla.needsUpdate = true; }, // Ha quedat un bodrio PintarPantalla_Topos : function() { this.BufferPantalla.Context.fillStyle = 'rgb(10, 10, 10)';
// this.BufferPantalla.Context.fillStyle = 'hsl(' + Math.abs(Math.floor((Math.sin(this.Tick / 20000) * 360))) + ', 100%, 20%)'; this.BufferPantalla.Context.fillRect(0, 0, this.BufferPantalla.Ancho, this.BufferPantalla.Alto);
// var h = Math.abs(Math.floor((Math.sin(this.Tick / 20000) * 360))); for (var i = this.Topos.length - 1; i > 0; i--) { this.Topos[i].Avance();
// console.log(this.Topos[i]); this.BufferPantalla.Context.fillStyle = 'hsla(' + this.Topos[i].h + ', 100%, 20%, ' + this.Topos[i].Alpha + ')'; this.BufferPantalla.Context.beginPath(); this.BufferPantalla.Context.arc(this.Topos[i].x, this.Topos[i].y, this.Topos[i].Radio + (this.DatosAnalizador[i] / 2), 0, 2 * Math.PI); this.BufferPantalla.Context.fill(); } // Actualizo la textura this.TexturaPantalla.needsUpdate = true; }, PintarPantalla_Topo : function() { this.Reiniciar = function() { this.Radio = Rand(5, 2); this.x = Rand((1024) - this.Radio, this.Radio); this.y = Rand(512 - this.Radio, this.Radio); this.Alpha = 0.7; this.AvanceAlpha = Rand(0.02, 0.005); this.Direccion = Rand(0, Math.PI * 2); // de 0 a 180 grados en (radians)
// this.BucleInicial = true; this.Velocidad = Rand(2, 0.75); this.h = Rand(360, 0); }; this.Avance = function() { this.x = this.x + (this.Velocidad * Math.cos(this.Direccion)); this.y = this.y - (this.Velocidad * Math.sin(this.Direccion)); if (this.x < -this.Radio || this.y < -this.Radio || this.x > 1024 + this.Radio || this.y > 512 + this.Radio) { this.Direccion += Math.PI; }
/* this.Alpha += this.AvanceAlpha; if (this.Alpha >= 1) { this.AvanceAlpha = -this.AvanceAlpha; } if (this.Alpha <= 0) { this.Reiniciar(); }*/ }; this.Reiniciar(); }, // Función que pinta cada frame de la animación Pintar : function() { this.Animaciones.Actualizar(); this.Camara.Rotar(); this.ActualizarCubos(); this.FuncionPintarPantalla();
// this.PintarPantalla_Circular();
// this.PintarPantalla_OndaSin();
// this.PintarPantalla_Circular(); this.Test.ActualizarValores(); this.Context.render(this.Escena, this.Camara); }, IniciarTest : function() { this.Test = new ObjetoTest({ "css" : { bottom : "10px", left : "10px" } }); if (this.EsMovil() === true) { return; } // Audio this.lAudio = this.Test.AgregarLista("Audio"); // Analizador this.lAnalizador = this.lAudio.AgregarLista("Analizador"); this.lAnalizador.Agregar({ Padre : this.Analizador, Variable : "fftSize", Min : 32, Max : 2048, Modificable : false }); this.lAnalizador.Agregar({ Padre : this.Analizador, Variable : "minDecibels", Min : -100, Max : -30.1 }); this.lAnalizador.Agregar({ Padre : this.Analizador, Variable : "maxDecibels", Min : -30, Max : 100 }); this.Visualizacion = { "Circular" : "1", "Onda" : "0" }; this.lAnalizador.Agregar( { Padre : this, Variable : "Visualizacion", Nombre : "Visualización", PorDefecto : this.PintarPantalla_OndaSin, Actualizar : function(NuevoValor) { if (NuevoValor === "0") { this.FuncionPintarPantalla = this.PintarPantalla_OndaSin; } else { this.FuncionPintarPantalla = this.PintarPantalla_Circular; } }.bind(this) }); // Precisión this.TamBuffer = { "32x32 (1024)" : 32, "16x16 (256)" : 16, "8x8 (64)" : 8, "4x4 (16)" : 4 }; this.lAnalizador.Agregar( { Padre : this, Variable : "TamBuffer", Nombre : "Precisión", PorDefecto : Math.sqrt(this.Analizador.fftSize / 2), Actualizar : function(NuevoValor) { this.ReIniciar(parseInt(NuevoValor)); }.bind(this) }); // Canciones this.lAudio.Agregar( { Padre : this, Variable : "Canciones", Actualizar : function(NuevoValor) { this.CargarCancion(NuevoValor); }.bind(this) }); // Play / pausa this.PlayPausa = function() { if (this.Cancion.duration > 0 && !this.Cancion.paused) { this.Cancion.pause(); } else { this.Cancion.play(); } }; this.lAudio.Agregar( { Padre : this, Variable : "PlayPausa", Nombre : 'Play / Pausa' }); this.lAudio.Agregar( { Padre : this.Cancion, Variable : "currentTime", Modificable : false, Min : 0, Max : this.Cancion.duration }); // Volumen
// this.lAudio.Agregar({ Padre : this, Variable : "Volumen", Min : 0, Max : 1, Actualizar : function(NuevoVolumen) { this.Cancion.volume = NuevoVolumen; }.bind(this) }); this.lAudio.Agregar({ Padre : this, Variable : "Volumen", Min : 0, Max : 1, Actualizar : function(NuevoVolumen) { this.Cancion.volume = NuevoVolumen; }.bind(this) }); // Objetos var tObjetos = this.Test.AgregarLista("Objetos"); // Cámara this.lCamara = tObjetos.AgregarLista("Cámara"); this.lCamara.Agregar({ Padre : this.Camara.Rotacion, Variable : "Animacion", Nombre : "Animación", Actualizar : function(NuevoValor) { this.Camara.Rotacion.Animacion = NuevoValor; this.lCamaraPos.Variables[0].Modificable(!NuevoValor); this.lCamaraPos.Variables[2].Modificable(!NuevoValor); this.lCamaraRot.Variables[0].Modificable(!NuevoValor); this.lCamaraRot.Variables[1].Modificable(!NuevoValor); this.lCamaraRot.Variables[2].Modificable(!NuevoValor);
/* for (var i = 0; i < this.lCamara.Variables.length; i++) { if (i !== 1 && i !== 6) { this.lCamara.Variables[i].Modificable(!NuevoValor); } }*/ }.bind(this) }); this.lCamaraPos = this.lCamara.AgregarLista("Posición"); this.lCamaraPos.Agregar({ Padre : this.Camara.position, Variable : "x", Min : -200, Max : 200, Modificable : false }); this.lCamaraPos.Agregar({ Padre : this.Camara.position, Variable : "y", Min : -200, Max : 200, }); this.lCamaraPos.Agregar({ Padre : this.Camara.position, Variable : "z", Min : -200, Max : 200, Modificable : false }); this.lCamaraRot = this.lCamara.AgregarLista("Rotación"); this.lCamaraRot.Agregar({ Padre : this.Camara.rotation, Variable : "x", Min : -Math.PI, Max : Math.PI, Nombre : "rotation.x", Modificable : false }); this.lCamaraRot.Agregar({ Padre : this.Camara.rotation, Variable : "y", Min : -Math.PI, Max : Math.PI, Nombre : "rotation.y", Modificable : false }); this.lCamaraRot.Agregar({ Padre : this.Camara.rotation, Variable : "z", Min : -Math.PI, Max : Math.PI, Nombre : "rotation.z", Modificable : false }); // Columnas var tCubos = tObjetos.AgregarLista("Columnas"); this.Columnas_WireFrame = this.Cubos[0].material.wireframe; tCubos.Agregar({ Padre : this, Variable : "Columnas_WireFrame", Nombre : "wireframe", Actualizar : function(NuevoValor) { this.Cubos[0].material.wireframe = NuevoValor; }.bind(this) }); this.Columnas_CastShadow = this.Cubos[0].castShadow; tCubos.Agregar({ Padre : this, Variable : "Columnas_CastShadow", Nombre : "castShadow", Actualizar : function(NuevoValor) { for (var i = 0; i < this.Cubos.length; i++) { this.Cubos[i].castShadow = NuevoValor; } }.bind(this) }); this.Columnas_ReceiveShadow = this.Cubos[0].receiveShadow; tCubos.Agregar({ Padre : this, Variable : "Columnas_ReceiveShadow", Nombre : "receiveShadow", Actualizar : function(NuevoValor) { for (var i = 0; i < this.Cubos.length; i++) { this.Cubos[i].receiveShadow = NuevoValor; } }.bind(this) });
/* var tPantalla = tObjetos.AgregarLista("Pantalla"); tPantalla.Agregar({ Padre : this.Pantalla.position, Variable : "x", Min : -100, Max : 100, Nombre : "position.x" }); tPantalla.Agregar({ Padre : this.Pantalla.position, Variable : "y", Min : -100, Max : 100, Nombre : "position.x" }); tPantalla.Agregar({ Padre : this.Pantalla.position, Variable : "z", Min : -100, Max : 100, Nombre : "position.x" }); tPantalla.Agregar({ Padre : this.Pantalla.rotation, Variable : "x", Min : -Math.PI, Max : Math.PI, Nombre : "rotation.x" }); tPantalla.Agregar({ Padre : this.Pantalla.rotation, Variable : "y", Min : -Math.PI, Max : Math.PI, Nombre : "rotation.y" }); tPantalla.Agregar({ Padre : this.Pantalla.rotation, Variable : "z", Min : -Math.PI, Max : Math.PI, Nombre : "rotation.z" });*/
// tPantalla.Agregar({ Padre : this.Pantalla, Variable : "castShadow", Nombre : "castShadow" }); // Luces var tLuces = tObjetos.AgregarLista("Luces"); // DirectionalLight var tDirLight = tLuces.AgregarLista("DirectionalLight"); tDirLight.Agregar({ Padre : this.DirLight.position, Variable : "x", Min : -100, Max : 100, Nombre : "position.x"}); tDirLight.Agregar({ Padre : this.DirLight.position, Variable : "y", Min : -100, Max : 100, Nombre : "position.y"}); tDirLight.Agregar({ Padre : this.DirLight.position, Variable : "z", Min : -200, Max : 200, Nombre : "position.z"}); tDirLight.Agregar({ Padre : this.DirLight, Variable : "intensity", Min : 0.0, Max : 1.0}); tDirLight.Agregar({ Padre : this.Dlhelper, Variable : "visible", Nombre : "helper" }); // SpotLight var tSpotLight = tLuces.AgregarLista("SpotLight"); tSpotLight.Agregar({ Padre : this.SpotLight.position, Variable : "x", Min : -100, Max : 100 }); tSpotLight.Agregar({ Padre : this.SpotLight.position, Variable : "y", Min : -200, Max : 200 }); tSpotLight.Agregar({ Padre : this.SpotLight.position, Variable : "z", Min : -750, Max : 750 }); tSpotLight.Agregar({ Padre : this.SpotLight, Variable : "intensity", Min : 0.0, Max : 1.0}); tSpotLight.Agregar({ Padre : this.Splhelper, Variable : "visible", Nombre : "helper" }); // HemisphereLight var tHemiLight = tLuces.AgregarLista("HemisphereLight"); tHemiLight.Agregar({ Padre : this.HemiLight.position, Variable : "x", Min : -100, Max : 100}); tHemiLight.Agregar({ Padre : this.HemiLight.position, Variable : "y", Min : 0, Max : 500}); tHemiLight.Agregar({ Padre : this.HemiLight.position, Variable : "z", Min : -200, Max : 200}); tHemiLight.Agregar({ Padre : this.HemiLight, Variable : "intensity", Min : 0.0, Max : 1.0}); tLuces.Agregar({ Padre : this, Variable : "AnimacionEncenderLuz", Nombre : "Ani Encender luz" }); var tSuelo = tObjetos.AgregarLista("Suelo"); tSuelo.Agregar({ Padre : this.Suelo.position, Variable : "x", Min : -200, Max : 200, Nombre : "position.x" }); tSuelo.Agregar({ Padre : this.Suelo.position, Variable : "y", Min : -200, Max : 200, Nombre : "position.x" }); tSuelo.Agregar({ Padre : this.Suelo.position, Variable : "z", Min : -200, Max : 200, Nombre : "position.x" }); tSuelo.Agregar({ Padre : this.Suelo.rotation, Variable : "x", Min : -Math.PI, Max : Math.PI, Nombre : "rotation.x" }); tSuelo.Agregar({ Padre : this.Suelo.rotation, Variable : "y", Min : -Math.PI, Max : Math.PI, Nombre : "rotation.y" }); tSuelo.Agregar({ Padre : this.Suelo.rotation, Variable : "z", Min : -Math.PI, Max : Math.PI, Nombre : "rotation.z" }); tSuelo.Agregar({ Padre : this.Suelo.material, Variable : "wireframe", Actualizar : function(NuevoValor) { this.Suelo.material.wireframe = NuevoValor; }.bind(this) });
// this.Test.Agregar( { Padre : this, Variable : "Pausa" }); }
});
var Canvas = null;
window.addEventListener('load', function() { Canvas = new EspectroAudible; });
3D Audio Analyzer 0.2 - Script Codes
3D Audio Analyzer 0.2 - Script Codes
Home Page Home
Developer Josep Antoni Bover Comas
Username devildrey33
Uploaded August 27, 2022
Rating 3
Size 8,929 Kb
Views 24,288
Do you need developer help for 3D Audio Analyzer 0.2?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Josep Antoni Bover Comas (devildrey33) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!