Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

31
LINES

< > BotCompany Repo | #1027050 // Android AudioRecord Test 2 [dev.]

JavaX source code (Android) [tags: use-pretranspiled] - run with: the app

Libraryless. Click here for Pure Java version (2194L/14K/51K).

1  
!7
2  
3  
import android.media.*;
4  
5  
static int bufferSize = 8192;
6  
7  
p {
8  
  print("Making recorder");
9  
  AudioRecord recorder = new AudioRecord.Builder()
10  
    .setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION)
11  
    .setAudioFormat(new AudioFormat.Builder()
12  
      .setEncoding(AudioFormat.ENCODING_PCM_16BIT)
13  
      .setSampleRate(16000)
14  
      .setChannelMask(AudioFormat.CHANNEL_IN_MONO)
15  
      .build())
16  
   .setBufferSizeInBytes(bufferSize)
17  
   .build();
18  
  print("Made recorder");
19  
  
20  
  recorder.startRecording();
21  
  print("Started recording");
22  
  
23  
  byte[] buf = new[bufferSize];
24  
  
25  
  while licensed {
26  
    printWithTime("Read bytes: " + recorder.read(buf, 0, l(buf), AudioRecord.READ_BLOCKING);
27  
  }
28  
  
29  
  recorder.release();
30  
  print("Released recorder");
31  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, mqqgnosmbjvj, odkhaoglnmdk, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027050
Snippet name: Android AudioRecord Test 2 [dev.]
Eternal ID of this version: #1027050/6
Text MD5: a4aada5138a5cb1a0214362b759c6210
Transpilation MD5: aac51bbf0431b8111f8fdfbf8da23ceb
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 13:02:43
Source code size: 780 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 218 / 320
Version history: 5 change(s)
Referenced in: [show references]