You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove unsupported methods from offlineAudioContext #308
Needs EditsDecision has been made, the issue can be fixed. https://speced.github.io/spec-maintenance/about/
don't make sense in an offlineAudioContext. They should be removed from the spec. Robert O'Callahan suggests adding a baseAudioContext or similar to the spec which AudioContext and offlineAudioContext can inherit from. That seems sensible to me.
Further guidance, then? adding an "implements" of an interface that contains the creation mechanisms of real-time nodes? We'd still need to handle erroring on new() (when we handle new()ing) when given an offline context rather than a realtime one.
Or we could flip it, make offlineaudiocontext "batchaudiocontext" and have the normal realtimeaudiocontext inherit from it...
The latter plan sounds better, but in the end, I am not sure inheritance relationships are useful. What new capabilities do they give programmers?
The more important thing is that for shared functionality, they share the same methods that accomplish that functionality, so that code that relies on only the shared subset can act on either without any trouble. This could be accomplished in a variety of ways, and inheritance seems to have no impact on that.
I'm confused. :) The only benefit of the latter idea is that it uses inheritance; it's kinda wacky that it does, in fact, since it kinda flips the ordering. I guess they both do.
In short - how would you normally structure two objects that are essentially the same class, except the less-commonly-used, special case object type has one subclass of functionality missing (when compared to the more commonly used one)?
how would you normally structure two objects that are essentially the same class, except the less-commonly-used, special case object type has one subclass of functionality missing
I would create two classes, with some methods appearing in both, and some appearing only in one. E.g.
I mean, hopefully WebIDL has features that would reduce that duplication. If not, hopefully that can be fixed in WebIDL. You shouldn't impose changes on the JavaScript-visible API just because WebIDL hasn't given you the tools you want.
Well, I haven't had any responses on my post to public-audio, so I'll cross-post here. Maybe more of the interested people will see it here.
I actually think that it does make sense to use a MediaElementAudioSourceNode in an OfflineAudioContext. I would very much like to be able to do this, particularly with a
Use cases:
A simple case: a web application that lets the user select a video file on their local storage, and uploads just the audio track to a server. It would create a Blob URL for the file, create a video element using that URL, and plug that into the OfflineAudioContext via a MediaElementAudioSourceNode. The audio could be retrieved as one giant buffer when the OfflineAudioContext is done, or as the decoding happens via a ScriptProcessorNode, or maybe sent to the server via WebRTC with a MediaStreamAudioDestinationNode. (Note: for this use case, it should not be necessary to actually decode the video track of the file, but I have no idea how hard it would be to implement this as a browser optimization.)
Similar to the above, but instead of the video track being completely dropped, its resolution and bit rate would be decreased. WebGL or a 2D canvas context can be used for high-quality scaling of each frame. This would be very useful for something like a web-based video editor, where you would like a low-quality version of your source material to be available very quickly for editing; the original high-quality footage can be uploaded later before final high-quality rendering.
More general cases, such as a web-based video editor that does its rendering on the client side (which is actually something I've been working on). In this case, the video source material would come from the server (possibly uploaded as described above). During editing, playback is low-quality and real-time, but when it's time to render the final, high-quality product, it generally has to happen much slower than real time. Of course it might be possible to do the audio and video rendering entirely separately in some cases, but there are cases where the rendered video would depend on the rendered audio and vice versa, such as an oscilloscope effect (audio affects video) or a text-to-speech effect (video affects audio).
I know I'm probably raising some complicated issues here, having to do with synchronization and worker threads and things I haven't thought of. I don't know a lot about browser implementations. I have read some recent conversations (mainly on this list) having to do with making all ScriptProcessorNode callbacks happen in a worker thread (both for AudioContext and OfflineAudioContext, I believe), which seems like a good idea, but could make some things difficult since the media element feeding a MediaElementAudioSourceNode can't exist in a worker.
Is any of the above practical? Is there any hope of these scenarios being possible to implement, let alone in an efficient and elegant way? I feel like it should be possible.
I saw it on public-audio too, just haven't gotten to respond yet.
Short version: You have no timeline control over media elements from within the web audio timeline, and no ability to run a MediaStream at faster than realtime. If that work were done - faster-than-realtime MediaStreams - that might make this possible, but as it is, we just can't reach back at an appropriate time, and remember that and
All three of these use cases really seem like they'd be better served by a stronger Media API, not by hacking into Web Audio for processing/re-recording. Particularly case 3, is really video-specific.
Wouldn't a stronger media API include the audio API? As in, the video and audio stuff should integrate well?
I don't see case 3 as all that video-specific. A good video editor needs to support flexible audio processing, including things like effects that would be well handled by the audio API. I would even want it to be able to include a music production system, with synthesizers and sequencing and all that, so I could create a full soundtrack for a movie.
I think all of what I want could probably be done in a near-future version of standard web APIs, but it might take some really ugly hacks. I need to go reread those threads about AudioWorkers and ScriptProcessorNode/OfflineAudioContext more carefully. I'm afraid that offline rendering might end up being too limited for what I and many other people want to do.
Possibly what I REALLY want is to be able to use all the standardized browser features (DOM elements, videos, WebGL, WebRTC, ...) in web workers and AudioWorkers (assuming that happens; it sounds like a good idea to me). I don't know if that's likely or what discussion group I'd have to crash to ask about it. I think of it this way: video codecs and WebGL are very powerful compute engines, and it would be a shame not to be able to use them outside the one main UI thread.
TPAC Resolution: Adopt ROC's original suggestion of making both the offline and realtime AudioContexts inherit from an abstract base class that doesn't contain the methods in question.
Note: Ask Cameron McCormack to pronounce on best way to describe in WebIDL.
Needs EditsDecision has been made, the issue can be fixed. https://speced.github.io/spec-maintenance/about/
I'm asking heycam for best WebIDL practices before merging.
In fact, we can ask @heycam right here. Cameron, we have the following setup (in pseudo code):
class BaseAudioContext {
... a lot of methods ...
};
class AudioContext : inherits BaseAudioContext {
... some more AudioContext-specific methods ...
};
class OfflineAudioContext: inherits BaseAudioContext {
... more OfflineAudioContext-specific methods ...
};
what would be the best way to write that in WebIDL ?
This does go against what @domenic says earlier about not having non-constructable base classes, but to be honest having the abstract base class not be constructable makes sense to me.
Needs EditsDecision has been made, the issue can be fixed. https://speced.github.io/spec-maintenance/about/
Activity
domenic commentedon Apr 3, 2014
Non-constructable base classes is not a good idea.
cwilso commentedon Apr 3, 2014
Further guidance, then? adding an "implements" of an interface that contains the creation mechanisms of real-time nodes? We'd still need to handle erroring on new() (when we handle new()ing) when given an offline context rather than a realtime one.
Or we could flip it, make offlineaudiocontext "batchaudiocontext" and have the normal realtimeaudiocontext inherit from it...
domenic commentedon Apr 3, 2014
The latter plan sounds better, but in the end, I am not sure inheritance relationships are useful. What new capabilities do they give programmers?
The more important thing is that for shared functionality, they share the same methods that accomplish that functionality, so that code that relies on only the shared subset can act on either without any trouble. This could be accomplished in a variety of ways, and inheritance seems to have no impact on that.
cwilso commentedon Apr 3, 2014
I'm confused. :) The only benefit of the latter idea is that it uses inheritance; it's kinda wacky that it does, in fact, since it kinda flips the ordering. I guess they both do.
In short - how would you normally structure two objects that are essentially the same class, except the less-commonly-used, special case object type has one subclass of functionality missing (when compared to the more commonly used one)?
domenic commentedon Apr 3, 2014
I would create two classes, with some methods appearing in both, and some appearing only in one. E.g.
cwilso commentedon Apr 4, 2014
That seems REALLY duplicative, since it would actually be:
domenic commentedon Apr 4, 2014
I mean, hopefully WebIDL has features that would reduce that duplication. If not, hopefully that can be fixed in WebIDL. You shouldn't impose changes on the JavaScript-visible API just because WebIDL hasn't given you the tools you want.
adelespinasse commentedon Jul 24, 2014
Well, I haven't had any responses on my post to public-audio, so I'll cross-post here. Maybe more of the interested people will see it here.
I actually think that it does make sense to use a MediaElementAudioSourceNode in an OfflineAudioContext. I would very much like to be able to do this, particularly with a
Use cases:
I know I'm probably raising some complicated issues here, having to do with synchronization and worker threads and things I haven't thought of. I don't know a lot about browser implementations. I have read some recent conversations (mainly on this list) having to do with making all ScriptProcessorNode callbacks happen in a worker thread (both for AudioContext and OfflineAudioContext, I believe), which seems like a good idea, but could make some things difficult since the media element feeding a MediaElementAudioSourceNode can't exist in a worker.
Is any of the above practical? Is there any hope of these scenarios being possible to implement, let alone in an efficient and elegant way? I feel like it should be possible.
cwilso commentedon Jul 24, 2014
I saw it on public-audio too, just haven't gotten to respond yet.
Short version: You have no timeline control over media elements from within the web audio timeline, and no ability to run a MediaStream at faster than realtime. If that work were done - faster-than-realtime MediaStreams - that might make this possible, but as it is, we just can't reach back at an appropriate time, and remember that and
All three of these use cases really seem like they'd be better served by a stronger Media API, not by hacking into Web Audio for processing/re-recording. Particularly case 3, is really video-specific.
adelespinasse commentedon Jul 26, 2014
Wouldn't a stronger media API include the audio API? As in, the video and audio stuff should integrate well?
I don't see case 3 as all that video-specific. A good video editor needs to support flexible audio processing, including things like effects that would be well handled by the audio API. I would even want it to be able to include a music production system, with synthesizers and sequencing and all that, so I could create a full soundtrack for a movie.
I think all of what I want could probably be done in a near-future version of standard web APIs, but it might take some really ugly hacks. I need to go reread those threads about AudioWorkers and ScriptProcessorNode/OfflineAudioContext more carefully. I'm afraid that offline rendering might end up being too limited for what I and many other people want to do.
Possibly what I REALLY want is to be able to use all the standardized browser features (DOM elements, videos, WebGL, WebRTC, ...) in web workers and AudioWorkers (assuming that happens; it sounds like a good idea to me). I don't know if that's likely or what discussion group I'd have to crash to ask about it. I think of it this way: video codecs and WebGL are very powerful compute engines, and it would be a shame not to be able to use them outside the one main UI thread.
joeberkovitz commentedon Oct 28, 2014
TPAC Resolution: Adopt ROC's original suggestion of making both the offline and realtime AudioContexts inherit from an abstract base class that doesn't contain the methods in question.
Note: Ask Cameron McCormack to pronounce on best way to describe in WebIDL.
Fix #308 by refactoring most of AudioContext into BaseAudioContext.
padenot commentedon Oct 19, 2015
I'm asking heycam for best WebIDL practices before merging.In fact, we can ask @heycam right here. Cameron, we have the following setup (in pseudo code):
what would be the best way to write that in WebIDL ?
heycam commentedon Oct 19, 2015
You can just mirror that structure in IDL interfaces:
interface BaseAudioContext { ... }; [Constructor(...)] interface AudioContext : BaseAudioContext { ... }; [Constructor(...)] interface OfflineAudioContext : BaseAudioContext { ... };This does go against what @domenic says earlier about not having non-constructable base classes, but to be honest having the abstract base class not be constructable makes sense to me.
Merge pull request #638 from WebAudio/308-remove-methods-offline-ctx
Merge pull request #661 from WebAudio/308-remove-methods-offline-ctx