Very good tutorial. I have reviewed it two times to get all of them. Some points: - How do you make that cubes glow? You have emission color with realtime gi. I thought you need to have a baked gi to make this. - I made a music visualizer some years ago. One thing that was cool is adding a small cube on top of the cube bars for showing the top value. The typical bar stands "floating" for some time until goes down. I used colliders and physics to let the bar go down by gravity. And thanks! You are great
add a post processing from the unity store, add the post processing behavior to the camera or create a game object an place it there, then create a post processing profile where you have the assets/scripts, open the profile and turn on the bloom
I fixed _bandBuffer -= _bufferDecrease[g]; for _bandBuffer[g] -= _bufferDecrease[g]; since Unity would complain about it Edit: well, the mistake was fixed 0.05 seconds after I paused the video. At least I'm glad I tried
hey! Wanted to say these are incredibly great and informative videos and very helpful especially with someone with basic knowledge with scripting. I'm a broke college student so I can't contribute too much $, but I definitely will support in anyway until i can! Keep it up!
I've been working on a visualizer in Unity as well. Instead of a buffer, I would adjust how often I got the spectrum data using Invoke. Nice going with splitting the frequencies into bands! It took a long time for me to split up the different sounds as well. How far are you taking this project? Now that the analyzing the data is finished, you can create a whole bunch of effects with it.
Hey there! I am just uploading the next part of the tutorial. I have been taking it quite far. Check out some other videos on my channel. I've made a whole bunch of games that run on audio. The invoke is a good one, I will check that out. I'm sure there is alot of optimization to be done, but I'm quite happy with the results I got. I'd love to see your take on it in script. Cheers!
Hey I know this tutorial is old but I'm stuck. I'm having problems with it working. There are no errors in the console and I've looked over the code like hundred times and I can't find what wrong. I'm not sure what's wrong but it would mean a lot if someone could help me?
hi, can you explain why the jittery effect occurs? is it a because of the difference between unity frame update (~30-90 hz) and audio filter update (~441khz or whatever your audio file is), or is it something else?
Thanks for the tutorial. I have a question: How can I make the buffer work on the ring / 512 samples? Because at the moment the buffer works on the 8 cubes and seems to be interwoven with 'band' code. I've been copy & pasting code from the other scripts and adjusting it but I can't seem to find out what I have to do/change to make the buffer work on those 512 cubes.
In case you haven’t figured this out, this comes down to where the center of your objects are, in the video he is using a cube where the center is placed at the very bottom of the cube, so when it is scaled around it only scales up. In order to do this yourself just go to any 3D modeling site and make a cube, then move it so the bottom of the cube is touching the default point.
my take on the frequency bar update void Update() { var val = useBuffer ? AudioPeer.buffers[band] : AudioPeer.bands[band]; var scale = transform.localScale; scale.y = scaleStart + (val * scaleFact); transform.localScale = scale; }
Is it possible to be sure that no matter what kind of music I put on, sound will always be divided into same bands? (for example 0th is always bass, 6th seems to be high pitched rings and so on)
That is what this script currenly does. It divides any soundfrequencies over 8 bands between 0 and 20000 hertz. But those bands will be in the same ranges, and doesn't matter what audio is playing. If for example a song has a higher pitched bass, their bass could be present in band 1 instead of zero. To fix that, you could write an algorithm to determine what profile the song consists out of, and how it's own frequencies should be dispenced. classical piano music, would be totally different than a male voice track.
I don't know why but the buffer isn't working (the parametric cubes aren't doing anything). If I disable _useBuffer the bars are working the same way as in part 4 (without buffering). I have no clue what the problem is and I've checked everything. The parameters are the same, the scripts are identical, so WHY is it not working for me?
Mickyelloow that is a hard question specifically answer. Though what you can do: Debug.log() the bandbuffer values and see if they actually change. if they are working in the AudioPeer script, you atleast know there is something wrong in the parametric script.
I just checked that and I didn't forget to put BandBuffer() in the void Update. I didn't have the chance to check for the problem since I'm still in school and I'm learning C# (I'm a semi-noob at programming).
The function MakeFrequencyBands in the script AudioPeer is different from in the last tutorial. I have downloaded the source files but the folders appear empty. Stuck!
thanks works great. could you please tell me how to change the instantiate512Cubes position? i would like to change the positions of the 512 cubes, by keeping the circle shape. the InstantiateCubes game object transforms controls dont affect the 512 cube position. I have manage to make a public float for the radius, but cant work out how to make a public float for the position . let me know if you could help thanks
Yes they do affect the position of all the cubes, as the 512 cubes are all childs of its parent. So move the transform of the parent object. The only way I could think of this not working, if you didn't actually parent the instances of cubes.
mm I think i did ..could you please help. ideally i would love to have public floats for x, y, z, position of the cubes.? using UnityEngine; using System.Collections; public class Instantiate512Cubes : MonoBehaviour { public GameObject _sampleCubePrefabs; GameObject[] _sampleCube = new GameObject[512]; public float _maxScale; public float _circleSize; // Use this for initialization void Start () { for (int i = 0; i < 512; i++) { GameObject _instanceSampleCube = (GameObject)Instantiate (_sampleCubePrefabs); _instanceSampleCube.transform.position = this.transform.position; _instanceSampleCube.transform.parent = this.transform; _instanceSampleCube.name = "SampleCube" + i; this.transform.eulerAngles = new Vector3 (0, -0.703125f * i, 0); _instanceSampleCube.transform.position = Vector3.forward * _circleSize; _sampleCube [i] = _instanceSampleCube; } } // Update is called once per frame void Update () { for (int i = 0; i < 512; i++) { if (_sampleCube != null) { _sampleCube [i].transform.localScale = new Vector3 (10, (AudioPeer._samples [i] * _maxScale) + 2, 10); } } } }
I have really no clue what you mean. The script you posted is basically the script I have in the tutorial. All the transforms are public anyways. To move a cube: _sampleCube[numberYouWantToMove].transform.localPosition = ...something
hi i am not an unity expert sorry. thats why i posted the script for you to see. yes thats your script. I dont want to move 1 cube. i want to change the position of all instantiated512 cubes. the game object transforms (with the script) do not work change where the cubes are instantiated. going back to what you said : 'Yes they do affect the position of all the cubes, as the 512 cubes are all childs of its parent. So move the transform of the parent object. The only way I could think of this not working, if you didn't actually parent the instances of cubes.' what you see wrong in the code i posted? where should i add : _sampleCube[numberYouWantToMove].transform.localPosition = ...something ?? thanks for your help
btw nows it works. my professor helped me: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Instantiate512Cubes : MonoBehaviour { public GameObject _sampleCubePrefabs; GameObject[] _sampleCube = new GameObject[512]; public float _maxScale; public float _circleSize; public int numberOfCubes = 512; // Use this for initialization void Start () { for (int i = 0; i < 512; i++) { GameObject _instanceSampleCube = (GameObject)Instantiate (_sampleCubePrefabs); _instanceSampleCube.transform.position = this.transform.position; _instanceSampleCube.transform.SetParent(this.transform); _instanceSampleCube.name = "SampleCube_" + i; this.transform.eulerAngles = new Vector3 (0, -(360f / numberOfCubes) * i, 0); _instanceSampleCube.transform.position = this.transform.position + Vector3.forward * _circleSize; _sampleCube [i] = _instanceSampleCube; } }
You're a genius for working out the logic for this exercise, and a saint for sharing them. Thank you so much!!
Very good tutorial. I have reviewed it two times to get all of them. Some points:
- How do you make that cubes glow? You have emission color with realtime gi. I thought you need to have a baked gi to make this.
- I made a music visualizer some years ago. One thing that was cool is adding a small cube on top of the cube bars for showing the top value. The typical bar stands "floating" for some time until goes down. I used colliders and physics to let the bar go down by gravity.
And thanks! You are great
add a post processing from the unity store, add the post processing behavior to the camera or create a game object an place it there, then create a post processing profile where you have the assets/scripts, open the profile and turn on the bloom
thanks for these tutorials! They were very easy to follow and I have been wanting to add audio visualizers into my games for too long now
This worked beautifully. Thank you so much!
I fixed _bandBuffer -= _bufferDecrease[g]; for _bandBuffer[g] -= _bufferDecrease[g]; since Unity would complain about it
Edit: well, the mistake was fixed 0.05 seconds after I paused the video. At least I'm glad I tried
lol i paused and panicked too
hey man, its the thought that counded
Thank you very much for this tutorial! You helped me so much and now I understand how this works.
Did you just do
if (foo) {}
if (!foo) {}
instead of
if (foo) {}
else {}
my real question is... can we do this with a particle emitter too?
Cool tutorial. Thanks for sharing it with us.
i followed the tutorial but it seems like the buffer does not work. Is this stuff normally working on Unity 2019.4?
Amazing your tutorials! Thx for share your knowledge, I´m learning a lot with you. Keep making then, U r fantastic bro. Good Job.
hey! Wanted to say these are incredibly great and informative videos and very helpful especially with someone with basic knowledge with scripting. I'm a broke college student so I can't contribute too much $, but I definitely will support in anyway until i can! Keep it up!
Great Tutorial! Thank you very much!
I've been working on a visualizer in Unity as well. Instead of a buffer, I would adjust how often I got the spectrum data using Invoke. Nice going with splitting the frequencies into bands! It took a long time for me to split up the different sounds as well. How far are you taking this project? Now that the analyzing the data is finished, you can create a whole bunch of effects with it.
Hey there! I am just uploading the next part of the tutorial. I have been taking it quite far. Check out some other videos on my channel. I've made a whole bunch of games that run on audio. The invoke is a good one, I will check that out. I'm sure there is alot of optimization to be done, but I'm quite happy with the results I got. I'd love to see your take on it in script. Cheers!
github.com/gushrodah/Visualizor
heres my project if you wanna check it out. definitely not as extensive as your code but just wanted to share it :D
Wade Gushikuma did that end up looking smooth?
Hey I know this tutorial is old but I'm stuck. I'm having problems with it working. There are no errors in the console and I've looked over the code like hundred times and I can't find what wrong. I'm not sure what's wrong but it would mean a lot if someone could help me?
You have a great future!!!!
thank you for putting these up. do you know if it is possible to use an external audio program such as pure data as the audio clip to be analysed?
how did you get it to glow
man that intro music rips my ears every time :((((
How did you make the cubes glow?
Assign emission color to the standard shader and use a bloom post processing on the camera.
hi, can you explain why the jittery effect occurs? is it a because of the difference between unity frame update (~30-90 hz) and audio filter update (~441khz or whatever your audio file is), or is it something else?
Thanks for the tutorial. I have a question: How can I make the buffer work on the ring / 512 samples? Because at the moment the buffer works on the 8 cubes and seems to be interwoven with 'band' code. I've been copy & pasting code from the other scripts and adjusting it but I can't seem to find out what I have to do/change to make the buffer work on those 512 cubes.
same
since I did the buffers the cubes are just flat?
How do the cubes you have only extend in one direction. Mine extends both ways. Please help
In case you haven’t figured this out, this comes down to where the center of your objects are, in the video he is using a cube where the center is placed at the very bottom of the cube, so when it is scaled around it only scales up. In order to do this yourself just go to any 3D modeling site and make a cube, then move it so the bottom of the cube is touching the default point.
my take on the frequency bar update
void Update()
{
var val = useBuffer ? AudioPeer.buffers[band] : AudioPeer.bands[band];
var scale = transform.localScale;
scale.y = scaleStart + (val * scaleFact);
transform.localScale = scale;
}
Is it possible to be sure that no matter what kind of music I put on, sound will always be divided into same bands?
(for example 0th is always bass, 6th seems to be high pitched rings and so on)
That is what this script currenly does. It divides any soundfrequencies over 8 bands between 0 and 20000 hertz. But those bands will be in the same ranges, and doesn't matter what audio is playing. If for example a song has a higher pitched bass, their bass could be present in band 1 instead of zero. To fix that, you could write an algorithm to determine what profile the song consists out of, and how it's own frequencies should be dispenced. classical piano music, would be totally different than a male voice track.
I don't know why but the buffer isn't working (the parametric cubes aren't doing anything). If I disable _useBuffer the bars are working the same way as in part 4 (without buffering).
I have no clue what the problem is and I've checked everything. The parameters are the same, the scripts are identical, so WHY is it not working for me?
Mickyelloow that is a hard question specifically answer. Though what you can do: Debug.log() the bandbuffer values and see if they actually change. if they are working in the AudioPeer script, you atleast know there is something wrong in the parametric script.
I just checked that and I didn't forget to put BandBuffer() in the void Update. I didn't have the chance to check for the problem since I'm still in school and I'm learning C# (I'm a semi-noob at programming).
The function MakeFrequencyBands in the script AudioPeer is different from in the last tutorial. I have downloaded the source files but the folders appear empty. Stuck!
No it is not, I just removed the comment lines. And you are right, I haven't yet updated the source files ;) I'll send you the audiopeer class ;)
Works anyway lol, Iv changed a few things. Have them all rotating around an object on all axis. looks good. Cheers for the videos appreciated!
Thank you! I'm so glad I helped you! Good luck with your game designs!
lol I ment to reply with this account xD
thanks works great. could you please tell me how to change the instantiate512Cubes position? i would like to change the positions of the 512 cubes, by keeping the circle shape. the InstantiateCubes game object transforms controls dont affect the 512 cube position. I have manage to make a public float for the radius, but cant work out how to make a public float for the position . let me know if you could help thanks
Yes they do affect the position of all the cubes, as the 512 cubes are all childs of its parent. So move the transform of the parent object. The only way I could think of this not working, if you didn't actually parent the instances of cubes.
mm I think i did ..could you please help. ideally i would love to have public floats for x, y, z, position of the cubes.?
using UnityEngine;
using System.Collections;
public class Instantiate512Cubes : MonoBehaviour {
public GameObject _sampleCubePrefabs;
GameObject[] _sampleCube = new GameObject[512];
public float _maxScale;
public float _circleSize;
// Use this for initialization
void Start () {
for (int i = 0; i < 512; i++) {
GameObject _instanceSampleCube = (GameObject)Instantiate (_sampleCubePrefabs);
_instanceSampleCube.transform.position = this.transform.position;
_instanceSampleCube.transform.parent = this.transform;
_instanceSampleCube.name = "SampleCube" + i;
this.transform.eulerAngles = new Vector3 (0, -0.703125f * i, 0);
_instanceSampleCube.transform.position = Vector3.forward * _circleSize;
_sampleCube [i] = _instanceSampleCube;
}
}
// Update is called once per frame
void Update () {
for (int i = 0; i < 512; i++) {
if (_sampleCube != null) {
_sampleCube [i].transform.localScale = new Vector3 (10, (AudioPeer._samples [i] * _maxScale) + 2, 10);
}
}
}
}
I have really no clue what you mean. The script you posted is basically the script I have in the tutorial. All the transforms are public anyways.
To move a cube:
_sampleCube[numberYouWantToMove].transform.localPosition = ...something
hi i am not an unity expert sorry. thats why i posted the script for you to see. yes thats your script. I dont want to move 1 cube. i want to change the position of all instantiated512 cubes. the game object transforms (with the script) do not work change where the cubes are instantiated. going back to what you said :
'Yes they do affect the position of all the cubes, as the 512 cubes are all childs of its parent. So move the transform of the parent object. The only way I could think of this not working, if you didn't actually parent the instances of cubes.'
what you see wrong in the code i posted? where should i add :
_sampleCube[numberYouWantToMove].transform.localPosition = ...something ??
thanks for your help
btw nows it works. my professor helped me:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Instantiate512Cubes : MonoBehaviour {
public GameObject _sampleCubePrefabs;
GameObject[] _sampleCube = new GameObject[512];
public float _maxScale;
public float _circleSize;
public int numberOfCubes = 512;
// Use this for initialization
void Start () {
for (int i = 0; i < 512; i++) {
GameObject _instanceSampleCube = (GameObject)Instantiate (_sampleCubePrefabs);
_instanceSampleCube.transform.position = this.transform.position;
_instanceSampleCube.transform.SetParent(this.transform);
_instanceSampleCube.name = "SampleCube_" + i;
this.transform.eulerAngles = new Vector3 (0, -(360f / numberOfCubes) * i, 0);
_instanceSampleCube.transform.position = this.transform.position + Vector3.forward * _circleSize;
_sampleCube [i] = _instanceSampleCube;
}
}
This code works in realtime right?