Uses 11463K of libraries. Click here for Pure Java version (14906L/104K).
!7 import static x30_pkg.x30_util.VF1; sclass PlayAudioLoop > DynModule { bool enabled = true; float gain = 0.5f; File file; transient short[] loop; transient StereoSamplesIterator source; transient GainSoundSource gainSource; start { dm_addSoundSource(gainSource = GainSoundSource(0)); onChangeAndNow(r { set(gainSource, gain := enabled ? (double) gain : 0.0); }); loadFile(file); } visualize { ret jHandleFileDrop(voidfunc(final File f) enter { thread { loadFile(f); } }, centerAndSouth(withLabel("File:", dm_fieldLabel('file)), centerAndEast( withLabel("Volume (0-200%):", liveSliderZeroToOne(gain/2, voidfunc(float f) { setField(gain := f*2) })), dm_fieldCheckBox('enabled)))); } void loadFile(File f) { loop = null; setField(file := f); print("Loading audio file: " + f); pcall { loop = decodeAudioFileToStereoSamples(f); } gainSource.replaceSource(source = stereoSamplesIterator_longCounter(loop)); } }
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1020114 |
Snippet name: | Play Audio Loop |
Eternal ID of this version: | #1020114/14 |
Text MD5: | 1dbd5bdd2699f68f4f9daf75667e37e4 |
Transpilation MD5: | 32f4e38449dc170265b3ae81fe06dc62 |
Author: | stefan |
Category: | |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-12-08 21:45:59 |
Source code size: | 1058 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 324 / 679 |
Version history: | 13 change(s) |
Referenced in: | [show references] |