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

33
LINES

< > BotCompany Repo | #1009769 // Swing: Record audio to .wav, CD quality mono [WORKS]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 114K of libraries. Click here for Pure Java version (2509L/18K).

1  
!7
2  
3  
static JButton btn;
4  
static Flag flag; // stop flag
5  
6  
static AudioFormat format;
7  
8  
p {
9  
  format = javaSound_monoCDQuality°;
10  
  swing {
11  
    showControls(jcenteredline(btn = jbutton("Start", f btn)));
12  
  }
13  
}
14  
15  
svoid btn {
16  
  if (flag == null || flag.isUp()) start(); else stop();
17  
}
18  
19  
svoid start ctex {
20  
  setText(btn, "Stop");
21  
  flag = new Flag;
22  
  final File wavFile = countTillNewFile(prepareProgramFile("recorded-"), ".wav");
23  
  thread {
24  
    captureAudioToWAV(format, wavFile, flag);
25  
    print(wavFile);
26  
    print("Actually done. " + l(wavFile) + " bytes");
27  
  }
28  
}
29  
30  
svoid stop {
31  
  setText(btn, "Start");
32  
  flag.raise();
33  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1009769
Snippet name: Swing: Record audio to .wav, CD quality mono [WORKS]
Eternal ID of this version: #1009769/14
Text MD5: bf2244c677dcd9b0cba35224238f6e13
Transpilation MD5: 86b1e6184f57620b562d98ceb959af22
Author: stefan
Category: javax / audio
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-16 17:16:58
Source code size: 648 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 370 / 912
Version history: 13 change(s)
Referenced in: [show references]