Uses 911K of libraries. Click here for Pure Java version (4633L/23K).
!7 cmodule AudioInput > DynPrintLog { switchable float sampleRate = 44100; switchable int channels = 1; int bufSize = 40960; transient recordToAudioListeners_AudioLoop loop; transient SimpleLiveValue<Float> lvVolume = floatLiveValue(); // in percent transient L<VF1<short[]>> audioListeners = synchroList(); visualize { ret centerAndSouthWithMargins(super.visualize(), jCenteredLine(jLiveValueLabel(mapLiveValue(func(float volume) -> S { "Volume: " + iround(volume) + " %" }, S, lvVolume)))); } start { ownTimer(loop = recordToAudioListeners(audioListeners, bufSize, lvVolume, getAudioFormat())); loop.start(); JComponent trayIcon = jMinWidth(16, jVerticalGreenBar(lvVolume, max := 100)); componentPopupMenuItem(trayIcon, "Audio Input", r { dm_showModule(module()) }); dm_setTrayIcon(trayIcon); } // hold audio listeners during reload O _getReloadData() { ret audioListeners; } void _setReloadData(L<VF1<short[]>> listeners) { addAll(audioListeners, listeners); } // API void addAudioListener(VF1<short[]> l) { audioListeners.add(l); } void removeAudioListener(VF1<short[]> l) { audioListeners.remove(l); } AudioFormat getAudioFormat() { ret new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, sampleRate, 16, channels, channels*2, sampleRate, false); } float getVolume() { ret lvVolume!; } }
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: | #1026861 |
Snippet name: | Audio Input with other sample rate / channels [dev.] |
Eternal ID of this version: | #1026861/7 |
Text MD5: | 9b234f86de6128263cfba803f59516cc |
Transpilation MD5: | ea283ba20647fb2a6cd4d0330c58916b |
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:05:58 |
Source code size: | 1412 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 315 / 458 |
Version history: | 6 change(s) |
Referenced in: | [show references] |