tentone / nunuStudio

Web powered cross-platform 3D, WebXR game engine.
https://nunustudio.org
MIT License
2.09k stars 312 forks source link

Music / audio manipulation visualisation #228

Open shantee opened 5 years ago

shantee commented 5 years ago

Hello, I would like to know if there is a method to get some data about an "audio emitter" object in order to make some music visualization or a demoscene reacting to the music.

I am not sure I am very clear (sorry about that) so ,for example : if I want to play an "audio emitter" object i can do something like this :

audio = scene.getObjectByName("music");
audio.play();

Now is there a way to do something like audio.getFrequency() or audio.getVolume(); Thanks a lot for the work you put in nunuStudio , it's really great and fun to play with

tentone commented 5 years ago

Hi

It is possible, since the audio system is based on the WebAudio API (you can check out some examples here https://webaudioapi.com/samples/).

I will try to put up some examples using the audio frequency and volume.

Thanks a lot for the suggestion.

Hope it helps.

Cheers

shantee commented 5 years ago

I finally got something moving with the sound :) So if it can help or inspire someone here is how I did it. It is a actually a mix of different methods I copied here and there and that I adapted. There are certainly better ways. sound-demo.nsp.zip