\ No newline at end of file
diff --git a/search-data.json b/search-data.json
index e83ba2d..242726d 100644
--- a/search-data.json
+++ b/search-data.json
@@ -1 +1 @@
-[{"url":"https://lusito.github.io/sounts/","content":"sounts\n\n\n\n\n\nA tiny helper library for working with the web audio API written in TypeScript.\nIt has been written to simplify playing sounds in games.\nIt is not meant as a fully-fledged audio library.\nFeatures:\n\nPlaying sounds with and without position and orientation (positional-audio / spatialization)\nA SoundSource (position + orientation) can play multiple sounds\nYou can play sounds on channels (if the specified channel already plays a sound, it will be stopped)\nSounds can of course be played freely (not on a channel)\nIt does not abstract away the web audio API. It only simplifies its usage. So you can still use the full power of the web audio API.\n\nWhat it doesn't do:\n\nPreloading sounds (that's up to you or a different asset manager)\nManipulating sounds\nFallback if web audio API is not supported\n\nIf you are looking for a more complete solution, you might want to take a look at howler.\nFair Warning\nThe compile target of this library is es2015, so if you want to support older browsers, you'll have to ensure that this module is being transpiled to an older es version during your build-process.\nGet started\n\nRead the documentation\nLook at the example (example/*.ts).\nAsk questions if the above doesn't clarify something good enough.\n\nGoals of this Project\nI am a purist. If possible, I like to work with the tools the browser gives me. I don't need an npm package to trim text, filter arrays, etc..\nExisting libraries\nWhile looking at existing libraries, I mostly found packages, that have not been updated in almost a decade, had no TypeScript support, weighed a ton or had a lot of dependencies.\nThe only library I deemed worthy of considering was howler. It's actively maintained, has type definitions via @types/howler and 0 dependencies.\nBut two aspects remained (If those don't concern you, you should consider howler):\n\nIt's big: 9.5kB minified + gzipped.\nAnd it abstracts a lot of the web audio part away.\n\nWorking with Raw Web Audio API\nAfter that, I took a look at web audio API tutorials, most of which have been written almost a decade ago. Here are the top 3:\n\nGetting Started with Web Audio API\nDeveloping Game Audio with the Web Audio API\nWeb audio spatialization basics\n\nThat's a lot to read and a lot to adjust for, as the API has changed a bit since then. Even JavaScript has changed quite a lot since then.\nThose tutorials are still worth a read, at least for the theory. You'll have to adjust the code a bit to work with the current standard.\nDeciding to Write Something New\nSo, here I am again starting the same old thought: "There has to be a better way..." (... to get started with web audio).\nThe goal of this library is to have a simple starting point for writing positional audio code with the web audio API without having to dig into old tutorials and convert all the legacy code examples to the new standard.\nYou can start writing code with sounts and as you learn more about the web audio API you can extend your code, as sounts does not hide the web audio API from you.\nReport issues\nSomething not working quite as expected? Do you need a feature that has not been implemented yet? Check the issue tracker and add a new one if your problem is not already listed. Please try to provide a detailed description of your problem, including the steps to reproduce it.\nContribute\nAwesome! If you would like to contribute with a new feature or submit a bugfix, fork this repo and send a pull request. Please, make sure all the unit tests are passing before submitting and add new ones in case you introduced new features.\nLicense\nsounts is licensed under the zlib/libpng, meaning you\ncan use it free of charge, without strings attached in commercial and non-commercial projects. Credits are appreciated but not mandatory.\n","title":"sounts","projectIndex":{"title":"sounts","url":"https://lusito.github.io/sounts/"}},{"url":"https://lusito.github.io/sounts/channels.html","content":"Channels\nChannels are a way of avoiding to play conflicting sounds.\nImagine you have an announcer (someone that gives you information) and you let it play a message to the user. Now, for some reason, another message is being played to the user. He will have to listen to two talkers at the same time, which is not something you can expect of your users.\nTo solve this issue, both SoundPlayer and SoundSource (which extends SoundPlayer) allow you to play sounds on channels (by name).\nIf a sound is already being played on a channel, it will be stopped before playing the new one.\nExample\nimport { SoundPlayer } from "sounts";\n\n// ...\nconst player = new SoundPlayer(audioContext.destination);\n// ...\nconst audioBuffer = ...;\nplayer.playOnChannel("announcer", audioBuffer);\nplayer.playOnChannel("music", musicAudioBuffer);\n\n// later maybe:\nplayer.stopChannel("announcer");\n\n","title":"Channels"},{"url":"https://lusito.github.io/sounts/getting-started.html","content":"Getting Started\nThe following shows you the simplest way to use sounts.\nNotice how you are still using native web audio API constructs. You will always have access to all nodes via the sounts API, so you can do all the stuff you can do with the normal web audio API even if it's not a feature of sounts.\nCreate an AudioContext\nFirst off, you'll need an instance of AudioContext. You can either create one yourself or use the built-in helper function createAudioContext:\nimport { createAudioContext } from "sounts";\n\nconst audioContext = createAudioContext();\n\nThe helper function has the benefit, that it will automatically add a click & keydown listener to resume your audio context as soon as the user interacts with your webpage. This is needed, as some browsers like chrome might suspend your audio context at the start.\nLoad an AudioBuffer\nNext, you'll need to load an AudioBuffer. You probably want to use a loader for that.\nIf you don't have a loader yet, you can take this one, which is written with plain JavaScript features:\nasync function loadAudioBuffer(audioContext: AudioContext, path: string) {\n const response = await fetch(path);\n const data = await response.arrayBuffer();\n return audioContext.decodeAudioData(data);\n}\n\n// ...\nasync function init() {\n // ...\n const audioBuffer = loadAudioBuffer(audioContext, "/assets/explosion.wav");\n}\n\nCreate a SoundPlayer and Play a Sound\nThe easiest way to play (non-positional) sounds is using the SoundPlayer class:\nimport { SoundPlayer } from "sounts";\n\n// ...\nconst player = new SoundPlayer(audioContext.destination);\n// ...\nconst audioBuffer = ...;\nconst sourceNode = player.play(audioBuffer);\n\nYou want to add position, volume and more to your sounds? Check out the other tutorials.\nStop a Sound\nThe play() method of SoundPlayer returns an AudioBufferSourceNode, which you can use to stop the sound:\nconst sourceNode = player.play(audioBuffer);\n// ...\nsourceNode.stop();\n\n","title":"Getting Started"},{"url":"https://lusito.github.io/sounts/gain.html","content":"Gain / Volume\nYou might be looking for a way to change the main volume or the volume of individual sound sources.\nThis can be done using gain.\nGain is not Volume\nIn short: Gain controls how loud something is before it gets processed.\nIn order to understand what that means, we need to understand how web audio processes sound:\nConnecting Nodes\nIn web audio you connect nodes to other nodes until you finally end up at the AudioContext destination.\nA simple connection flow without positional audio and without volume/gain control might look like this:\nAudioBufferSourceNode -> AudioContext.destination\n\nOnce you add positional audio, it might look like this:\n(AudioBufferSourceNode -> PannerNode) -> AudioContext.destination\n\nThe brackets represent the nodes within the SoundSource, so you have one context, but multiple PannerNodes connected to this context.\nNow, in order to control the global "volume", we need to insert a GainNode right before the AudioContext:\nAudioBufferSourceNode -> GainNode -> AudioContext.destination\n\nIf we have positional audio, we might have a GainNode after the PannerNode as well:\n(AudioBufferSourceNode -> PannerNode -> GainNode) -> GainNode -> AudioContext.destination\n\nIn this scenario, you can change the gain of the positioned sound as well as the overall "main volume".\nAdding Global/Main Volume\nAs we learned above, we need to introduce a GainNode in order to configure the global "volume".\nWithout Positional Audio\nimport { SoundPlayer } from "sounts";\n\n// ...\nconst mainVolume = audioContext.createGain();\n// connect main volume to audioContext.destination\nmainVolume.connect(audioContext.destination);\n// Connect the player to mainVolume instead of audioContext.destination!\nconst player = new SoundPlayer(mainVolume);\n\n// Set the gain value (0-1):\nmainVolume.gain.value = 0.5;\n\nWith Positional Audio\nimport { SoundSource } from "sounts";\n\n// ...\nconst mainVolume = audioContext.createGain();\n// connect main volume to audioContext.destination\nmainVolume.connect(audioContext.destination);\n\n// Connect the sound source to mainVolume instead of audioContext.destination!\n// Also pass a gain property to the sound source\nconst source = new SoundSource(mainVolume, { gain: 0.75 });\n// Later you can change the gain:\nsource.setGain(0.5);\n\nBy passing in a gain value as option to the SoundSource constructor, a gain node will automatically be added to the source.\nNote, that you can't call setGain unless you passed a gain value in the options parameter.\nSummary\nAs you can see, it's quite easy to configure GainNodes. You can even have different GainNodes for different sources and players. For example one for main volume, one music, one for all sound effects and one for each sound source individually.\n","title":"Gain / Volume"},{"url":"https://lusito.github.io/sounts/positional-sound.html","content":"Positional Sound\nWith web audio you can move sound sources and the listener (your virtual head) in 2D or 3D space.\nWith sounts this is easily done:\nCreate a SoundListener\nThis is an optional step if you want to change the position and orientation of the listener. Think of the listener as the camera of the audio world.\nIf you don't set up a SoundListener, it will be located at (0, 0, 0) with a forward vector of (0, 0, -1) and an up vector of (0, 1, 0).\nimport { createSoundListener } from "sounts";\n\n// ...\nconst listener = createSoundListener(audioContext);\n// ...\nlistener.setPosition(cameraPos.x, cameraPos.y, cameraPos.z);\n\n// Either set forward and up vector at the same time:\nlistener.setOrientation(forward.x, forward.y, forward.z, up.x, up.y, up.z);\n\n// Or set them independently (it might be interesting if the up vector never changes):\nlistener.setForward(forward.x, forward.y, forward.z);\nlistener.setUp(up.x, up.y, up.z);\n\nIf you are wondering why you'd want to use createSoundListener rather than modifying the audioContext.listener manually: Firefox is still using the legacy API and does not support the standardized API yet. SoundListener abstracts this difference away.\nCreate a SoundSource\nNow that you have your listener configured, you want to play sounds in the 2D/3D world.\nA SoundSource extends the SoundPlayer with a position, orientation and other options related to positional audio.\nimport { SoundSource } from "sounts";\n\n// ...\nconst source = new SoundSource(audioContext.destination);\n// ...\nsource.setPosition(pos.x, pos.y, pos.z);\n// ...\nconst audioBuffer = ...;\nsource.play(audioBuffer);\n\nAs you can see, it's really simple to work with a SoundSource. Check out the API documentation to see what other options you have.\nOrienting a SoundSource\nWhen creating a sound source, you have the option of configuring a cone.\nCheck out the documentation at MDN to learn more about the cone.\nIf you specify a cone for the SoundSource, you can also set its orientation:\nimport { SoundSource } from "sounts";\n\n// ...\nconst source = new SoundSource(audioContext.destination, {\n coneInnerAngle: 30,\n coneOuterAngle: 45,\n coneOuterGain: 0\n});\n// ...\nsource.setOrientation(dir.x, dir.y, dir.z);\n\nDetailed Example\nYou might also want to check out the example code.\n","title":"Positional Sound"},{"url":"https://lusito.github.io/sounts/setup.html","content":"Setup\nThis is the easy part, you already know it:\nInstall With NPM\nnpm i sounts\n\nInstall With Yarn\nyarn add sounts\n\n","title":"Setup"}]
\ No newline at end of file
+[{"url":"https://lusito.github.io/sounts/","content":"sounts\n\n\n\n\n\nA tiny helper library for working with the web audio API written in TypeScript.\nIt has been written to simplify playing sounds in games.\nIt is not meant as a fully-fledged audio library.\nFeatures:\n\nPlaying sounds with and without position and orientation (positional-audio / spatialization)\nA SoundSource (position + orientation) can play multiple sounds\nYou can play sounds on channels (if the specified channel already plays a sound, it will be stopped)\nSounds can of course be played freely (not on a channel)\nIt does not abstract away the web audio API. It only simplifies its usage. So you can still use the full power of the web audio API.\n\nWhat it doesn't do:\n\nPreloading sounds (that's up to you or a different asset manager)\nManipulating sounds\nFallback if web audio API is not supported\n\nIf you are looking for a more complete solution, you might want to take a look at howler.\nFair Warning\nThe compile target of this library is es2015, so if you want to support older browsers, you'll have to ensure that this module is being transpiled to an older es version during your build-process.\nGet started\n\nRead the documentation\nLook at the example (example/*.ts).\nAsk questions if the above doesn't clarify something good enough.\n\nGoals of this Project\nI am a purist. If possible, I like to work with the tools the browser gives me. I don't need an npm package to trim text, filter arrays, etc..\nExisting libraries\nWhile looking at existing libraries, I mostly found packages, that have not been updated in almost a decade, had no TypeScript support, weighed a ton or had a lot of dependencies.\nThe only library I deemed worthy of considering was howler. It's actively maintained, has type definitions via @types/howler and 0 dependencies.\nBut two aspects remained (If those don't concern you, you should consider howler):\n\nIt's big: 9.5kB minified + gzipped.\nAnd it abstracts a lot of the web audio part away.\n\nWorking with Raw Web Audio API\nAfter that, I took a look at web audio API tutorials, most of which have been written almost a decade ago. Here are the top 3:\n\nGetting Started with Web Audio API\nDeveloping Game Audio with the Web Audio API\nWeb audio spatialization basics\n\nThat's a lot to read and a lot to adjust for, as the API has changed a bit since then. Even JavaScript has changed quite a lot since then.\nThose tutorials are still worth a read, at least for the theory. You'll have to adjust the code a bit to work with the current standard.\nDeciding to Write Something New\nSo, here I am again starting the same old thought: "There has to be a better way..." (... to get started with web audio).\nThe goal of this library is to have a simple starting point for writing positional audio code with the web audio API without having to dig into old tutorials and convert all the legacy code examples to the new standard.\nYou can start writing code with sounts and as you learn more about the web audio API you can extend your code, as sounts does not hide the web audio API from you.\nReport issues\nSomething not working quite as expected? Do you need a feature that has not been implemented yet? Check the issue tracker and add a new one if your problem is not already listed. Please try to provide a detailed description of your problem, including the steps to reproduce it.\nContribute\nAwesome! If you would like to contribute with a new feature or submit a bugfix, fork this repo and send a pull request. Please, make sure all the unit tests are passing before submitting and add new ones in case you introduced new features.\nLicense\nsounts is licensed under the zlib/libpng, meaning you\ncan use it free of charge, without strings attached in commercial and non-commercial projects. Credits are appreciated but not mandatory.\n","title":"sounts","projectIndex":{"title":"sounts","url":"https://lusito.github.io/sounts/"}},{"url":"https://lusito.github.io/sounts/channels.html","content":"Channels\nChannels are a way of avoiding to play conflicting sounds.\nImagine you have an announcer (someone that gives you information) and you let it play a message to the user. Now, for some reason, another message is being played to the user. He will have to listen to two talkers at the same time, which is not something you can expect of your users.\nTo solve this issue, both SoundPlayer and SoundSource (which extends SoundPlayer) allow you to play sounds on channels (by name).\nIf a sound is already being played on a channel, it will be stopped before playing the new one.\nExample\nimport { SoundPlayer } from "sounts";\n\n// ...\nconst player = new SoundPlayer(audioContext.destination);\n// ...\nconst audioBuffer = ...;\nplayer.playOnChannel("announcer", audioBuffer);\nplayer.playOnChannel("music", musicAudioBuffer);\n\n// later maybe:\nplayer.stopChannel("announcer");\n\n","title":"Channels"},{"url":"https://lusito.github.io/sounts/gain.html","content":"Gain / Volume\nYou might be looking for a way to change the main volume or the volume of individual sound sources.\nThis can be done using gain.\nGain is not Volume\nIn short: Gain controls how loud something is before it gets processed.\nIn order to understand what that means, we need to understand how web audio processes sound:\nConnecting Nodes\nIn web audio you connect nodes to other nodes until you finally end up at the AudioContext destination.\nA simple connection flow without positional audio and without volume/gain control might look like this:\nAudioBufferSourceNode -> AudioContext.destination\n\nOnce you add positional audio, it might look like this:\n(AudioBufferSourceNode -> PannerNode) -> AudioContext.destination\n\nThe brackets represent the nodes within the SoundSource, so you have one context, but multiple PannerNodes connected to this context.\nNow, in order to control the global "volume", we need to insert a GainNode right before the AudioContext:\nAudioBufferSourceNode -> GainNode -> AudioContext.destination\n\nIf we have positional audio, we might have a GainNode after the PannerNode as well:\n(AudioBufferSourceNode -> PannerNode -> GainNode) -> GainNode -> AudioContext.destination\n\nIn this scenario, you can change the gain of the positioned sound as well as the overall "main volume".\nAdding Global/Main Volume\nAs we learned above, we need to introduce a GainNode in order to configure the global "volume".\nWithout Positional Audio\nimport { SoundPlayer } from "sounts";\n\n// ...\nconst mainVolume = audioContext.createGain();\n// connect main volume to audioContext.destination\nmainVolume.connect(audioContext.destination);\n// Connect the player to mainVolume instead of audioContext.destination!\nconst player = new SoundPlayer(mainVolume);\n\n// Set the gain value (0-1):\nmainVolume.gain.value = 0.5;\n\nWith Positional Audio\nimport { SoundSource } from "sounts";\n\n// ...\nconst mainVolume = audioContext.createGain();\n// connect main volume to audioContext.destination\nmainVolume.connect(audioContext.destination);\n\n// Connect the sound source to mainVolume instead of audioContext.destination!\n// Also pass a gain property to the sound source\nconst source = new SoundSource(mainVolume, { gain: 0.75 });\n// Later you can change the gain:\nsource.setGain(0.5);\n\nBy passing in a gain value as option to the SoundSource constructor, a gain node will automatically be added to the source.\nNote, that you can't call setGain unless you passed a gain value in the options parameter.\nSummary\nAs you can see, it's quite easy to configure GainNodes. You can even have different GainNodes for different sources and players. For example one for main volume, one music, one for all sound effects and one for each sound source individually.\n","title":"Gain / Volume"},{"url":"https://lusito.github.io/sounts/getting-started.html","content":"Getting Started\nThe following shows you the simplest way to use sounts.\nNotice how you are still using native web audio API constructs. You will always have access to all nodes via the sounts API, so you can do all the stuff you can do with the normal web audio API even if it's not a feature of sounts.\nCreate an AudioContext\nFirst off, you'll need an instance of AudioContext. You can either create one yourself or use the built-in helper function createAudioContext:\nimport { createAudioContext } from "sounts";\n\nconst audioContext = createAudioContext();\n\nThe helper function has the benefit, that it will automatically add a click & keydown listener to resume your audio context as soon as the user interacts with your webpage. This is needed, as some browsers like chrome might suspend your audio context at the start.\nLoad an AudioBuffer\nNext, you'll need to load an AudioBuffer. You probably want to use a loader for that.\nIf you don't have a loader yet, you can take this one, which is written with plain JavaScript features:\nasync function loadAudioBuffer(audioContext: AudioContext, path: string) {\n const response = await fetch(path);\n const data = await response.arrayBuffer();\n return audioContext.decodeAudioData(data);\n}\n\n// ...\nasync function init() {\n // ...\n const audioBuffer = loadAudioBuffer(audioContext, "/assets/explosion.wav");\n}\n\nCreate a SoundPlayer and Play a Sound\nThe easiest way to play (non-positional) sounds is using the SoundPlayer class:\nimport { SoundPlayer } from "sounts";\n\n// ...\nconst player = new SoundPlayer(audioContext.destination);\n// ...\nconst audioBuffer = ...;\nconst sourceNode = player.play(audioBuffer);\n\nYou want to add position, volume and more to your sounds? Check out the other tutorials.\nStop a Sound\nThe play() method of SoundPlayer returns an AudioBufferSourceNode, which you can use to stop the sound:\nconst sourceNode = player.play(audioBuffer);\n// ...\nsourceNode.stop();\n\n","title":"Getting Started"},{"url":"https://lusito.github.io/sounts/positional-sound.html","content":"Positional Sound\nWith web audio you can move sound sources and the listener (your virtual head) in 2D or 3D space.\nWith sounts this is easily done:\nCreate a SoundListener\nThis is an optional step if you want to change the position and orientation of the listener. Think of the listener as the camera of the audio world.\nIf you don't set up a SoundListener, it will be located at (0, 0, 0) with a forward vector of (0, 0, -1) and an up vector of (0, 1, 0).\nimport { createSoundListener } from "sounts";\n\n// ...\nconst listener = createSoundListener(audioContext);\n// ...\nlistener.setPosition(cameraPos.x, cameraPos.y, cameraPos.z);\n\n// Either set forward and up vector at the same time:\nlistener.setOrientation(forward.x, forward.y, forward.z, up.x, up.y, up.z);\n\n// Or set them independently (it might be interesting if the up vector never changes):\nlistener.setForward(forward.x, forward.y, forward.z);\nlistener.setUp(up.x, up.y, up.z);\n\nIf you are wondering why you'd want to use createSoundListener rather than modifying the audioContext.listener manually: Firefox is still using the legacy API and does not support the standardized API yet. SoundListener abstracts this difference away.\nCreate a SoundSource\nNow that you have your listener configured, you want to play sounds in the 2D/3D world.\nA SoundSource extends the SoundPlayer with a position, orientation and other options related to positional audio.\nimport { SoundSource } from "sounts";\n\n// ...\nconst source = new SoundSource(audioContext.destination);\n// ...\nsource.setPosition(pos.x, pos.y, pos.z);\n// ...\nconst audioBuffer = ...;\nsource.play(audioBuffer);\n\nAs you can see, it's really simple to work with a SoundSource. Check out the API documentation to see what other options you have.\nOrienting a SoundSource\nWhen creating a sound source, you have the option of configuring a cone.\nCheck out the documentation at MDN to learn more about the cone.\nIf you specify a cone for the SoundSource, you can also set its orientation:\nimport { SoundSource } from "sounts";\n\n// ...\nconst source = new SoundSource(audioContext.destination, {\n coneInnerAngle: 30,\n coneOuterAngle: 45,\n coneOuterGain: 0\n});\n// ...\nsource.setOrientation(dir.x, dir.y, dir.z);\n\nDetailed Example\nYou might also want to check out the example code.\n","title":"Positional Sound"},{"url":"https://lusito.github.io/sounts/setup.html","content":"Setup\nThis is the easy part, you already know it:\nInstall With NPM\nnpm i sounts\n\nInstall With Yarn\nyarn add sounts\n\n","title":"Setup"}]
\ No newline at end of file
diff --git a/sitemap.xml b/sitemap.xml
index 4e7fba1..a0be3fc 100644
--- a/sitemap.xml
+++ b/sitemap.xml
@@ -6,8 +6,8 @@
https://lusito.github.io/sounts/all.htmlhttps://lusito.github.io/sounts/https://lusito.github.io/sounts/channels.html
- https://lusito.github.io/sounts/getting-started.htmlhttps://lusito.github.io/sounts/gain.html
+ https://lusito.github.io/sounts/getting-started.htmlhttps://lusito.github.io/sounts/positional-sound.htmlhttps://lusito.github.io/sounts/setup.html
\ No newline at end of file