Skip to content

Commit

Permalink
Switch back to using traits for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
yilinwei committed Sep 18, 2023
1 parent b44eaa8 commit 2aaf2ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 7 additions & 3 deletions dom/src/main/scala/org/scalajs/dom/GainNode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
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 @@ -24,10 +23,15 @@ import scala.scalajs.js.annotation._
* - Channel count: 2 (not used in the default count mode)
* - Channel interpretation: "speakers"
*/
@JSGlobal
@js.native
class GainNode(context: BaseAudioContext, options: GainNodeOptions = js.native) extends AudioNode {
trait GainNode extends AudioNode {

/** Is an a-rate AudioParam representing the amount of gain to apply. */
val gain: AudioParam = js.native
}

object GainNode {

def apply(context: BaseAudioContext, options: js.UndefOr[GainNodeOptions] = js.undefined): GainNode =
js.Dynamic.newInstance(js.Dynamic.global.GainNode)(context, options).asInstanceOf[GainNode]
}
9 changes: 6 additions & 3 deletions dom/src/main/scala/org/scalajs/dom/OscillatorNode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package org.scalajs.dom

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

/** The OscillatorNode interface represents a periodic waveform, like a sine wave. It is an AudioNode audio-processing
* module that causes a given frequency of sine wave to be created — in effect, a constant tone.
Expand All @@ -20,9 +19,8 @@ import scala.scalajs.js.annotation._
* - Channel count: 2 (not used in the default count mode)
* - Channel interpretation: speakers
*/
@JSGlobal
@js.native
class OscillatorNode(context: BaseAudioContext, options: OscillatorNodeOptions = js.native)
trait OscillatorNode
extends AudioScheduledSourceNode {

/** An a-rate AudioParam representing the frequency of oscillation in hertz (though the AudioParam returned is
Expand All @@ -45,3 +43,8 @@ class OscillatorNode(context: BaseAudioContext, options: OscillatorNodeOptions =
*/
def setPeriodicWave(wave: PeriodicWave): Unit = js.native
}

object OscillatorNode {
def apply(context: BaseAudioContext, options: js.UndefOr[OscillatorNodeOptions] = js.undefined): GainNode =
js.Dynamic.newInstance(js.Dynamic.global.GainNode)(context, options).asInstanceOf[GainNode]
}

0 comments on commit 2aaf2ed

Please sign in to comment.