{"id":17273068,"url":"https://github.com/jakubfiala/panner-utils","last_synced_at":"2025-04-14T08:42:26.046Z","repository":{"id":57144685,"uuid":"153900284","full_name":"jakubfiala/panner-utils","owner":"jakubfiala","description":"Utility functions to calculate vector values for the Web Audio PannerNode","archived":false,"fork":false,"pushed_at":"2018-10-20T13:35:45.000Z","size":12,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T22:13:29.937Z","etag":null,"topics":["audio","javascript","spatial-audio","web-audio","web-audio-api"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jakubfiala.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-20T11:49:06.000Z","updated_at":"2024-03-29T22:14:12.000Z","dependencies_parsed_at":"2022-09-05T11:30:36.863Z","dependency_job_id":null,"html_url":"https://github.com/jakubfiala/panner-utils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubfiala%2Fpanner-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubfiala%2Fpanner-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubfiala%2Fpanner-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakubfiala%2Fpanner-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakubfiala","download_url":"https://codeload.github.com/jakubfiala/panner-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248849514,"owners_count":21171588,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","javascript","spatial-audio","web-audio","web-audio-api"],"created_at":"2024-10-15T08:50:10.502Z","updated_at":"2025-04-14T08:42:26.025Z","avatar_url":"https://github.com/jakubfiala.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# panner-utils\n\nUtility functions to calculate vector values for the [Web Audio PannerNode](https://developer.mozilla.org/en-US/docs/Web/API/PannerNode).\n\nThey convert between rotation around [aircraft principal axes](https://en.wikipedia.org/wiki/Aircraft_principal_axes)\nto forward/up orientation vectors as required by the `AudioListener` and `PannerNode`\ninterfaces of the Web Audio API.\n\n![Aircraft principal axes visualisation](https://upload.wikimedia.org/wikipedia/commons/thumb/5/54/Flight_dynamics_with_text.png/320px-Flight_dynamics_with_text.png)\n\n[Image source](https://commons.wikimedia.org/wiki/File:Flight_dynamics_with_text.png)\n\n```\nnpm i panner-utils\n```\n\n## Usage example\n\n```js\nconst context = new AudioContext();\n// point the listener 45 degrees to the left, 60 degrees up and tilt by 15 degrees\nconst listenerOrientation = calculateListenerOrientation(45, 60, -15);\n\ncontext.listener.forwardX.setValueAtTime(listenerOrientation.forward.x, context.currentTime);\ncontext.listener.forwardY.setValueAtTime(listenerOrientation.forward.y, context.currentTime);\ncontext.listener.forwardZ.setValueAtTime(listenerOrientation.forward.z, context.currentTime);\ncontext.listener.upX.setValueAtTime(listenerOrientation.up.x, context.currentTime);\ncontext.listener.upY.setValueAtTime(listenerOrientation.up.y, context.currentTime);\ncontext.listener.upZ.setValueAtTime(listenerOrientation.up.z, context.currentTime);\n\nconst panner = new PannerNode(context, { panningModel: 'HRTF' });\n// point the panner 45 degrees to the right and 15 degrees up\nconst pannerOrientation = calculatePannerOrientation({ yaw: -45, pitch: 15 });\n\npanner.orientationX.setValueAtTime(pannerOrientation.x, context.currentTime);\npanner.orientationY.setValueAtTime(pannerOrientation.y, context.currentTime);\npanner.orientationZ.setValueAtTime(pannerOrientation.z, context.currentTime);\n```\n\n\n## Reference\n\nThe module exports the following two functions:\n\n### calculatePannerOrientation\n\nThis function takes two arguments, all defaulting to 0:\n\n+ `yaw` – rotation around the Y axis (in degrees)\n+ `pitch` – rotation around the X axis (in degrees)\n\nand returns an object with properties `x, y, z` corresponding to the\n`PannerNode.{orientationX,orientationY,orientationZ}` parameters.\n\nYou can also pass the arguments in a single object.\n\n*Note: this function assumes that, at no rotation (`{ yaw: 0, pitch: 0 }`),\nthe panner is pointing **forward**, i.e. away from the listener. This is to harmonise the rotation\ncalculations for both the panner and listener, since by default in Web Audio,\nthe Panner is facing 90 degrees to the left.*\n\n### calculateListenerOrientation\n\nThis function takes three arguments, all defaulting to 0:\n\n+ `yaw` – rotation around the Y axis (in degrees)\n+ `pitch` – rotation around the X axis (in degrees)\n+ `roll` - rotation around the Z axis (in degrees)\n\nand returns an object with properties `forward, up`,\neach of which has the properties `x, y, z` corresponding to the\nappropriate `PannerNode` parameters.\n\nYou can also pass the arguments in a single object.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakubfiala%2Fpanner-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakubfiala%2Fpanner-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakubfiala%2Fpanner-utils/lists"}