1 | !7 |
2 | |
3 | cmodule AudioInput > DynPrintLog { |
4 | int bufSize = 40960; |
5 | transient recordToAudioListeners_AudioLoop loop; |
6 | transient SimpleLiveValue<Float> lvVolume = floatLiveValue(); // in percent |
7 | transient L<VF1<short[]>> audioListeners = synchroList(); |
8 | |
9 | visualize { |
10 | ret centerAndSouthWithMargins(super.visualize(), |
11 | jCenteredLine(jLiveValueLabel(mapLiveValue(func(float volume) -> S { "Volume: " + iround(volume) + " %" }, S, lvVolume)))); |
12 | } |
13 | |
14 | start { |
15 | ownTimer(loop = recordToAudioListeners(audioListeners, bufSize, lvVolume)).start(); |
16 | JComponent trayIcon = jMinWidth(16, jVerticalGreenBar(lvVolume, max := 100)); |
17 | componentPopupMenuItem(trayIcon, "Audio Input", r { dm_showModule(module()) }); |
18 | dm_setTrayIcon(trayIcon); |
19 | } |
20 | |
21 | // hold audio listeners during reload |
22 | |
23 | O _getReloadData() { ret audioListeners; } |
24 | void _setReloadData(L<VF1<short[]>> listeners) { addAll(audioListeners, listeners); } |
25 | |
26 | // API |
27 | |
28 | void addAudioListener(VF1<short[]> l) { audioListeners.add(l); } |
29 | void removeAudioListener(VF1<short[]> l) { audioListeners.remove(l); } |
30 | |
31 | AudioFormat getAudioFormat() { ret javaSound_cdQuality(); } |
32 | |
33 | float getVolume() { ret lvVolume!; } |
34 | } |
Began life as a copy of #1017138
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: | #1026862 |
Snippet name: | Audio Input [Dyn Module, backup before sample rate field] |
Eternal ID of this version: | #1026862/1 |
Text MD5: | a1483ab34fa1c91e9bfee8166db92d39 |
Author: | stefan |
Category: | javax / audio |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-01-29 16:08:21 |
Source code size: | 1227 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 195 / 197 |
Referenced in: | [show references] |