Skip to content

Commit

Permalink
backup
Browse files Browse the repository at this point in the history
  • Loading branch information
yilinwei committed Jul 22, 2023
1 parent 4f524b8 commit 8b1d132
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.scalajs.dom

import scala.scalajs.js
import scala.scalajs.js.annotation._

/** AudioBufferSourceNode has no input and exactly one output. The number of channels in the output corresponds to the
* number of channels of the AudioBuffer that is set to the AudioBufferSourceNode.buffer property. If there is no
Expand All @@ -23,8 +24,10 @@ import scala.scalajs.js
* - Number of outputs: 1
* - Channel count: defined by the associated AudioBuffer
*/
@JSGlobal
@js.native
trait AudioBufferSourceNode extends AudioScheduledSourceNode {
class AudioBufferSourceNode(context: BaseAudioContext, options: AudioBufferSourceNodeOptions = js.native)
extends AudioScheduledSourceNode {

/** Is an AudioBuffer that defines the audio asset to be played, or when set to the value null, defines a single
* channel of silence.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available
* under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/
*
* Everything else is under the MIT License http://opensource.org/licenses/MIT
*/
package org.scalajs.dom

import scala.scalajs.js

trait AudioBufferSourceNodeOptions extends js.Object {
var buffer: js.UndefOr[AudioBuffer] = js.undefined
var loop: js.UndefOr[Boolean] = js.undefined
var loopStart: js.UndefOr[Double] = js.undefined
var loopEnd: js.UndefOr[Double] = js.undefined
var detune: js.UndefOr[Double] = js.undefined
var playbackRate: js.UndefOr[Double] = js.undefined
}

1 change: 0 additions & 1 deletion dom/src/main/scala/org/scalajs/dom/AudioContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ 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
def getOutputTimestamp: AudioTimestamp = js.native
}
4 changes: 2 additions & 2 deletions dom/src/main/scala/org/scalajs/dom/AudioNode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ trait AudioNode extends EventTarget {

/** Represents an enumerated value describing the way channels must be matched between the node's inputs and outputs.
*/
var channelCountMode: ChannelCountMode = js.native
var channelCountMode: AudioNodeChannelCountMode = js.native

/** 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: ChannelInterpretation = js.native
var channelInterpretation: AudioNodeChannelInterpretation = js.native

/** Allows us to connect one output of this node to one input of another node. */
def connect(audioNode: AudioNode): Unit = js.native
Expand Down
18 changes: 18 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/AudioNodeChannelCountMode.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available
* under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/
*
* Everything else is under the MIT License http://opensource.org/licenses/MIT
*/
package org.scalajs.dom

import scala.scalajs.js

@js.native
sealed trait AudioNodeChannelCountMode extends js.Any

object AudioNodeChannelCountMode {
val max: AudioNodeChannelCountMode = "max".asInstanceOf[AudioNodeChannelCountMode]
val `clamped-max`: AudioNodeChannelCountMode = "clamped-max".asInstanceOf[AudioNodeChannelCountMode]
val explicit: AudioNodeChannelCountMode = "explicit".asInstanceOf[AudioNodeChannelCountMode]

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

@js.native
sealed trait ChannelCountMode extends js.Any

object ChannelCountMode {
val max: ChannelCountMode = "max".asInstanceOf[ChannelCountMode]
val `clamped-max`: ChannelCountMode = "clamped-max".asInstanceOf[ChannelCountMode]
val explicit: ChannelCountMode = "explicit".asInstanceOf[ChannelCountMode]
sealed trait AudioNodeChannelInterpretation extends js.Any

object AudioNodeChannelInterpretation {
val speakers: AudioNodeChannelInterpretation = "speakers".asInstanceOf[AudioNodeChannelInterpretation]
val discrete: AudioNodeChannelInterpretation = "discrete".asInstanceOf[AudioNodeChannelInterpretation]
}
9 changes: 6 additions & 3 deletions dom/src/main/scala/org/scalajs/dom/BaseAudioContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ package org.scalajs.dom

import scala.scalajs.js

/** The BaseAudioContext interface of the Web Audio API acts as a base definition for online and offline audio-processing graphs, as represented by AudioContext and OfflineAudioContext respectively. You wouldn't use BaseAudioContext directly — you'd use its features via one of these two inheriting interfaces.
A BaseAudioContext can be a target of events, therefore it implements the EventTarget interface. */
/** The BaseAudioContext interface of the Web Audio API acts as a base definition for online and offline
* audio-processing graphs, as represented by AudioContext and OfflineAudioContext respectively. You wouldn't use
* BaseAudioContext directly — you'd use its features via one of these two inheriting interfaces.
*
* A BaseAudioContext can be a target of events, therefore it implements the EventTarget interface.
*/
@js.native
trait BaseAudioContext extends EventTarget {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scala.scalajs.js
@js.native
trait ConstantSourceNode extends AudioScheduledSourceNode {

// TODO
// TODO
val offset: AudioParam = js.native

}
4 changes: 3 additions & 1 deletion dom/src/main/scala/org/scalajs/dom/GainNode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.scalajs.dom

import scala.scalajs.js
import scala.scalajs.js.annotation._

/** The GainNode interface represents a change in volume. It is an AudioNode audio-processing module that causes a given
* gain to be applied to the input data before its propagation to the output. A GainNode always has exactly one input
Expand All @@ -23,8 +24,9 @@ import scala.scalajs.js
* - Channel count: 2 (not used in the default count mode)
* - Channel interpretation: "speakers"
*/
@JSGlobal
@js.native
trait GainNode extends AudioNode {
class GainNode(context: BaseAudioContext, options: GainNodeOptions = js.native) extends AudioNode {

/** Is an a-rate AudioParam representing the amount of gain to apply. */
val gain: AudioParam = js.native
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ package org.scalajs.dom

import scala.scalajs.js

@js.native
sealed trait ChannelInterpretation extends js.Any

object ChannelInterpretation {
val speakers: ChannelInterpretation = "speakers".asInstanceOf[ChannelInterpretation]
val discrete: ChannelInterpretation = "discrete".asInstanceOf[ChannelInterpretation]
trait GainNodeOptions extends js.Object {
var gain: js.UndefOr[Double] = js.undefined
var channelCount: js.UndefOr[Int] = js.undefined
var channelCountMode: js.UndefOr[AudioNodeChannelCountMode] = js.undefined
var channelInterpretation: js.UndefOr[AudioNodeChannelInterpretation] = js.undefined
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import scala.scalajs.js.annotation._
*/
@JSGlobal
@js.native
class MediaElementAudioSourceNode(ctx: BaseAudioContext, options: MediaElementAudioSourceNodeOptions) extends AudioNode {
class MediaElementAudioSourceNode(ctx: BaseAudioContext, options: MediaElementAudioSourceNodeOptions)
extends AudioNode {
val mediaElement: HTMLMediaElement = js.native
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import scala.scalajs.js
trait MediaElementAudioSourceNodeOptions extends js.Object {
var mediaElement: HTMLMediaElement
var channelCount: js.UndefOr[Int] = js.undefined
var channelCountMode: js.UndefOr[ChannelCountMode] = js.undefined
var channelInterpretation: js.UndefOr[ChannelInterpretation] = js.undefined
var channelCountMode: js.UndefOr[AudioNodeChannelCountMode] = js.undefined
var channelInterpretation: js.UndefOr[AudioNodeChannelInterpretation] = js.undefined
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ 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.
def suspend(suspendTime: Double): js.Promise[Unit] = js.native

Expand Down

0 comments on commit 8b1d132

Please sign in to comment.