google / google/oboe

how to do live recording and playing.

Open
#1,457 12 comments 0 reactions 1 assignee Claimed by @jet-yangqs View on GitHub
Dominant language
C++
Stars
4.1k
Forks
639
Avg merge
2d 23h
Merged PRs (30d)
8

Description

I want to make a APP which can record the speaking of someone through mic phone and playing it through speaker of android device by modifying the liveEffect APP.

What I expected: recording the speaking of some body through mic phone and playing it through speaker Simultaneously.
What I got: it can not record human voice correctly. if I make a beep near the phone, the output audio of speaker is beep with feedback loop.(same Phenomenon with liveEffect APP)

my modifications include:
1. In liveEffectEngine, I ceate two streams, one for recording and another for playing.
2. I write two classes inherited from oboe::AudioStreamCallback with overrided onAudioReady function. I set these two onAudioReady functions as callback function of record and play stream respectively.
3. I set the callback peroid length to 20 ms by calling setFramesPerDataCallback() function. So these two streams will call their callback function each 20 ms(MilliSeconds);
4. I use a global char array buffer with size of 640 bytes to store the data(enough for 20 ms length in my case). The reading and writing operations of the buffer from recording and playing thread are protected by std::mutex;
5. each 20 ms, the record stream will call the callback function and write to the global buffer and the play stream will read from the global buffer.

why I can not get what I want from the design above? can you give me some advices?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.