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
More docs.
  • Loading branch information
zainab-ali committed Dec 18, 2023
commit 67815654b62ab59f176b2d6ebab72a1fff13063c
3 changes: 3 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/AudioWorkletNode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class AudioWorkletNode(context: BaseAudioContext, name: String, options: AudioWo
*/
val parameters: AudioParamMap = js.native

/** Fires when the underlying [[AudioWorkletProcessor]] behind the node throws an exception in its constructor, the
* process method, or any user-defined class method.
*/
var onprocessorerror: js.Function1[Event, _] = js.native

}
11 changes: 11 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/AudioWorkletNodeOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ trait AudioWorkletNodeOptions extends js.Object {

/** The value to initialize the [[AudioNode#numberOfOutputs]] property. Defaults to 1. */
var numberOfOutputs: js.UndefOr[Int] = js.undefined

/** An array defining the number of channels for each output. For example, outputChannelCount: [n, m] specifies the
* number of channels in the first output to be n and the second output to be m. The array length must match
* numberOfOutputs.
*/
var outputChannelCount: js.UndefOr[js.Array[Int]] = js.undefined

/** An object containing the initial values of custom AudioParam objects on this node (in its parameters property),
* with key being the name of a custom parameter and value being its initial value.
*/
var parameterData: js.UndefOr[js.Object] = js.undefined

/** Any additional data that can be used for custom initialization of the underlying AudioWorkletProcessor. */
var processorOptions: js.UndefOr[js.Any] = js.undefined
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ trait AudioWorkletProcessorOptions extends js.Object {

/** The value to initialize the [[AudioNode#numberOfOutputs]] property. Defaults to 1. */
var numberOfOutputs: Int

/** An array defining the number of channels for each output. For example, outputChannelCount: [n, m] specifies the
* number of channels in the first output to be n and the second output to be m. The array length must match
* numberOfOutputs.
*/
var outputChannelCount: js.Array[Int]

/** An object containing the initial values of custom AudioParam objects on this node (in its parameters property),
* with key being the name of a custom parameter and value being its initial value.
*/
var parameterData: js.UndefOr[js.Object] = js.undefined

/** Any additional data that can be used for custom initialization of the underlying AudioWorkletProcessor. */
var processorOptions: js.UndefOr[js.Any] = js.undefined
}
5 changes: 4 additions & 1 deletion dom/src/main/scala/org/scalajs/dom/BlobEvent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package org.scalajs.dom
import scala.scalajs.js
import scala.scalajs.js.annotation._

/** The AnimationEvent interface represents events providing information related to animations. */
/** The BlobEvent interface represents events associated with a Blob. These blobs are typically, but not necessarily,
* associated with media content.
*/
@JSGlobal
@js.native
class BlobEvent(typeArg: String, init: BlobEventInit) extends Event(typeArg, init) {
Expand All @@ -12,5 +14,6 @@ class BlobEvent(typeArg: String, init: BlobEventInit) extends Event(typeArg, ini
this("dataavailable", init)
}

/** Represents a Blob associated with the event. */
def data: Blob = js.native
}
2 changes: 2 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/BlobEventInit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ import scala.scalajs.js

@js.native
trait BlobEventInit extends EventInit {

/** The Blob associated with the event. */
var data: Blob
}
9 changes: 8 additions & 1 deletion dom/src/main/scala/org/scalajs/dom/ConstantSourceNode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ import scala.scalajs.js.annotation._

@JSGlobal
@js.native
/** Represents an audio source (based upon AudioScheduledSourceNode) whose output is single unchanging value. This makes
* it useful for cases in which you need a constant value coming in from an audio source. In addition, it can be used
* like a constructible AudioParam by automating the value of its offset or by connecting another node to it; see
* Controlling multiple parameters with ConstantSourceNode.
*/
class ConstantSourceNode(context: BaseAudioContext, options: ConstantSourceNodeOptions = js.native)
extends AudioScheduledSourceNode {

// TODO
/** Returns a AudioParam object indicating the numeric a-rate value which is always returned by the source when asked
* for the next sample.
*/
val offset: AudioParam = js.native

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@ package org.scalajs.dom
import scala.scalajs.js

trait ConstantSourceNodeOptions extends js.Object {

/** A read-only AudioParam specifying the constant value generated by the source. The default is 1.0. The normal range
* is -1.0 to 1.0, but the value can be anywhere in the range from -Infinity to +Infinity.
*/
var offset: js.UndefOr[Double] = js.undefined
}
16 changes: 16 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/GainNodeOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,24 @@ package org.scalajs.dom
import scala.scalajs.js

trait GainNodeOptions extends js.Object {

/** The amount of gain to apply. This parameter is a- rate and it's nominal range is (-∞,+∞). The default is 1 */
var gain: 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
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,24 @@ package org.scalajs.dom
import scala.scalajs.js

trait MediaElementAudioSourceNodeOptions extends js.Object {

/** An HTMLMediaElement that will be used as the source for the audio. */
var mediaElement: HTMLMediaElement

/** 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

/** Describes 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

/** Describes 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.channelInterpretation for more
* information including default values.)
*/
var channelInterpretation: js.UndefOr[AudioNodeChannelInterpretation] = js.undefined
}
3 changes: 2 additions & 1 deletion dom/src/main/scala/org/scalajs/dom/OfflineAudioContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class OfflineAudioContext(numOfChannels: Int, length: Int, sampleRate: Int) exte
*/
def startRendering(): js.Promise[AudioBuffer] = js.native

// Schedules a suspension of the time progression in the audio context at the specified time and returns a promise.
/** Schedules a suspension of the time progression in the audio context at the specified time and returns a promise.
*/
def suspend(suspendTime: Double): js.Promise[Unit] = js.native

}
24 changes: 24 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/OscillatorNodeOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,35 @@ package org.scalajs.dom
import scala.scalajs.js

trait OscillatorNodeOptions extends js.Object {

/** The shape of the wave produced by the node. Valid values are 'sine', 'square', 'sawtooth', 'triangle' and
* 'custom'. The default is 'sine'.
*/
var `type`: js.UndefOr[OscillatorNodeType] = js.undefined

/** A detuning value (in cents) which will offset the frequency by the given amount. Its default is 0. */
var detune: js.UndefOr[Double] = js.undefined

/** The frequency (in hertz) of the periodic waveform. Its default is 440. */
var frequency: js.UndefOr[Double] = js.undefined

/** An arbitrary period waveform described by a PeriodicWave object. */
var periodicWave: js.UndefOr[PeriodicWave] = 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
}
12 changes: 12 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/OscillatorNodeType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,21 @@ import scala.scalajs.js
sealed trait OscillatorNodeType extends js.Any

object OscillatorNodeType {

/** A sine wave. This is the default value. */
val sine: OscillatorNodeType = "sine".asInstanceOf[OscillatorNodeType]

/** A square wave with a duty cycle of 0.5; that is, the signal is "high" for half of each period. */
val square: OscillatorNodeType = "square".asInstanceOf[OscillatorNodeType]

/** A sawtooth wave. */
val sawtooth: OscillatorNodeType = "sawtooth".asInstanceOf[OscillatorNodeType]

/** A triangle wave. */
val triangle: OscillatorNodeType = "triangle".asInstanceOf[OscillatorNodeType]

/** A custom waveform. You never set type to custom manually; instead, use the setPeriodicWave() method to provide the
* data representing the waveform. Doing so automatically sets the type to custom.
*/
val custom: OscillatorNodeType = "custom".asInstanceOf[OscillatorNodeType]
}
8 changes: 8 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/Worklet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ import scala.scalajs.js.annotation._

@JSGlobal
@js.native
/** The Worklet interface is a lightweight version of Web Workers and gives developers access to low-level parts of the
* rendering pipeline.
*/
abstract class Worklet extends js.Object {

/** loads the module in the given JavaScript file and adds it to the current Worklet.
* @param moduleURL
* A String containing the URL of a JavaScript file with the module to add.
*/
def addModule(moduleURL: String, options: WorkletOptions = js.native): js.Promise[Unit] = js.native
}
3 changes: 3 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/WorkletGlobalScope.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ package org.scalajs.dom
import scala.scalajs.js

@js.native
/** An abstract class that specific worklet scope classes inherit from. Each WorkletGlobalScope defines a new global
* environment.
*/
trait WorkletGlobalScope extends js.Object {}