{"action":"created","issue":{"url":"https://api.github.com/repos/WebAudio/web-audio-api/issues/12","labels_url":"https://api.github.com/repos/WebAudio/web-audio-api/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/WebAudio/web-audio-api/issues/12/comments","events_url":"https://api.github.com/repos/WebAudio/web-audio-api/issues/12/events","html_url":"https://github.com/WebAudio/web-audio-api/issues/12","id":19322382,"number":12,"title":"Need a way to determine AudioContext time of currently audible signal","user":{"login":"olivierthereaux","id":604646,"avatar_url":"https://avatars.githubusercontent.com/u/604646?v=3","gravatar_id":"","url":"https://api.github.com/users/olivierthereaux","html_url":"https://github.com/olivierthereaux","followers_url":"https://api.github.com/users/olivierthereaux/followers","following_url":"https://api.github.com/users/olivierthereaux/following{/other_user}","gists_url":"https://api.github.com/users/olivierthereaux/gists{/gist_id}","starred_url":"https://api.github.com/users/olivierthereaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olivierthereaux/subscriptions","organizations_url":"https://api.github.com/users/olivierthereaux/orgs","repos_url":"https://api.github.com/users/olivierthereaux/repos","events_url":"https://api.github.com/users/olivierthereaux/events{/privacy}","received_events_url":"https://api.github.com/users/olivierthereaux/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/WebAudio/web-audio-api/labels/Feature%20Request/Missing%20Feature","name":"Feature Request/Missing Feature","color":"0052cc"},{"url":"https://api.github.com/repos/WebAudio/web-audio-api/labels/Ready%20for%20Editing","name":"Ready for Editing","color":"bfe5bf"}],"state":"open","locked":false,"assignee":{"login":"cwilso","id":507001,"avatar_url":"https://avatars.githubusercontent.com/u/507001?v=3","gravatar_id":"","url":"https://api.github.com/users/cwilso","html_url":"https://github.com/cwilso","followers_url":"https://api.github.com/users/cwilso/followers","following_url":"https://api.github.com/users/cwilso/following{/other_user}","gists_url":"https://api.github.com/users/cwilso/gists{/gist_id}","starred_url":"https://api.github.com/users/cwilso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cwilso/subscriptions","organizations_url":"https://api.github.com/users/cwilso/orgs","repos_url":"https://api.github.com/users/cwilso/repos","events_url":"https://api.github.com/users/cwilso/events{/privacy}","received_events_url":"https://api.github.com/users/cwilso/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/WebAudio/web-audio-api/milestones/1","html_url":"https://github.com/WebAudio/web-audio-api/milestones/Web%20Audio%20V1","labels_url":"https://api.github.com/repos/WebAudio/web-audio-api/milestones/1/labels","id":444685,"number":1,"title":"Web Audio V1","description":"Issues to be resolved to enable V1 to be taken forward.","creator":{"login":"olivierthereaux","id":604646,"avatar_url":"https://avatars.githubusercontent.com/u/604646?v=3","gravatar_id":"","url":"https://api.github.com/users/olivierthereaux","html_url":"https://github.com/olivierthereaux","followers_url":"https://api.github.com/users/olivierthereaux/followers","following_url":"https://api.github.com/users/olivierthereaux/following{/other_user}","gists_url":"https://api.github.com/users/olivierthereaux/gists{/gist_id}","starred_url":"https://api.github.com/users/olivierthereaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olivierthereaux/subscriptions","organizations_url":"https://api.github.com/users/olivierthereaux/orgs","repos_url":"https://api.github.com/users/olivierthereaux/repos","events_url":"https://api.github.com/users/olivierthereaux/events{/privacy}","received_events_url":"https://api.github.com/users/olivierthereaux/received_events","type":"User","site_admin":false},"open_issues":89,"closed_issues":83,"state":"open","created_at":"2013-10-03T15:27:25Z","updated_at":"2015-09-23T09:37:10Z","due_on":null,"closed_at":null},"comments":31,"created_at":"2013-09-11T14:27:36Z","updated_at":"2015-09-24T02:07:32Z","closed_at":null,"body":"> Originally reported on W3C Bugzilla [ISSUE-20698](https://www.w3.org/Bugs/Public/show_bug.cgi?id=20698) Thu, 17 Jan 2013 14:15:09 GMT\n> Reported by Joe Berkovitz / NF\n> Assigned to \n\nUse case:\n\nIf one needs to display a visual cursor in relationship to some onscreen representation of an audio timeline (e.g. a cursor on top of music notation or DAW clips) then knowing the real time coordinates for what is coming out of the speakers is essential.\n\nHowever on any given implementation an AudioContext's currentTime may report a time that is somewhat ahead of the time of the actual audio signal emerging from the device, by a fixed amount.  If a sound is scheduled (even very far in advance) to be played at time T, the sound will actually be played when AudioContext.currentTime = T + L where L is a fixed number.\n\nOn Jan 16, 2013, at 2:05 PM cwilso@google.com wrote:\n\nIt's problematic to incorporate scheduling other real-time events (even knowing precisely \"what time it is\" from the drawing function) without a better understanding of the latency.\n\nThe idea we reached (I think Chris proposed it, but I can't honestly remember) was to have a performance.now()-reference clock time on AudioContext that would tell you when the AudioContext.currentTime was taken (or when that time will occur, if it's in the future); that would allow you to synchronize the two clocks.  The more I've thought about it, the more I quite like this approach - having something like AudioContext.currentSystemTime in window.performance.now()-reference.\n\nOn Jan 16, 2013, at 3:18 PM, Chris Rogers <crogers@google.com> wrote:\n\nthe general idea is that the underlying different platforms/OSs can have very different latency characteristics, so I think you're looking for a way to query the system to know what it is.  I think that something like AudioContext.presentationLatency is what we're looking for.  Presentation latency is the time difference between when you tell an event to happen and the actual time when you hear it.  So, for example, with source.start(0), you would hope to hear the sound right now, but in reality will hear it with some (hopefully) small delay.  One example where this could be useful is if you're trying to synchronize a visual \"playhead\" to the actual audio being scheduled...\n\nI believe the goal for any implementation should be to achieve as low a latency as possible, one which is on-par with desktop/native audio software on the same OS/hardware that the browser is run on.  That said, as with other aspects of the web platform (page rendering speed, cache behavior, etc.) performance is something which is tuned (and hopefully improved) over time for each browser implementation and OS."},"comment":{"url":"https://api.github.com/repos/WebAudio/web-audio-api/issues/comments/142782739","html_url":"https://github.com/WebAudio/web-audio-api/issues/12#issuecomment-142782739","issue_url":"https://api.github.com/repos/WebAudio/web-audio-api/issues/12","id":142782739,"user":{"login":"srikumarks","id":117721,"avatar_url":"https://avatars.githubusercontent.com/u/117721?v=3","gravatar_id":"","url":"https://api.github.com/users/srikumarks","html_url":"https://github.com/srikumarks","followers_url":"https://api.github.com/users/srikumarks/followers","following_url":"https://api.github.com/users/srikumarks/following{/other_user}","gists_url":"https://api.github.com/users/srikumarks/gists{/gist_id}","starred_url":"https://api.github.com/users/srikumarks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srikumarks/subscriptions","organizations_url":"https://api.github.com/users/srikumarks/orgs","repos_url":"https://api.github.com/users/srikumarks/repos","events_url":"https://api.github.com/users/srikumarks/events{/privacy}","received_events_url":"https://api.github.com/users/srikumarks/received_events","type":"User","site_admin":false},"created_at":"2015-09-24T02:07:32Z","updated_at":"2015-09-24T02:07:32Z","body":"> It's understood that it's possible this could be inaccurate due to delays not observable from the OS, e.g. Bluetooth transmission delays.\r\n\r\nThese are observable from some OSes. [AVAudioSession] on iOS provides this latency in its `outputLatency` property. The [AudioTimeStamp] received as an argument in the output audio callbacks provides both sample time and host time (in addition to other times if available), but the latency needs to be added to the host time to get the playback time.\r\n\r\n[AVAudioSession]: https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAudioSession_ClassReference/#//apple_ref/occ/instp/AVAudioSession/outputLatency\r\n[AudioTimeStamp]: https://developer.apple.com/library/mac/documentation/MusicAudio/Reference/CoreAudioDataTypesRef/#//apple_ref/c/tdef/AudioTimeStamp"}}