Skip to main content

SoundSpectrum

caution

This service is experimental and may change in the future.

A microphone that analyzes the sound specturm

import { SoundSpectrum } from "@devicescript/core"

const soundSpectrum = new SoundSpectrum()

Registers

reading

The computed frequency data.

  • type: Register<Buffer> (packing format b)

  • track incoming values

import { SoundSpectrum } from "@devicescript/core"

const soundSpectrum = new SoundSpectrum()
// ...
soundSpectrum.reading.subscribe(async (value) => {
...
})
note

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

enabled

Turns on/off the micropohone.

  • type: Register<boolean> (packing format u8)

  • read and write

import { SoundSpectrum } from "@devicescript/core"

const soundSpectrum = new SoundSpectrum()
// ...
const value = await soundSpectrum.enabled.read()
await soundSpectrum.enabled.write(value)
  • track incoming values
import { SoundSpectrum } from "@devicescript/core"

const soundSpectrum = new SoundSpectrum()
// ...
soundSpectrum.enabled.subscribe(async (value) => {
...
})
note

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

fftPow2Size

The power of 2 used as the size of the FFT to be used to determine the frequency domain.

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

  • read and write

import { SoundSpectrum } from "@devicescript/core"

const soundSpectrum = new SoundSpectrum()
// ...
const value = await soundSpectrum.fftPow2Size.read()
await soundSpectrum.fftPow2Size.write(value)
  • track incoming values
import { SoundSpectrum } from "@devicescript/core"

const soundSpectrum = new SoundSpectrum()
// ...
soundSpectrum.fftPow2Size.subscribe(async (value) => {
...
})
note

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

minDecibels

The minimum power value in the scaling range for the FFT analysis data

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

  • read and write

import { SoundSpectrum } from "@devicescript/core"

const soundSpectrum = new SoundSpectrum()
// ...
const value = await soundSpectrum.minDecibels.read()
await soundSpectrum.minDecibels.write(value)
  • track incoming values
import { SoundSpectrum } from "@devicescript/core"

const soundSpectrum = new SoundSpectrum()
// ...
soundSpectrum.minDecibels.subscribe(async (value) => {
...
})
note

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

maxDecibels

The maximum power value in the scaling range for the FFT analysis data

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

  • read and write

import { SoundSpectrum } from "@devicescript/core"

const soundSpectrum = new SoundSpectrum()
// ...
const value = await soundSpectrum.maxDecibels.read()
await soundSpectrum.maxDecibels.write(value)
  • track incoming values
import { SoundSpectrum } from "@devicescript/core"

const soundSpectrum = new SoundSpectrum()
// ...
soundSpectrum.maxDecibels.subscribe(async (value) => {
...
})
note

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

smoothingTimeConstant

The averaging constant with the last analysis frame. If 0 is set, there is no averaging done, whereas a value of 1 means "overlap the previous and current buffer quite a lot while computing the value".

  • type: Register<number> (packing format u0.8)

  • read and write

import { SoundSpectrum } from "@devicescript/core"

const soundSpectrum = new SoundSpectrum()
// ...
const value = await soundSpectrum.smoothingTimeConstant.read()
await soundSpectrum.smoothingTimeConstant.write(value)
  • track incoming values
import { SoundSpectrum } from "@devicescript/core"

const soundSpectrum = new SoundSpectrum()
// ...
soundSpectrum.smoothingTimeConstant.subscribe(async (value) => {
...
})
note

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