{"action":"created","comment":{"url":"https://api.github.com/repos/mosra/magnum/pulls/comments/39932024","id":39932024,"diff_hunk":"@@ -0,0 +1,247 @@\n+#ifndef Magnum_Audio_Listener_h\n+#define Magnum_Audio_Listener_h\n+/*\n+    This file is part of Magnum.\n+\n+    Copyright © 2010, 2011, 2012, 2013, 2014, 2015\n+              Vladimír Vondruš <mosra@centrum.cz>\n+    Copyright © 2015 Jonathan Hale <squareys@googlemail.com>\n+\n+    Permission is hereby granted, free of charge, to any person obtaining a\n+    copy of this software and associated documentation files (the \"Software\"),\n+    to deal in the Software without restriction, including without limitation\n+    the rights to use, copy, modify, merge, publish, distribute, sublicense,\n+    and/or sell copies of the Software, and to permit persons to whom the\n+    Software is furnished to do so, subject to the following conditions:\n+\n+    The above copyright notice and this permission notice shall be included\n+    in all copies or substantial portions of the Software.\n+\n+    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n+    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n+    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n+    DEALINGS IN THE SOFTWARE.\n+*/\n+\n+/** @file\n+ * @brief Class @ref Magnum::Audio::Listener\n+ */\n+\n+#include <string>\n+#include <al.h>\n+\n+#include <Magnum/Math/Matrix3.h>\n+#include <Magnum/Math/Matrix4.h>\n+#include <Magnum/Math/Quaternion.h>\n+#include <Magnum/SceneGraph/AbstractFeature.h>\n+#include <Magnum/SceneGraph/AbstractObject.h>\n+\n+#include \"Magnum/Audio/Renderer.h\"\n+\n+namespace Magnum { namespace Audio {\n+\n+/** !!! TODO: This is an experiment !!!\n+ * @brief Base for @ref AbstractListener, @ref Listener2D and @ref Listener3D\n+ */\n+class AbstractListenerBase {\n+    public:\n+\n+        /** @brief Destructor */\n+        virtual ~AbstractListenerBase() = 0;\n+\n+        /** @brief Whether this listener is the active listener */\n+        bool isActive() {\n+            return (this == _activeListener);\n+        }\n+\n+        /**\n+         * @brief Set this listener as the active listener\n+         * @param active Whether to activate or deactivate this listener.\n+         *\n+         * When activating a listener, all other listeners are disabled. If\n+         * this listener was not active and is disabled by passing `false`,\n+         * this method does nothing.\n+         */\n+        virtual void setActive(bool active = true) {\n+            if(active) {\n+                _activeListener = this;\n+            } else if(isActive()){\n+                _activeListener = nullptr;\n+            }\n+        }\n+\n+    protected:\n+        /** @brief Constructor */\n+        explicit AbstractListenerBase() = default;\n+\n+    private:\n+        /* Pointer to the currently active listener. Should never be dereferenced, since may be null at any given time. */\n+        static AbstractListenerBase* _activeListener;\n+};\n+\n+AbstractListenerBase* AbstractListenerBase::_activeListener = nullptr;\n+\n+inline AbstractListenerBase::~AbstractListenerBase() { }\n+\n+/**\n+@brief Base of @ref Listener2D and @ref Listener3D\n+\n+Contains methods common for all Listeners.\n+\n+## Usage\n+\n+Minimal scene setup with a listener will require the following code:\n+\n+@code\n+Scene3D scene;\n+Object3D object{&scene};\n+Listener3D listener{object};\n+\n+// Important!\n+listener.setActive();\n+\n+// ... and every frame, update listener to object transformation if necessary\n+listener.update();\n+\n+@endcode\n+\n+Without calling `listener.setActive()`, calling `listener.update()` will not update the OpenAL listener.\n+For two dimensional scenes simply replace `3D` with `2D`.\n+\n+## Active Listener\n+\n+There can only be at the most *one* active listener at a given time. This is because OpenAL only supports notion of one listener.\n+Having multiple @ref Listener2D or @ref Listener3D instances can still be useful for conveniently switching between them for\n+cinematics for example.\n+\n+## Sound Transformation\n+\n+@ref AbstractListener::setSoundTransformation() enables you to set transformation which is applied to the listeners orientation and position\n+before passed onto OpenAL. This can be used for rotating two dimensional scenes as planes into three dimensional space or even scaling the audio\n+scene to match a certain world scale. In the later case you might want to instead consider @ref Renderer::setSpeedOfSound().\n+\n+*/\n+template <UnsignedInt dimensions, class Derived> class AbstractListener: public SceneGraph::AbstractFeature<dimensions, Float>, public AbstractListenerBase {","path":"src/Magnum/Audio/Listener.h","position":127,"original_position":127,"commit_id":"dc004f50618b5bef6f39aebf36ae0086d59600ec","original_commit_id":"dc004f50618b5bef6f39aebf36ae0086d59600ec","user":{"login":"mosra","id":344828,"avatar_url":"https://avatars.githubusercontent.com/u/344828?v=3","gravatar_id":"","url":"https://api.github.com/users/mosra","html_url":"https://github.com/mosra","followers_url":"https://api.github.com/users/mosra/followers","following_url":"https://api.github.com/users/mosra/following{/other_user}","gists_url":"https://api.github.com/users/mosra/gists{/gist_id}","starred_url":"https://api.github.com/users/mosra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mosra/subscriptions","organizations_url":"https://api.github.com/users/mosra/orgs","repos_url":"https://api.github.com/users/mosra/repos","events_url":"https://api.github.com/users/mosra/events{/privacy}","received_events_url":"https://api.github.com/users/mosra/received_events","type":"User","site_admin":false},"body":"I might be blind, but why the `Derived` template parameter is needed?","created_at":"2015-09-20T17:15:05Z","updated_at":"2015-09-20T17:15:05Z","html_url":"https://github.com/mosra/magnum/pull/110#discussion_r39932024","pull_request_url":"https://api.github.com/repos/mosra/magnum/pulls/110","_links":{"self":{"href":"https://api.github.com/repos/mosra/magnum/pulls/comments/39932024"},"html":{"href":"https://github.com/mosra/magnum/pull/110#discussion_r39932024"},"pull_request":{"href":"https://api.github.com/repos/mosra/magnum/pulls/110"}}},"pull_request":{"url":"https://api.github.com/repos/mosra/magnum/pulls/110","id":44532705,"html_url":"https://github.com/mosra/magnum/pull/110","diff_url":"https://github.com/mosra/magnum/pull/110.diff","patch_url":"https://github.com/mosra/magnum/pull/110.patch","issue_url":"https://api.github.com/repos/mosra/magnum/issues/110","number":110,"state":"open","locked":false,"title":"[WIP] Audio features","user":{"login":"Squareys","id":1889284,"avatar_url":"https://avatars.githubusercontent.com/u/1889284?v=3","gravatar_id":"","url":"https://api.github.com/users/Squareys","html_url":"https://github.com/Squareys","followers_url":"https://api.github.com/users/Squareys/followers","following_url":"https://api.github.com/users/Squareys/following{/other_user}","gists_url":"https://api.github.com/users/Squareys/gists{/gist_id}","starred_url":"https://api.github.com/users/Squareys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Squareys/subscriptions","organizations_url":"https://api.github.com/users/Squareys/orgs","repos_url":"https://api.github.com/users/Squareys/repos","events_url":"https://api.github.com/users/Squareys/events{/privacy}","received_events_url":"https://api.github.com/users/Squareys/received_events","type":"User","site_admin":false},"body":"Hi @mosra, Hi everybody!\r\n\r\nAs discussed, here is a work-in-progress pullrequest for everything related to Audio and SceneGraph.\r\n\r\nTODOs:\r\n - [ ] PlayableGroup\r\n - [ ] Playable\r\n - [ ] Listener\r\n - [ ] Adapt audio-example\r\n\r\nGreetings, Squareys","created_at":"2015-09-09T10:19:22Z","updated_at":"2015-09-20T17:15:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"936b2beeb646f9e0c148702c049fbee40dd6f927","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mosra/magnum/pulls/110/commits","review_comments_url":"https://api.github.com/repos/mosra/magnum/pulls/110/comments","review_comment_url":"https://api.github.com/repos/mosra/magnum/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mosra/magnum/issues/110/comments","statuses_url":"https://api.github.com/repos/mosra/magnum/statuses/dc004f50618b5bef6f39aebf36ae0086d59600ec","head":{"label":"Squareys:audio-features","ref":"audio-features","sha":"dc004f50618b5bef6f39aebf36ae0086d59600ec","user":{"login":"Squareys","id":1889284,"avatar_url":"https://avatars.githubusercontent.com/u/1889284?v=3","gravatar_id":"","url":"https://api.github.com/users/Squareys","html_url":"https://github.com/Squareys","followers_url":"https://api.github.com/users/Squareys/followers","following_url":"https://api.github.com/users/Squareys/following{/other_user}","gists_url":"https://api.github.com/users/Squareys/gists{/gist_id}","starred_url":"https://api.github.com/users/Squareys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Squareys/subscriptions","organizations_url":"https://api.github.com/users/Squareys/orgs","repos_url":"https://api.github.com/users/Squareys/repos","events_url":"https://api.github.com/users/Squareys/events{/privacy}","received_events_url":"https://api.github.com/users/Squareys/received_events","type":"User","site_admin":false},"repo":{"id":33696624,"name":"magnum","full_name":"Squareys/magnum","owner":{"login":"Squareys","id":1889284,"avatar_url":"https://avatars.githubusercontent.com/u/1889284?v=3","gravatar_id":"","url":"https://api.github.com/users/Squareys","html_url":"https://github.com/Squareys","followers_url":"https://api.github.com/users/Squareys/followers","following_url":"https://api.github.com/users/Squareys/following{/other_user}","gists_url":"https://api.github.com/users/Squareys/gists{/gist_id}","starred_url":"https://api.github.com/users/Squareys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Squareys/subscriptions","organizations_url":"https://api.github.com/users/Squareys/orgs","repos_url":"https://api.github.com/users/Squareys/repos","events_url":"https://api.github.com/users/Squareys/events{/privacy}","received_events_url":"https://api.github.com/users/Squareys/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Squareys/magnum","description":"C++11/C++14 and OpenGL graphics engine","fork":true,"url":"https://api.github.com/repos/Squareys/magnum","forks_url":"https://api.github.com/repos/Squareys/magnum/forks","keys_url":"https://api.github.com/repos/Squareys/magnum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Squareys/magnum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Squareys/magnum/teams","hooks_url":"https://api.github.com/repos/Squareys/magnum/hooks","issue_events_url":"https://api.github.com/repos/Squareys/magnum/issues/events{/number}","events_url":"https://api.github.com/repos/Squareys/magnum/events","assignees_url":"https://api.github.com/repos/Squareys/magnum/assignees{/user}","branches_url":"https://api.github.com/repos/Squareys/magnum/branches{/branch}","tags_url":"https://api.github.com/repos/Squareys/magnum/tags","blobs_url":"https://api.github.com/repos/Squareys/magnum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Squareys/magnum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Squareys/magnum/git/refs{/sha}","trees_url":"https://api.github.com/repos/Squareys/magnum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Squareys/magnum/statuses/{sha}","languages_url":"https://api.github.com/repos/Squareys/magnum/languages","stargazers_url":"https://api.github.com/repos/Squareys/magnum/stargazers","contributors_url":"https://api.github.com/repos/Squareys/magnum/contributors","subscribers_url":"https://api.github.com/repos/Squareys/magnum/subscribers","subscription_url":"https://api.github.com/repos/Squareys/magnum/subscription","commits_url":"https://api.github.com/repos/Squareys/magnum/commits{/sha}","git_commits_url":"https://api.github.com/repos/Squareys/magnum/git/commits{/sha}","comments_url":"https://api.github.com/repos/Squareys/magnum/comments{/number}","issue_comment_url":"https://api.github.com/repos/Squareys/magnum/issues/comments{/number}","contents_url":"https://api.github.com/repos/Squareys/magnum/contents/{+path}","compare_url":"https://api.github.com/repos/Squareys/magnum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Squareys/magnum/merges","archive_url":"https://api.github.com/repos/Squareys/magnum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Squareys/magnum/downloads","issues_url":"https://api.github.com/repos/Squareys/magnum/issues{/number}","pulls_url":"https://api.github.com/repos/Squareys/magnum/pulls{/number}","milestones_url":"https://api.github.com/repos/Squareys/magnum/milestones{/number}","notifications_url":"https://api.github.com/repos/Squareys/magnum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Squareys/magnum/labels{/name}","releases_url":"https://api.github.com/repos/Squareys/magnum/releases{/id}","created_at":"2015-04-09T22:49:56Z","updated_at":"2015-04-09T22:49:58Z","pushed_at":"2015-09-19T14:33:12Z","git_url":"git://github.com/Squareys/magnum.git","ssh_url":"git@github.com:Squareys/magnum.git","clone_url":"https://github.com/Squareys/magnum.git","svn_url":"https://github.com/Squareys/magnum","homepage":"http://mosra.cz/blog/magnum.php","size":19945,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mosra:master","ref":"master","sha":"ab2a5c8a2879907d93b374675523bb916b7624e9","user":{"login":"mosra","id":344828,"avatar_url":"https://avatars.githubusercontent.com/u/344828?v=3","gravatar_id":"","url":"https://api.github.com/users/mosra","html_url":"https://github.com/mosra","followers_url":"https://api.github.com/users/mosra/followers","following_url":"https://api.github.com/users/mosra/following{/other_user}","gists_url":"https://api.github.com/users/mosra/gists{/gist_id}","starred_url":"https://api.github.com/users/mosra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mosra/subscriptions","organizations_url":"https://api.github.com/users/mosra/orgs","repos_url":"https://api.github.com/users/mosra/repos","events_url":"https://api.github.com/users/mosra/events{/privacy}","received_events_url":"https://api.github.com/users/mosra/received_events","type":"User","site_admin":false},"repo":{"id":1182756,"name":"magnum","full_name":"mosra/magnum","owner":{"login":"mosra","id":344828,"avatar_url":"https://avatars.githubusercontent.com/u/344828?v=3","gravatar_id":"","url":"https://api.github.com/users/mosra","html_url":"https://github.com/mosra","followers_url":"https://api.github.com/users/mosra/followers","following_url":"https://api.github.com/users/mosra/following{/other_user}","gists_url":"https://api.github.com/users/mosra/gists{/gist_id}","starred_url":"https://api.github.com/users/mosra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mosra/subscriptions","organizations_url":"https://api.github.com/users/mosra/orgs","repos_url":"https://api.github.com/users/mosra/repos","events_url":"https://api.github.com/users/mosra/events{/privacy}","received_events_url":"https://api.github.com/users/mosra/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mosra/magnum","description":"C++11/C++14 and OpenGL graphics engine","fork":false,"url":"https://api.github.com/repos/mosra/magnum","forks_url":"https://api.github.com/repos/mosra/magnum/forks","keys_url":"https://api.github.com/repos/mosra/magnum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mosra/magnum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mosra/magnum/teams","hooks_url":"https://api.github.com/repos/mosra/magnum/hooks","issue_events_url":"https://api.github.com/repos/mosra/magnum/issues/events{/number}","events_url":"https://api.github.com/repos/mosra/magnum/events","assignees_url":"https://api.github.com/repos/mosra/magnum/assignees{/user}","branches_url":"https://api.github.com/repos/mosra/magnum/branches{/branch}","tags_url":"https://api.github.com/repos/mosra/magnum/tags","blobs_url":"https://api.github.com/repos/mosra/magnum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mosra/magnum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mosra/magnum/git/refs{/sha}","trees_url":"https://api.github.com/repos/mosra/magnum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mosra/magnum/statuses/{sha}","languages_url":"https://api.github.com/repos/mosra/magnum/languages","stargazers_url":"https://api.github.com/repos/mosra/magnum/stargazers","contributors_url":"https://api.github.com/repos/mosra/magnum/contributors","subscribers_url":"https://api.github.com/repos/mosra/magnum/subscribers","subscription_url":"https://api.github.com/repos/mosra/magnum/subscription","commits_url":"https://api.github.com/repos/mosra/magnum/commits{/sha}","git_commits_url":"https://api.github.com/repos/mosra/magnum/git/commits{/sha}","comments_url":"https://api.github.com/repos/mosra/magnum/comments{/number}","issue_comment_url":"https://api.github.com/repos/mosra/magnum/issues/comments{/number}","contents_url":"https://api.github.com/repos/mosra/magnum/contents/{+path}","compare_url":"https://api.github.com/repos/mosra/magnum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mosra/magnum/merges","archive_url":"https://api.github.com/repos/mosra/magnum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mosra/magnum/downloads","issues_url":"https://api.github.com/repos/mosra/magnum/issues{/number}","pulls_url":"https://api.github.com/repos/mosra/magnum/pulls{/number}","milestones_url":"https://api.github.com/repos/mosra/magnum/milestones{/number}","notifications_url":"https://api.github.com/repos/mosra/magnum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mosra/magnum/labels{/name}","releases_url":"https://api.github.com/repos/mosra/magnum/releases{/id}","created_at":"2010-12-19T22:19:59Z","updated_at":"2015-09-14T01:56:31Z","pushed_at":"2015-09-19T14:33:12Z","git_url":"git://github.com/mosra/magnum.git","ssh_url":"git@github.com:mosra/magnum.git","clone_url":"https://github.com/mosra/magnum.git","svn_url":"https://github.com/mosra/magnum","homepage":"http://mosra.cz/blog/magnum.php","size":24802,"stargazers_count":375,"watchers_count":375,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":55,"mirror_url":null,"open_issues_count":23,"forks":55,"open_issues":23,"watchers":375,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mosra/magnum/pulls/110"},"html":{"href":"https://github.com/mosra/magnum/pull/110"},"issue":{"href":"https://api.github.com/repos/mosra/magnum/issues/110"},"comments":{"href":"https://api.github.com/repos/mosra/magnum/issues/110/comments"},"review_comments":{"href":"https://api.github.com/repos/mosra/magnum/pulls/110/comments"},"review_comment":{"href":"https://api.github.com/repos/mosra/magnum/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mosra/magnum/pulls/110/commits"},"statuses":{"href":"https://api.github.com/repos/mosra/magnum/statuses/dc004f50618b5bef6f39aebf36ae0086d59600ec"}}}}