SoundRecorderWithPlayback
caution
This service is experimental and may change in the future.
A record and replay module. You can record a few seconds of audio and play it back.
import { SoundRecorderWithPlayback } from "@devicescript/core"
const soundRecorderWithPlayback = new SoundRecorderWithPlayback()
Commands
play
Replay recorded audio.
soundRecorderWithPlayback.play(): Promise<void>
record
Record audio for N milliseconds.
soundRecorderWithPlayback.record(duration: number): Promise<void>
cancel
Cancel record, the time
register will be updated by already cached data.
soundRecorderWithPlayback.cancel(): Promise<void>
Registers
status
Indicate the current status
type:
Register<number>
(packing formatu8
)read only
import { SoundRecorderWithPlayback } from "@devicescript/core"
const soundRecorderWithPlayback = new SoundRecorderWithPlayback()
// ...
const value = await soundRecorderWithPlayback.status.read()
- track incoming values
import { SoundRecorderWithPlayback } from "@devicescript/core"
const soundRecorderWithPlayback = new SoundRecorderWithPlayback()
// ...
soundRecorderWithPlayback.status.subscribe(async (value) => {
...
})
note
write
and read
will block until a server is bound to the client.
time
Milliseconds of audio recorded.
type:
Register<number>
(packing formatu16
)read only
import { SoundRecorderWithPlayback } from "@devicescript/core"
const soundRecorderWithPlayback = new SoundRecorderWithPlayback()
// ...
const value = await soundRecorderWithPlayback.time.read()
- track incoming values
import { SoundRecorderWithPlayback } from "@devicescript/core"
const soundRecorderWithPlayback = new SoundRecorderWithPlayback()
// ...
soundRecorderWithPlayback.time.subscribe(async (value) => {
...
})
note
write
and read
will block until a server is bound to the client.
intensity
Playback volume control
type:
Register<number>
(packing formatu0.8
)optional: this register may not be implemented
read and write
import { SoundRecorderWithPlayback } from "@devicescript/core"
const soundRecorderWithPlayback = new SoundRecorderWithPlayback()
// ...
const value = await soundRecorderWithPlayback.intensity.read()
await soundRecorderWithPlayback.intensity.write(value)
- track incoming values
import { SoundRecorderWithPlayback } from "@devicescript/core"
const soundRecorderWithPlayback = new SoundRecorderWithPlayback()
// ...
soundRecorderWithPlayback.intensity.subscribe(async (value) => {
...
})
note
write
and read
will block until a server is bound to the client.