rom1v / sndcpy

Android audio forwarding (scrcpy, but for audio)
MIT License
3.25k stars 297 forks source link

miccpy? #264

Closed ali80 closed 1 year ago

ali80 commented 1 year ago

is there a way to share only the microphone though this and use android phone as a wireless microphone?

rom1v commented 1 year ago

It's theoretically possible.

Take the current master branch of scrcpy, and apply this patch:

diff --git a/server/src/main/java/com/genymobile/scrcpy/AudioCapture.java b/server/src/main/java/com/genymobile/scrcpy/AudioCapture.java
index 9228e3d71..b5bc67b39 100644
--- a/server/src/main/java/com/genymobile/scrcpy/AudioCapture.java
+++ b/server/src/main/java/com/genymobile/scrcpy/AudioCapture.java
@@ -50,7 +50,7 @@ public final class AudioCapture {
             // On older APIs, Workarounds.fillAppInfo() must be called beforehand
             builder.setContext(FakeContext.get());
         }
-        builder.setAudioSource(MediaRecorder.AudioSource.REMOTE_SUBMIX);
+        builder.setAudioSource(MediaRecorder.AudioSource.MIC);
         builder.setAudioFormat(createAudioFormat());
         int minBufferSize = AudioRecord.getMinBufferSize(SAMPLE_RATE, CHANNEL_CONFIG, FORMAT);
         // This buffer size does not impact latency

Then what is captured by the device microphone is played on the computer.