Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

30
LINES

< > BotCompany Repo | #1019654 // Play Audio From Other Machine v2 [shortened]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (14974L/104K).

!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)));
  }
}

Author comment

Began life as a copy of #1019651

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: #1019654
Snippet name: Play Audio From Other Machine v2 [shortened]
Eternal ID of this version: #1019654/4
Text MD5: 48e2d673154c92cb4d5a8487aa310776
Transpilation MD5: d77fb6a5e2188c45331d0ce5751e1087
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-16 21:48:16
Source code size: 966 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 203 / 1661
Version history: 3 change(s)
Referenced in: [show references]