The Speaker
class encapsulates an speaker for a scene. Old class name is AudioSource
.
Inherits From : SceneObjectBase
//============================================================================ // The following example demonstrates how to set a Speaker's volume, // using a slow sawtooth shaped signal based on 'Time.ms'. // // Project setup: // - Add a Speaker to the scene, with the name 'speaker0' //============================================================================ // Load in the required modules const Reactive = require('Reactive'); const Scene = require('Scene'); const Time = require('Time'); (async function () { // Enables async/await in JS [part 1] // Locate the Speaker in the scene const speaker = await Scene.root.findFirst('speaker0'); // Set its volume from a sawtooth shaped signal based on `Time.ms` speaker.volume = Time.ms.div(Reactive.val(100)).mod(Reactive.val(100)). div(100); })(); // Enables async/await in JS [part 2]
Property | Description |
---|---|
volume | (get) volume: ScalarSignal Specifies the volume of the speaker in the range of [0.0, 1.0]. Note: To access this property you need to enable the AudioSourceVolume API capability. |
volume | (get) volume: ScalarSignal Specifies the volume of the speaker in the range of [0.0, 1.0]. Note: To access this property you need to enable the AudioSourceVolume API capability. |
This module exposes no methods.