Android: AudioRecord Class Problem: Callback is never called

前端 未结 4 614
南旧
南旧 2020-12-29 05:19

My Android Java Application needs to record audio data into the RAM and process it. This is why I use the class \"AudioRecord\" and not the \"MediaRecorder\" (records only t

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-29 06:11

    I believe the problem is that you still need to do the read loop. If you setup callbacks, they will fire when you've read the number of frames that you specify for the callbacks. But you still need to do the reads. I've tried this and the callbacks get called just fine. Setting up a marker causes a callback when that number of frames has been read since the start of recording. In other words, you could set the marker far into the future, after many of your reads, and it will fire then. You can set the period to some bigger number of frames and that callback will fire every time that number of frames has been read. I think they do this so you can do low-level processing of the raw data in a tight loop, then every so often your callback can do summary-level processing. You could use the marker to make it easier to decide when to stop recording (instead of counting in the read loop).

提交回复
热议问题