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

34
LINES

< > BotCompany Repo | #1027532 // Stefan's Audio Adjuster

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

Uses 911K of libraries. Click here for Pure Java version (6479L/33K).

!7

cmodule AudioAdjuster > DynPrintLogAndEnabled {
  transient S goodMic = "USB PnP Audio Device Analog Stereo";
  transient S headphones = "Bluedio T 5th"; //"Bluedio T";
  transient S internal = "HD-Audio Generic Analog Stereo";

  transient S defaultSink;
  transient Bool haveGoodMic, haveHeadphones;
  transient long lastChecked;
  
  start {
    doEvery(10.0, r check);
    dm_registerAs_direct haveHeadphones();
  }

  void check enter {
    if (!enabled) ret;
    lastChecked = now();
    Map<Int, S> sinks = dm_systemAudioSinkNames();
    bool haveGoodMic = cicValue(sinks, goodMic);
    bool haveHeadphones = cicValue(sinks, headphones);
    S defaultSink = haveHeadphones ? headphones : internal;

    if (setFields(+defaultSink, +haveGoodMic, +haveHeadphones))
      dm_pulseAudio_setDefaultSinkAndSwitchAllClients(defaultSink);
  }

  // API

  WithTimestamp<Bool> haveHeadphones() {
    ret withTimestamp(lastChecked, haveHeadphones);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027532
Snippet name: Stefan's Audio Adjuster
Eternal ID of this version: #1027532/9
Text MD5: 9d059514b4847fd70feb6f2f53cc44df
Transpilation MD5: e1e91b86cafdfee431b7e7f08dfcc364
Author: stefan
Category:
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-07 20:40:16
Source code size: 956 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 173 / 9421
Version history: 8 change(s)
Referenced in: #1027542 - Audio Feedback Preventer [OK, stops speech output -> recognition endless loops]