// Set brightnesses of flares based on the values from analysis. public override void UpdateVisuals() { // Build a logarithmic spectrum float[] scaledSpectrum = new float[NumberOfFlares]; float b = Mathf.Pow(VisualizerCore.SpectrumSize, 1f / NumberOfFlares); float bPow = 1; for (int i = 0; i < NumberOfFlares; i++) { float prevBPow = bPow; bPow *= b; for (int j = (int)prevBPow; j < bPow - 1; j++) { scaledSpectrum[i] += VisualizerCore.Spectrum(j); } } // Set brightnesses of flares for (int i = 0; i < NumberOfFlares; i++) { // Smooth falling and sharp rising. float thisY = scaledSpectrum[i] * SizeModifier; _scales[i] -= SmoothSpeed * Time.deltaTime; _scales[i] = Mathf.Clamp(_scales[i], thisY, MaxVisualScale); _visuals[i].GetComponent <LensFlare>().brightness = _scales[i]; } }
public override void UpdateVisuals() { float sumSpectrum = VisualizerCore.Level(); // Build a logarithmic spectrum float[] scaledSpectrum = new float[FLAMES]; float b = Mathf.Pow(VisualizerCore.SpectrumSize, 1f / FLAMES); float bPow = 1; for (int i = 0; i < FLAMES; i++) { float prevBPow = bPow; bPow *= b; for (int j = (int)prevBPow; j < bPow - 1; j++) { scaledSpectrum[i] += VisualizerCore.Spectrum(j); } } // Update for (int i = 0; i < FLAMES; i++) { float nextPower = 0.2f + scaledSpectrum[i] * 6 + sumSpectrum * 0.5f; _powers[i] = Mathf.Max(_powers[i] * (1 - 10 * Time.deltaTime), nextPower); _flames[i].SetFloat("Power", _powers[i]); } }
// Set scale of bars based on the values from analysis. public override void UpdateVisuals() { float[] spectrum = VisualizerCore.Spectrum(); int spectrumIndex = 0; int averageSize = (int)(spectrum.Length * KeepPercentage / AmountOfVisuals); for (int visualIndex = 0; visualIndex < AmountOfVisuals; visualIndex++) { float sum = 0; for (int j = 0; j < averageSize; j++) { sum += spectrum[spectrumIndex]; spectrumIndex++; } float audioScale = sum / averageSize * SizeModifier; float fallScale = Mathf.Clamp(_scales[visualIndex] - SmoothSpeed * Time.deltaTime, 0, MaxVisualScale); float finalScale = Mathf.Clamp(audioScale, fallScale, MaxVisualScale); _scales[visualIndex] = finalScale; _visuals[visualIndex].localScale = new Vector3(1 + finalScale, 1, 1); } }
public override void UpdateVisuals() { // Build a logarithmic spectrum float[] scaledSpectrum = new float[NumberOfChunks]; float b = Mathf.Pow(VisualizerCore.SpectrumSize, 1f / NumberOfChunks); float bPow = 1; for (int i = 0; i < NumberOfChunks; i++) { float prevBPow = bPow; bPow *= b; for (int j = (int)prevBPow; j < bPow - 1 && j < VisualizerCore.SpectrumSize; j++) { scaledSpectrum[i] += Mathf.Abs(VisualizerCore.Spectrum(j)); } } // Update texture Graphics.CopyTexture(_blank, _texture); float[] samples = VisualizerCore.Samples(FilterType.Bypass); for (int i = 0; i < SampleBarCount && i < samples.Length; i++) { // Height between 2 and 32 float heightFrac = Mathf.Clamp01(Mathf.Abs(samples[i])) * SampleMultiplier; int height = (int)Mathf.Ceil(Mathf.Lerp(SampleBarMinHeight, SampleBarMaxHeight, heightFrac)); // Draw the rect on the texture buffer _texture.SetPixels( SampleBarDistance - height, (SampleBarWidth + SampleBarSeparation) * i, 2 * height, SampleBarWidth, Enumerable.Repeat(Color.white, 2 * SampleBarWidth * height).ToArray() ); } // Draw the texture buffer to the texture (no mipmaps) _texture.Apply(false); // Rotate and jump for (int i = 0; i < NumberOfChunks; i++) { _disks[i].transform.Rotate(Vector3.forward * RotationAmount(i)); float target = scaledSpectrum[i] * JumpPower; float height = Mathf.Clamp( Mathf.Lerp(-_disks[i].transform.localPosition.z, target, FallRate), target, 20 ); _disks[i].transform.localPosition = Vector3.back * height; } _subParent.transform.localRotation = Quaternion.Euler(_subRot + new Vector3(5 * Mathf.Sin(Time.time), 5 * Mathf.Sin(Time.time * 1.234f), 0)); }
// Set scale of bars based on the values from analysis. public override void UpdateVisuals() { int spectrumIndex = 0; int averageSize = (int)(VisualizerCore.SpectrumSize * keepPercentage / (amountOfVisuals.x * amountOfVisuals.y)); for (int visualIndex = 0; visualIndex < visuals.Length; visualIndex++) { float sum = 0; for (int j = 0; j < averageSize; j++) { sum += VisualizerCore.Spectrum(spectrumIndex); spectrumIndex++; } float scale = sum / averageSize * sizeModifier; scales[visualIndex] -= smoothSpeed * Time.deltaTime; scales[visualIndex] = Mathf.Clamp(scale, minSize, maxVisualScale); colors[visualIndex].material.color = gradient.Evaluate(scale * 1.0f / maxVisualScale); visuals[visualIndex].localScale = Vector3.one * scales[visualIndex]; } }