Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/munshkr/threejs-3d-sound-sandbox
ThreeJS example of 3D sound simulation using PositionalAudio and extra filters
https://github.com/munshkr/threejs-3d-sound-sandbox
3d-sound example threejs webaudio
Last synced: about 21 hours ago
JSON representation
ThreeJS example of 3D sound simulation using PositionalAudio and extra filters
- Host: GitHub
- URL: https://github.com/munshkr/threejs-3d-sound-sandbox
- Owner: munshkr
- License: mit
- Created: 2020-04-12T14:33:52.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-13T00:44:31.000Z (almost 5 years ago)
- Last Synced: 2024-12-19T20:27:26.669Z (about 2 months ago)
- Topics: 3d-sound, example, threejs, webaudio
- Language: JavaScript
- Homepage: https://munshkr.github.io/threejs-3d-sound-sandbox/
- Size: 1.16 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# threejs-3d-sound-sandbox
[See Demo](https://munshkr.github.io/threejs-3d-sound-sandbox/)
Testing filters on a ThreeJS PositionalAudio object (WebAudio Panner wrapper),
to get a richer 3D sound simulation.For now, there is a Low shelf filter implemented with the
[BiquadFilterNode](https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode),
that changes its frequency dynamically based on the camera and mesh distance.
By default, the distance model used is the same as the one set to the
Panner/PositionalAudio object (either "linear", "inverse" or "exponential").## Usage
See [jsm/PositionalAudioFilter.js](jsm/PositionalAudioFilter.js) for the actual
class that implements the filters.To use:
```javascript
const camera = new THREE.PerspectiveCamera(...);
const listener = new THREE.AudioListener();
camera.add(listener);...
const sound = new THREE.PositionalAudio(listener);
const filter = new PositionalAudioFilter(sound);filter.connect();
```Then, when the camera moves, you should call `filter.update()`, to update
frequency based on distance.## Attributions
This example was based on the [ThreeJS WebAudio sandbox
example](https://threejs.org/examples/?q=audio#webaudio_sandbox).## License
See [LICENSE](LICENSE).