Loading files
adfe118f0This file is pinned to the selected release. Download the original to open it in your design tool.
Files from this revision, including CAD and LFS contents. Git history is not included.
Or in GitHub Desktop, choose File → Clone repository → URL and paste this address.
Public repositories can be cloned without signing in. For pushing, use your ThingAtlas username and a Git access token as the password.
git lfs install git clone https://thingatlas.com/git/-unclaimed/stack-chan-374381865.git
Includes Git history, branches, and Git LFS files. Clones the repository’s default branch, regardless of the version shown here.
import AudioOut from 'pins/audioout'
export type ToneProperty = {
volume?: number
}
export default class Tone {
volume: number
constructor(props: ToneProperty) {
this.volume = props.volume ?? 0.5
}
async tone(hz: number, duration: number, volume?: number): Promise<void> {
const audio = new AudioOut({
streams: 1,
sampleRate: 24000,
bitsPerSample: 16,
})
return new Promise((resolve) => {
audio.enqueue(0, AudioOut.Flush)
audio.enqueue(0, AudioOut.Volume, Math.round((volume ?? this.volume) * 256))
audio.enqueue(0, AudioOut.Tone, hz, (audio.sampleRate * duration) / 1000)
audio.enqueue(0, AudioOut.Callback, 1)
audio.start()
audio.callback = (_id) => {
audio.close()
resolve()
}
})
}
}
adfe118f0This file is pinned to the selected release. Download the original to open it in your design tool.