!7 import static x30_pkg.x30_util.VF1; sclass PlaySyncedAudioLoop > DynModule { bool enabled = true; float gain = 0.5f; File file; S masterModule; double speed = 1; transient short[] loop; transient SyncedStereoSamplesIterator 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( vstackWithSpacing( withLabel("Master:", dm_moduleSelectorComboBox(dm_fieldLiveValue('masterModule))), 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 = SyncedStereoSamplesIterator(masterModule, loop)); } }
Began life as a copy of #1020114
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: | #1020126 |
Snippet name: | Play Audio Loop Synced To Another Module [dev.] |
Eternal ID of this version: | #1020126/1 |
Text MD5: | 880087c815c3a0f812a4f1da13a7e979 |
Author: | stefan |
Category: | javax / sound |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-12-08 21:55:02 |
Source code size: | 1253 bytes / 42 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 313 / 335 |
Referenced in: | -