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
Add docs.
  • Loading branch information
zainab-ali committed Dec 2, 2023
commit b548118df40d7ac195cc98b2d2d687bb78a180eb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,58 @@ package org.scalajs.dom
import scala.scalajs.js

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.
*/
var loop: js.UndefOr[Boolean] = js.undefined

/** An optional value in seconds, where looping should begin if the loop attribute is true. The default is 0. It's
* sensible to set this to a value between 0 and the duration of the buffer. If loopStart is less than 0, looping
* will begin at 0. If loopStart is greater than the duration of the buffer, looping will begin at the end of the
* buffer. This attribute is converted to an exact sample frame offset within the buffer, by multiplying by the
* buffer's sample rate and rounding to the nearest integer value. Thus, its behavior is independent of the value of
* the playbackRate parameter.
*/
var loopStart: js.UndefOr[Double] = js.undefined

/** An optional value, in seconds, where looping should end if the loop attribute is true. The default is 0. Its value
* is exclusive to the content of the loop. The sample frames, comprising the loop, run from the values loopStart to
* loopEnd-(1/sampleRate). It's sensible to set this to a value between 0 and the duration of the buffer. If loopEnd
* is less than 0, looping will end at 0. If loopEnd is greater than the duration of the buffer, looping will end at
* the end of the buffer. This attribute is converted to an exact sample frame offset within the buffer, by
* multiplying by the buffer's sample rate and rounding to the nearest integer value. Thus, its behavior is
* independent of the value of the playbackRate parameter.
*/
var loopEnd: js.UndefOr[Double] = js.undefined

/** A value in cents to modulate the speed of audio stream rendering. Its nominal range is (-∞ to +∞). The default is
* 0.
*/
var detune: js.UndefOr[Double] = js.undefined

/** The speed at which to render the audio stream. Its default value is 1. This parameter is k-rate. This is a
* compound parameter with detune. Its nominal range is (-∞ to +∞).
*/
var playbackRate: js.UndefOr[Double] = js.undefined

/** Represents an integer used to determine how many channels are used when up-mixing and down-mixing connections to
* any inputs to the node. (See AudioNode.channelCount for more information.) Its usage and precise definition depend
* on the value of channelCountMode.
*/
var channelCount: js.UndefOr[Int] = js.undefined

/** Represents an enumerated value describing the way channels must be matched between the node's inputs and outputs.
* (See AudioNode.channelCountMode for more information including default values.)
*/
var channelCountMode: js.UndefOr[AudioNodeChannelCountMode] = js.undefined

