Skip to main content

Microphone

caution

This service is experimental and may change in the future.

A single-channel microphone.

import { Microphone } from "@devicescript/core"

const microphone = new Microphone()

Registers

samplingPeriod

Get or set microphone sampling period. Sampling rate is 1_000_000 / sampling_period Hz.

  • type: Register<number> (packing format u32)

  • read and write

import { Microphone } from "@devicescript/core"

const microphone = new Microphone()
// ...
const value = await microphone.samplingPeriod.read()
await microphone.samplingPeriod.write(value)
  • track incoming values
import { Microphone } from "@devicescript/core"

const microphone = new Microphone()
// ...
microphone.samplingPeriod.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.