Libraryless. Click here for Pure Java version (5280L/35K/120K).
!7 set flag Android. set flag AndroidOnly. set flag NoAWT. import android.media.*; static int bufferSize = 8192; // raspi home, X20 static LS ips = ll("192.168.2.165", "192.168.43.244"); static AudioRecord recorder; static new L<StefansOS_ConnectToServer> senders; p { for (S ip : ips) { print("Connecting to " + ip); new StefansOS_ConnectToServer sender; sender.server = ip; sender.start(); senders.add(sender); } print("Making recorder"); recorder = new AudioRecord.Builder() .setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION) .setAudioFormat(new AudioFormat.Builder() .setEncoding(AudioFormat.ENCODING_PCM_16BIT) .setSampleRate(16000) .setChannelMask(AudioFormat.CHANNEL_IN_MONO) .build()) .setBufferSizeInBytes(bufferSize) .build(); print("Made recorder"); recorder.startRecording(); print("Started recording"); byte[] buf = new[bufferSize]; while licensed { printWithTime("Read bytes: " + recorder.read(buf, 0, l(buf), AudioRecord.READ_BLOCKING); S line = "audio: " + base64(buf); for (StefansOS_ConnectToServer sender : senders) pcall { sender.sendLine(line); } } /*recorder.release(); print("Released recorder");*/ } svoid cleanMeUp { if (recorder != null) recorder.release(); dispose senders; }
Began life as a copy of #1027051
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027054 |
Snippet name: | Android Send Audio To Raspi v1 [works, but doesn't seem to use Bluetooth headset] |
Eternal ID of this version: | #1027054/1 |
Text MD5: | 11f8aba7ac51a446c109919c722d23fb |
Transpilation MD5: | d522c111328a4adeea16b14ec092565b |
Author: | stefan |
Category: | javax / android |
Type: | JavaX source code (Android) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-02-15 14:23:39 |
Source code size: | 1403 bytes / 57 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 283 / 337 |
Referenced in: | [show references] |