/** Represents an enumerated value describing the meaning of the channels. This interpretation will define how audio
* up-mixing and down-mixing will happen. The possible values are "speakers" or "discrete". (See
* AudioNode.channelCountMode for more information including default values.)
*/
var channelInterpretation: js.UndefOr[AudioNodeChannelInterpretation] = js.undefined
}
7 changes: 5 additions & 2 deletions dom/src/main/scala/org/scalajs/dom/AudioContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import scala.scalajs.js.annotation._
@JSGlobal
class AudioContext extends BaseAudioContext {

// Returns the number of seconds of processing latency incurred by the AudioContext passing the audio from the AudioDestinationNode to the aud io subsystem.
/** Returns the number of seconds of processing latency incurred by the AudioContext passing the audio from the
* AudioDestinationNode to the audio subsystem.
*/
def baseLatency: Double = js.native

/** Returns an estimation of the output latency of the current audio context. */
Expand Down Expand Up @@ -57,6 +59,7 @@ class AudioContext extends BaseAudioContext {
/** Closes the audio context, releasing any system audio resources that it uses. */
def close(): js.Promise[Unit] = js.native

// TODO docs
/** Returns a new AudioTimestamp object containing two audio timestamp values relating to the current audio context.
*/
def getOutputTimestamp: AudioTimestamp = js.native
}
2 changes: 0 additions & 2 deletions dom/src/main/scala/org/scalajs/dom/AudioNode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ trait AudioNode extends EventTarget {

/** Represents an enumerated value describing the meaning of the channels. This interpretation will define how audio
* up-mixing and down-mixing will happen.
*
* The possible values are "speakers" or "discrete".
*/
var channelInterpretation: AudioNodeChannelInterpretation = js.native

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

@js.native
/** Represents an enumerated value describing the way channels must be matched between the AudioNode's inputs and
* outputs.
*/
sealed trait AudioNodeChannelCountMode extends js.Any

object AudioNodeChannelCountMode {

/** The number of channels is equal to the maximum number of channels of all connections. In this case, channelCount
* is ignored and only up-mixing happens.
*/
val max: AudioNodeChannelCountMode = "max".asInstanceOf[AudioNodeChannelCountMode]

/** The number of channels is equal to the maximum number of channels of all connections, clamped to the value of
* channelCount.
*/
val `clamped-max`: AudioNodeChannelCountMode = "clamped-max".asInstanceOf[AudioNodeChannelCountMode]

/** The number of channels is defined by the value of channelCount. */
val explicit: AudioNodeChannelCountMode = "explicit".asInstanceOf[AudioNodeChannelCountMode]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,21 @@ package org.scalajs.dom
import scala.scalajs.js

@js.native
/** Represents an enumerated value describing how input channels are mapped to output channels when the number of
* inputs/outputs is different. For example, this setting defines how a mono input will be up-mixed to a stereo or 5.1
* channel output, or how a quad channel input will be down-mixed to a stereo or mono output.
*/
sealed trait AudioNodeChannelInterpretation extends js.Any

object AudioNodeChannelInterpretation {

/** Use set of "standard" mappings for combinations of common speaker input and outputs setups (mono, stereo, quad,
* 5.1). For example, with this setting a mono channel input will output to both channels of a stereo output.
*/
val speakers: AudioNodeChannelInterpretation = "speakers".asInstanceOf[AudioNodeChannelInterpretation]

/** Input channels are mapped to output channels in order. If there are more inputs that outputs the additional inputs
* are dropped; if there are fewer than the unused outputs are silent.
*/
val discrete: AudioNodeChannelInterpretation = "discrete".asInstanceOf[AudioNodeChannelInterpretation]
}
2 changes: 2 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/AudioParam.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ trait AudioParam extends AudioNode {
/** Represents the initial value of the attributes as defined by the specific AudioNode creating the AudioParam. */
val defaultValue: Double = js.native

/** Represents the maximum possible value for the parameter's nominal (effective) range. */
val maxValue: Double = js.native

/** Represents the minimum possible value for the parameter's nominal (effective) range. */
val minValue: Double = js.native

/** Schedules an instant change to the value of the AudioParam at a precise time, as measured against
Expand Down
14 changes: 14 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/AudioParamDescriptor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,29 @@ package org.scalajs.dom

import scala.scalajs.js

/** Specifies properties for AudioParam objects.
*
* It is used to create custom AudioParams on an AudioWorkletNode. If the underlying AudioWorkletProcessor has a
* parameterDescriptors static getter, then the returned array of objects based on this dictionary is used internally
* by AudioWorkletNode constructor to populate its parameters property accordingly.
*/
trait AudioParamDescriptor extends js.Object {

/** The string which represents the name of the [[AudioParam]]. Under this name the [[AudioParam]] will be available
* in the parameters property of the node, and under this name the [[AudioWorkletProcessor#process]] method will
* acquire the calculated values of this [[AudioParam]].
*/
var name: String

/** Defaults to -3.4028235e38. */
var minValue: js.UndefOr[Double] = js.undefined

/** Defaults to 3.4028235e38. */
var maxValue: js.UndefOr[Double] = js.undefined

/** Represents initial value of the AudioParam. Defaults to 0. */
var defaultValue: js.UndefOr[Double] = js.undefined

/** Represents an automation rate of this AudioParam. Defaults to "a-rate". */
var automationRate: js.UndefOr[AudioParamAutomationRate] = js.undefined
}