!7 import static x30_pkg.x30_util.VF1; module ReceiveAudio > DynPrintLog { bool enabled; float gain = 0.5f; transient StreamingSoundSource soundSource; transient GainSoundSource gainSource; start { onChange(r { set(gainSource, gain := (double) gain); if (soundSource != null) soundSource.setEnabled(enabled); }); soundSource = new StreamingSoundSource; dm_addSoundSource(gainSource = GainSoundSource(gain, soundSource)); ownResource(vmBus_onMessage('gotFromPrivateChat, voidfunc(S sender, S msg) { if (enabled && startsWith(msg, "audio:")) soundSource.addChunk(shortArrayFromBytes_littleEndian(base64decode(substring(msg, 6)))); })); } visualize { ret centerAndSouth(super.visualize(), centerAndEast( withLabel("Volume (0-200%):", liveSliderZeroToOne(gain/2, voidfunc(float f) { setField(gain := f*2) })), dm_fieldCheckBox('enabled))); } }