Skip to content

Audio API changes #797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
4f524b8
backup
yilinwei Jul 22, 2023
8b1d132
backup
yilinwei Jul 22, 2023
b44eaa8
backup
yilinwei Jul 22, 2023
2aaf2ed
Switch back to using traits for now.
yilinwei Sep 18, 2023
b91df37
typo.
yilinwei Sep 18, 2023
a4edff5
Switch encoding for mima.
yilinwei Sep 24, 2023
9887ce0
Check-in API report
yilinwei Sep 24, 2023
081534d
BlobEvent and MediaRecorder.
zainab-ali Oct 8, 2023
fca6713
Make sure `BlobEvent` is class.
yilinwei Oct 8, 2023
4dda4bf
`data` is required.
yilinwei Oct 8, 2023
a4cfb9a
Add `AudioWorkletNode` and associated options.
yilinwei Nov 15, 2023
0099ad3
Add `Worklet` and `AudioWorklet`.
yilinwei Nov 15, 2023
e8b3650
Fix signature
yilinwei Nov 15, 2023
1178935
Add `AudioParamDescriptor`.
yilinwei Nov 15, 2023
fdb9aad
Add `defaultValue` for `AudioParamDescriptor`.
yilinwei Nov 15, 2023
c067de2
Make sure to extend `js.Object`.
yilinwei Nov 15, 2023
ba8f619
Add `AudioWorkletGlobalScope`.
yilinwei Nov 15, 2023
3e32f25
`AudioWorkletNode` should not be abstract.
yilinwei Nov 16, 2023
42275a7
Make `ReadOnlyMapLike` extend `js.Iterable`.
yilinwei Nov 16, 2023
0e90800
`self` does not yet exist within the `Worklet` contexts.
yilinwei Nov 16, 2023
f860eaa
Correct `ReadOnlyMapLike` signature `forEach`.
yilinwei Nov 16, 2023
b548118
Add docs.
zainab-ali Dec 2, 2023
2d1f240
Add docs.
zainab-ali Dec 2, 2023
f7adab3
Doc improvements.
zainab-ali Dec 18, 2023
56d513b
Add js.native annotation to AudioParamAutomationRate.
zainab-ali Dec 18, 2023
6781565
More docs.
zainab-ali Dec 18, 2023
7d6eb4e
Add js.native annotation to AudioTimestamp.
zainab-ali Dec 18, 2023
d159170
Correct type of params for AudioWorkletProcessor.
zainab-ali Dec 18, 2023
3bac38d
WorkletOptions should extend js.Object.
zainab-ali Dec 18, 2023
e32a80c
Add MediaRecorder and options.
zainab-ali Dec 18, 2023
c221e2b
Correct scaladoc.
zainab-ali Dec 18, 2023
824092d
Api reports.
zainab-ali Dec 18, 2023
e637830
AudioWorkletGlobalScope should be an abstract class.
zainab-ali Dec 29, 2023
314c67b
AudioScheduledSourceNode should be an abstract class.
zainab-ali Dec 29, 2023
9923b6b
MediaElementAudioSourceNode mediaElement should be a def.
zainab-ali Dec 29, 2023
98af177
Regenerate api reports.
zainab-ali Dec 29, 2023
18a6f7d
Add docs for ReadOnlyMapLike.
zainab-ali Dec 29, 2023
df8e9cf
Reformat doc comments.
zainab-ali Jan 28, 2024
523266a
Remove redundant comment.
zainab-ali Jan 28, 2024
07dcf43
Remove channelCount, channelCountMode and channelInterpretation.
zainab-ali Jan 28, 2024
b3a694e
Refactor enums for Scala 3.
zainab-ali Jan 28, 2024
e305129
Regenerate API reports.
zainab-ali Jan 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Doc improvements.
  • Loading branch information
