Open satoshinm opened 7 years ago
OpenAL looks to be the most promising (over SDL, since Craft already is using GLFW and there's some overlap).
http://www.glfw.org/faq.html#will-sound-support-be-added-to-glfw
2.4 - Will sound support be added to GLFW?
No. However, if you are looking for an OpenGL-like API for sound, have a look at OpenAL.
Tutorial on OpenAL: http://www.edenwaith.com/products/pige/tutorials/openal.php
The above tutorial uses ALUT, analogous to GLUT (AL = audio library, GL = graphics library, UT = utility toolkit), providing useful utility functions not in the core library such as alutLoadWAVFile()
.
But http://stackoverflow.com/questions/1693499/alutcreatebufferhelloworld-in-openal#1693582 says "ALUT is a very old library, it is very unfindable, you may use OpenAL Soft, it is very simple. You need a WAVE reader, and a couple of calls you can find in ANY OpenAL tutorial"
Found an active openal-soft repository at, builds using cmake: https://github.com/kcat/openal-soft
Spatial audio in VR (https://github.com/satoshinm/NetCraft/pull/63 VR): https://news.ycombinator.com/item?id=14271151 https://developers.google.com/vr/concepts/spatial-audio
For audio file decoding, consider stb_vorbis (Ogg Vorbis audio decoder): https://github.com/nothings/stb/blob/master/stb_vorbis.c
Some good information on HTML5 Audio through emscripten at this blog: http://www.rossis.red/wasm.html#audio Audio May 14, 2017, from https://news.ycombinator.com/item?id=14411328 used in https://www.funkykarts.rocks/demo.html. They are using MIDI synthesized at runtime, to reduce download size.
This includes some useful information: [https://www.youtube.com/watch?v=BR8KjNkYURk&list=PLRIWtICgwaX2VNpAFjAZdlQw2pA1-5kU8](). It is in Java. However, ThinMatrix is the one that got me to understand OpenGL, despite the language barrier.
Play sound effects when things happen: breaking a block, placing a block, walking over a block, etc.
Should be possible to support both web and native through a suitable API. SDL audio APIs via emscripten to Web Audio API (or was Mozilla Audio API?), or OpenAL which "uses Web Audio and has buffer streaming support currently in the master branch.": http://stackoverflow.com/questions/18350537/getting-emscripten-streaming-audio-to-work
And then: music (mp3s streaming?)