如何写精华回答,获更多曝光?
发布
在安卓我可以类似以下代码从Mic上获取到音高并转为十二平均律
// 创建音频调度器
AudioDispatcher dispatcher = AudioDispatcherFactory.fromDefaultMicrophone(sampleRate, bufferSize);
PitchProcessor pitchProcessor = new PitchProcessor(PitchProcessor.Tuning.STANDARD, sampleRate, bufferSize, new PitchProcessor.PitchDetectionHandler() {
@Override
public void handlePitch(PitchDetectionResult result) {
float pitch = result.getPitch();
// 转换为十二平均律音高
}
});
dispatcher.addAudioProcessor(pitchProcessor);
请问,HarmonyOS的ArkTS该如何实现类似功能。先谢谢了。