UNPKG

pxt-common-packages

Version:
23 lines (20 loc) 576 B
namespace pxsim.input { export function soundLevel(): number { let b = microphoneState(); if (!b) return 0; b.setUsed(); return b.getLevel(); } export function onLoudSound(body: RefAction) { let b = microphoneState(); if (!b) return; b.setUsed(); pxtcore.registerWithDal(b.id, DAL.LEVEL_THRESHOLD_HIGH, body); } export function setLoudSoundThreshold(value: number) { let b = microphoneState(); if (!b) return; b.setUsed(); b.setHighThreshold(value); } }