zainab-ali committed Dec 18, 2023
commit f7adab353e500578f6f77981f57b2998efb3dbfa
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ trait AudioBufferSourceNodeOptions extends js.Object {
/** An instance of [[AudioBuffer]] to be played. */
var buffer: js.UndefOr[AudioBuffer] = js.undefined

/** Indicates whether the audio should play in a loop. The default is false. If the loop is dynamically
* modified during playback, the new value will take effect on the next processing block of audio.
/** Indicates whether the audio should play in a loop. The default is false. If the loop is dynamically modified
* during playback, the new value will take effect on the next processing block of audio.
*/
var loop: js.UndefOr[Boolean] = js.undefined

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ package org.scalajs.dom
import scala.scalajs.js

@js.native
/** A parent interface for several types of audio source node
* interfaces which share the ability to be started and stopped,
* optionally at specified times. Unless stated otherwise, nodes
* based upon AudioScheduledSourceNode output silence when not
* playing (that is, before start() is called and after stop() is
* called). Silence is represented, as always, by a stream of samples
* with the value zero (0).
/** A parent interface for several types of audio source node interfaces which share the ability to be started and
* stopped, optionally at specified times. Unless stated otherwise, nodes based upon AudioScheduledSourceNode output
* silence when not playing (that is, before start() is called and after stop() is called). Silence is represented, as
* always, by a stream of samples with the value zero (0).
*/
trait AudioScheduledSourceNode extends AudioNode {

Expand Down
10 changes: 10 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/AudioTimestamp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ package org.scalajs.dom
import scala.scalajs.js

trait AudioTimestamp extends js.Object {

/** The time of the sample frame currently being rendered by the audio output device (i.e., output audio stream
* position), in the same units and origin as the context's AudioContext.currentTime. Basically, this is the time
* after the audio context was first created.
*/
var contextTime: Double

/** An estimation of the moment when the sample frame corresponding to the stored contextTime value was rendered by
* the audio output device, in the same units and origin as performance.now(). This is the time after the document
* containing the audio context was first rendered.
*/
var performanceTime: Double
}
8 changes: 8 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/AudioWorklet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ package org.scalajs.dom
import scala.scalajs.js
import scala.scalajs.js.annotation._

/** Used to supply custom audio processing scripts that execute in a separate thread to provide very low latency audio
* processing.
*
* The worklet's code is run in the AudioWorkletGlobalScope global execution context, using a separate Web Audio thread
* which is shared by the worklet and other audio nodes.
*
* Access the audio context's instance of AudioWorklet through the BaseAudioContext.audioWorklet property.
*/
@JSGlobal
@js.native
abstract class AudioWorklet extends Worklet {}
19 changes: 19 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/AudioWorkletGlobalScope.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,34 @@ package org.scalajs.dom
import scala.scalajs.js
import scala.scalajs.js.annotation._

/** Represents a global execution context for user-supplied code, which defines custom AudioWorkletProcessor-derived
* classes.
*
* Each BaseAudioContext has a single AudioWorklet available under the audioWorklet property, which runs its code in a
* single AudioWorkletGlobalScope.
*
* As the global execution context is shared across the current BaseAudioContext, it's possible to define any other
* variables and perform any actions allowed in worklets — apart from defining AudioWorkletProcessor derived classes.
*/
@js.native
trait AudioWorkletGlobalScope extends WorkletGlobalScope {

/** Returns an integer that represents the ever-increasing current sample-frame of the audio block being processed. It
* is incremented by 128 (the size of a render quantum) after the processing of each audio block.
*/
def currentFrame: Int

/** Returns a double that represents the ever-increasing context time of the audio block being processed. It is equal
* to the currentTime property of the BaseAudioContext the worklet belongs to.
*/
def currentTime: Double

/** Returns a float that represents the sample rate of the associated BaseAudioContext. */
def sampleRate: Float

/** Registers a class derived from the AudioWorkletProcessor interface. The class can then be used by creating an
* AudioWorkletNode, providing its registered name.
*/
def registerProcessor(name: String, processorCtor: js.Dynamic): Unit = js.native
}

Expand Down