Libraryless. Compilation Failed (14949L/104K).
1 | !7 |
2 | |
3 | import static x30_pkg.x30_util.VF1; |
4 | |
5 | sclass AudioInputOutput > DynPrintLog { |
6 | int bufSize = 40960; |
7 | transient recordToAudioListeners_AudioLoop loop; |
8 | transient SimpleLiveValue<Float> lvVolume = floatLiveValue(); // in percent |
9 | L<VF1<short[]>> audioListeners = synchroList(); |
10 | float gain = 1; |
11 | transient playAudioFromSampleMakingFunction_AudioLoop outputLoop; |
12 | transient L<VF1<double[]>> sources = synchroList(); |
13 | |
14 | visualize { |
15 | ret centerAndSouthWithMargins(super.visualize(), |
16 | vstackWithSpacing( |
17 | withLabel("Volume (0-200%):", liveSliderZeroToOne(gain/2, voidfunc(float f) { setField(gain := f*2) })), |
18 | jCenteredLine(jLiveValueLabel(mapLiveValue(func(float volume) -> S { "Input Volume: " + iround(volume) + " %" }, S, lvVolume))))); |
19 | } |
20 | |
21 | start { |
22 | ownTimer(loop = recordToAudioListeners(audioListeners, bufSize, lvVolume)); |
23 | ownTimer(outputLoop = playAudioFromSampleMakingFunction_dontStart(bufSize, voidfunc(double[] pair) { |
24 | audio_makeSampleFromSources(sources, pair, gain) |
25 | })); |
26 | Mixer mixer = AudioSystem.getMixer(null); |
27 | print("Mixer: " + mixer); |
28 | Line[] lines = { loop.line, outputLoop.out }; |
29 | bool fullSync = true; |
30 | bool canSync = mixer.isSynchronizationSupported(lines, true); |
31 | print("Can sync: " + canSync); |
32 | if (!canSync) { |
33 | fullSync = false; |
34 | canSync = mixer.isSynchronizationSupported(lines, false); |
35 | print("Can sync: " + canSync); |
36 | } |
37 | if (canSync) |
38 | mixer.synchronize(lines, fullSync); |
39 | loop.start(); |
40 | outputLoop.start(); |
41 | } |
42 | |
43 | void addAudioListener(VF1<short[]> l) { audioListeners.add(l); } |
44 | void removeAudioListener(VF1<short[]> l) { audioListeners.remove(l); } |
45 | |
46 | void addSource(VF1<double[]> source) { sources.add(source); } |
47 | void removeSource(VF1<double[]> source) { sources.remove(source); } |
48 | } |
Began life as a copy of #1017138
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018253 |
Snippet name: | Audio Input + Output [dev., Dyn Module, TODO: sync-start] |
Eternal ID of this version: | #1018253/6 |
Text MD5: | 41332e8185af37b9dbad24ce532dbe02 |
Transpilation MD5: | 84418319a853442ec45f6608fab63f58 |
Author: | stefan |
Category: | javax / audio |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-09-12 13:49:08 |
Source code size: | 1871 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 403 / 577 |
Version history: | 5 change(s) |
Referenced in: | [show references] |