Uses 911K of libraries. Click here for Pure Java version (5564L/28K).
!7 import static x30_pkg.x30_util.VF1; cmodule AudioOutput > DynPrintLog { switchable int bufSize = 40960; switchable float gain = 1; switchable bool registerService; transient playAudioFromSampleMakingFunction_AudioLoop loop; transient L<VF1<double[]>> sources = notifyingList(r setNumSources); transient SimpleLiveValue<Int> numSources = new(Int, 0); visualize { ret centerAndSouth(super.visualize(), withLeftAndRightMargin(vstackWithSpacing( withLabel("Volume (0-200%):", liveSliderZeroToOne(gain/2, voidfunc(float f) { setField(gain := f*2) })), jrightalignedline(withLabel("Sound sources:", jLiveValueLabel(numSources))) ))); } start { final VF1<VF1<double[]>> vfRemoveSource = voidfunc(VF1<double[]> source) { removeSource(source) }; ownTimer(loop = playAudioFromSampleMakingFunction(bufSize, voidfunc(double[] pair) { audio_makeSampleFromSources(sources, pair, gain, vfRemoveSource) })); dm_registerAs audioOutputModule(); if (registerService) dm_registerService('playWAVAndWait, func(S method, O[] args) -> bool { temp enter(); callMC(f dm_playWAV, args); true; }); } void setNumSources { numSources.set(l(sources)); } // hold audio sources during reload O _getReloadData() { ret sources; } void _setReloadData(L<VF1<double[]>> sources) { addAll(this.sources, sources); } // API void addSource(VF1<double[]> source) { sources.add(source); print("Audio source added."); } void removeSource(VF1<double[]> source) { sources.remove(source); print("Audio source removed."); } AudioFormat getAudioFormat() { ret loop.quality; } long samplesPlayed() { ret loop.samplesPlayed; } }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1016699 |
Snippet name: | Audio Output [Dyn Module] |
Eternal ID of this version: | #1016699/40 |
Text MD5: | ee68a7b54cbe3afa95a4002bf2cb1eb6 |
Transpilation MD5: | 230c666ab1c7fb49bce35fb3bbb4454f |
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-02-06 23:38:00 |
Source code size: | 1842 bytes / 61 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 624 / 29759 |
Version history: | 39 change(s) |
Referenced in: | #1016700 - Demo Audio Loop [Dyn Module] #1016708 - dm_audioOutputModule - returns ID #1017138 - Audio Input [Dyn Module] #1027007 - Audio Output using aplay [dev.] |