• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by sumit47 · Jan 31, 2018 at 11:26 AM · audio sourcevisualization

Can we make better audio visualizer than it?

using System.Collections; using System.Collections.Generic; using UnityEngine;

[RequireComponent(typeof(AudioSource))] public class AudioVisualizer : MonoBehaviour { AudioSource _MyAudioSource; public static float[] Samples = new float[512]; public static float[] _FrequencyBand = new float[8];

 void Start()
 {
     _MyAudioSource = GetComponent<AudioSource>();
 }

 void Update()
 {
     GetSpectrumAudioSource();
     MakeFrequencyBand();
 }

 void GetSpectrumAudioSource()
 {
     _MyAudioSource.GetSpectrumData(Samples, 0, FFTWindow.Blackman);
 }

 void MakeFrequencyBand()
 {
     int count = 0;
     for (int i = 0; i < 8; i++)
     {
         float average = 0;
         int SampleCount = (int)Mathf.Pow(2, i) * 2;

         if (i == 7)
         {
             SampleCount += 2;
         }
         for (int j = 0; j < SampleCount; j++)
         {
             average += Samples[count] * (count + 1);
             count++;
         }
         average /= count;
         _FrequencyBand[i] = average * 10;
     }
 }

}

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sumit47 · Jan 31, 2018 at 11:27 AM 0
Share

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class Param : $$anonymous$$onoBehaviour { public int band; public float _StartScale,_Scale$$anonymous$$ultiplier;

 void Start()
 {
     
 }
 void Update()
 {
     transform.localScale = new Vector3(0.1f,(AudioVisualizer._FrequencyBand[band]*_Scale$$anonymous$$ultiplier)+_StartScale,0.01f);
 }

}

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

73 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Lower volume when another audio source plays 1 Answer

Custom inspector curves similar to the 'Audio Source' volume/pan/spread Curves 0 Answers

how can i mute all audio sources in the scene? 2 Answers

Is there a more efficient way to trigger an audio source from an array to play than using a timer? 0 Answers

Want Main Camera to show what fxcamera is rendering 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges