Skip to content

gdzx/audiosource

Repository files navigation

Audio Source

Audio Source forwards Android microphone audio input to the PulseAudio daemon through ADB, so you can use your Android device as a USB microphone.

screenshot

Requirements

  • Device with at least Android 4.0 (API level 14), but fully tested only on Android 10 (API level 29) so your mileage may vary.
  • GNU/Linux machine with:
    • Android SDK Platform Tools (requires adb in PATH).
    • PulseAudio or PipeWire with PulseAudio support (requires pactl in PATH).
    • Python 3 (requires python3 in PATH).

Installation

Get it on F-Droid Get it on GitHub

On your Android device:

  1. Go to Settings > About phone then tap Build number 7 times to enable the Developer options menu.
  2. In Settings > System > Developer options enable USB debugging (Android Debug Bridge).
  3. Install the Audio Source Android app:

On your Linux PC:

  1. Download the audiosource client script from the latest release (look for a file named audiosource in the assets section).
  2. Open a terminal in the downloads directory (or cd into it).
  3. Then make the script executable with chmod a+x ./audiosource.

Usage

  1. Connect your Android device to your PC via a USB cable. (Note that wireless debugging should also work, at the cost of increased latency and jitter.)
  2. On your phone, allow USB debugging, if requested.
  3. In the terminal, run ./audiosource run. This starts Audio Source and immediately attempts to forward the microphone audio.
  4. On your phone, grant microphone/recording permissions, if requested.
  5. If the volume is too low, adjust it with ./audiosource volume 200% (replace 200% with the desired level). You will likely need a volume level higher than 100%.

Troubleshooting

If you encounter the adb not found error, it means that the adb command is either not installed or not in your system's PATH. On most distributions you can install it via the package manager:

# Arch Linux
$ pacman -S android-tools

# Debian/Ubuntu
$ apt install android-tools-adb

After installation, verify that it is working with adb --version, and re-run audiosource.

Common tips:

  • Ensure your phone is connected, USB debugging is enabled, and the PC is authorized (check your phone for a prompt to allow the connection).
  • Run adb devices to confirm your phone is detected (it should show a serial number and "device").
  • If no devices are found, try a different USB cable/port or try to re-enable USB debugging.

Multi-device

If you have multiple devices connected then you will have to specify the serial number of the device you would like to forward audio to. Device serial numbers can be found by running adb devices.

Then you can specify the serial number as an argument:

$ ./audiosource -s 1234 run

Or by setting the ANDROID_SERIAL environment variable:

$ ANDROID_SERIAL=1324 ./audiosource run

You can utilize job control to forward audio from multiple devices simultaneously as follows:

$ ./audiosource -s shiba run &  # press ENTER to regain control of your terminal
$ ./audiosource -s 192.168.1.188:39857 run

Build and install

Run ./gradlew tasks to list the available commands.

Debug

$ ./audiosource build
$ ./audiosource install

Release

  1. Generate a Java KeyStore:

    $ keytool -keystore /home/user/android.jks -genkey -alias release \
           -keyalg RSA -keysize 2048 -validity 30000
  2. Create keystore.properties in the project root directory containing:

    storeFile=/home/user/android.jks
    storePassword=STORE_PASS
    keyAlias=release
    keyPassword=KEY_PASS
  3. Build and install:

    $ export AUDIOSOURCE_PROFILE=release
    $ ./audiosource build
    $ ./audiosource install

Acknowledgement

sndcpy for the initial implementation of audio playback forwarding.

License

This project is licensed under the MIT license (LICENSE or http://opensource.org/licenses/MIT).

About

🎤 Use an Android device as a USB microphone

Topics

Resources

License

Stars

Watchers

Forks

Contributors