# Procedural audio

**URL:** <https://forum.babylonjs.com/t/procedural-audio/19858>\
**Category:** Questions\
**Created:** [April 9, 2021, 2:45pm UTC](https://forum.babylonjs.com/t/procedural-audio/19858 "2021-04-09T14:45:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yam](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/yam/32/11467_2.png) [@Yam](https://forum.babylonjs.com/u/Yam)\
**Post date:** [April 9, 2021, 2:45pm UTC](https://forum.babylonjs.com/t/procedural-audio/19858/1 "2021-04-09T14:45:21Z")

</div>

Is there any way to create procedural audio in babylon.js?

---

<div class="post-metadata">

**Author:** ![JCPalmer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jcpalmer/32/42_2.png) [@JCPalmer](https://forum.babylonjs.com/u/JCPalmer)\
**Post date:** [April 9, 2021, 3:11pm UTC](https://forum.babylonjs.com/t/procedural-audio/19858/2 "2021-04-09T15:11:37Z")

</div>

There is WebAudio that is built into the browser. If you can build an audio buffer in code (btw that is amazing tough to do. better to start with samples in .mp4 or .wav), you can make a graph to cause it to come out. There is some direct integration to replay sound files in BJS, but this is a browser question, not a framework / webgl issue.

---

<div class="post-metadata">

**Author:** ![Yam](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/yam/32/11467_2.png) [@Yam](https://forum.babylonjs.com/u/Yam)\
**Post date:** [April 9, 2021, 3:22pm UTC](https://forum.babylonjs.com/t/procedural-audio/19858/3 "2021-04-09T15:22:16Z")

</div>

Ah okay, so WebAudio can be used in anything browser-based including BJS but is not part of BJS itself? Is the purpose of building an audio buffer to avoid processing delays? Uploading sound files is fine but deeper levels of sonic interaction can be achieved using procedural audio, plus it’s theoretically computationally cheaper - sounds like it might be a pain to implement though?

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [April 9, 2021, 3:31pm UTC](https://forum.babylonjs.com/t/procedural-audio/19858/4 "2021-04-09T15:31:16Z")

</div>

It’s not to hard to make simple bleeps and bloops, but anything more advance is tedious.

---

<div class="post-metadata">

**Author:** ![JCPalmer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jcpalmer/32/42_2.png) [@JCPalmer](https://forum.babylonjs.com/u/JCPalmer)\
**Post date:** [April 9, 2021, 6:01pm UTC](https://forum.babylonjs.com/t/procedural-audio/19858/5 "2021-04-09T18:01:56Z")

</div>

[WebAudio](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API) is separate API available in most browsers. It is queue based. It is designed to do the actual processing of the queue off of the UI thread, so it can be very accurate.

Unless you are very familiar with [Fast Fourier Transform(FFT)](https://en.wikipedia.org/wiki/Fast_Fourier_transform), I would stick with something that has been recorded. You might look at

> **[surikov/webaudiofont](https://github.com/surikov/webaudiofont)**
>
> Use full GM set of musical instruments to play MIDI and single sounds or effects. Support for reverberation and equaliser. No plugins, no Flash. Pure HTML5 implementation compatible with desktop an...

While it is primary for music. There are also instrument fonts which are more like sound effects. BJS can also just play any sound file for you, in a number of options. This is implemented in WebAudio though, and not doing anything it cannot.

> **[Audio | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/audio/playingSoundsMusic)**
>
> Dive into everything you could want to know about using the Babylon.js sound engine for simple to advanced audio.

---

<div class="post-metadata">

**Author:** ![Yam](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/yam/32/11467_2.png) [@Yam](https://forum.babylonjs.com/u/Yam)\
**Post date:** [April 22, 2021, 10:25am UTC](https://forum.babylonjs.com/t/procedural-audio/19858/6 "2021-04-22T10:25:04Z")

</div>

Thanks so much for the explanation and links!
