-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
1391 lines (1127 loc) · 58.4 KB
/
main.py
File metadata and controls
1391 lines (1127 loc) · 58.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# !/usr/bin/env python
import gettext
import locale
import subprocess
import re
import os
import platform
import sys
import wx
import wx.adv
import wx.lib.agw.hyperlink as hl
from FlooStateMachine import FlooStateMachine
from FlooStateMachineDelegate import FlooStateMachineDelegate
from FlooDfuThread import FlooDfuThread
from FlooSettings import FlooSettings
from FlooAuxInput import FlooAuxInput
from PIL import Image
import urllib.request
import certifi
import ssl
appIcon = "FlooCastApp.ico"
appGif = "FlooCastApp.gif"
appTitle = "FlooCast"
appLogoPng = "FlooCastHeader.png"
codecStr = ['None',
'CVSD',
'mSBC/WBS',
'SBC',
'aptX\u2122',
'aptX\u2122 HD',
'aptX\u2122 Adaptive',
'LC3',
'aptX\u2122 Adaptive',
'aptX\u2122 Lite',
'aptX\u2122 Lossless',
'aptX\u2122 Voice']
mainWindowWidth = 950
mainWindowHeight = 560
if platform.system().lower().startswith('darwin'):
mainWindowWidth = 1200
mainWindowHeight = 640
preferLanguages = subprocess.run(['defaults', 'read', '-g', 'AppleLanguages'], stdout=subprocess.PIPE)
preferLanguage = preferLanguages.stdout.decode('utf-8').split('\n')[1]
lanSearch = re.search(r'(?<=\")\w+', preferLanguage.lstrip())
lan = lanSearch.group(0)
else:
userLocale = wx.Locale.GetSystemLanguage()
lan = wx.Locale.GetLanguageInfo(userLocale).CanonicalName
# Set the local directory
app_path = os.path.abspath(os.path.dirname(sys.argv[0]))
localedir = app_path + os.sep + 'locales'
# Set up your magic function
translate = gettext.translation("messages", localedir, languages=[lan], fallback=True)
translate.install()
_ = translate.gettext
sourceStateStr = [_("Initializing"),
_("Idle"),
_("Pairing"),
_("Connecting"),
_("Connected"),
_("Audio starting"),
_("Audio streaming"),
_("Audio stopping"),
_("Disconnecting"),
_("Voice starting"),
_("Voice streaming"),
_("Voice stopping")]
leaStateStr = [_("Disconnected"),
_("Connected"),
_("Unicast starting"),
_("Unicast streaming"),
_("Broadcast starting"),
_("Broadcast streaming"),
_("Streaming stopping")]
# create root window
app = wx.App(False)
settings = FlooSettings()
startMinimized = bool(settings.get_item("start_minimized") or False)
appFrame = wx.Frame(None, wx.ID_ANY, "FlooCast", size=wx.Size(mainWindowWidth, 560))
appFrame.SetIcon(wx.Icon(app_path + os.sep + appIcon))
statusBar = appFrame.CreateStatusBar(name=_("Status Bar"))
statusBar.SetStatusText(_("Initializing"))
# Update the status bar
def update_status_bar(info: str):
global statusBar
statusBar.SetStatusText(info)
# Define On/Off Images
on = wx.Bitmap(app_path + os.sep + 'onS.png', )
off = wx.Bitmap(app_path + os.sep + 'offS.png')
appPanel = wx.Panel(appFrame)
appSizer = wx.FlexGridSizer(2, 2, vgap=2, hgap=4)
# Hardware variant FMA120 (USB only) or FMA120 (with 3.5mm analog input)
hwWithAnalogInput = 0
# Audio mode panel
audioMode = None
audioModeSb = wx.StaticBox(appPanel, wx.ID_ANY, _('Audio Mode'))
audioModeSbSizer = wx.StaticBoxSizer(audioModeSb, wx.VERTICAL)
audioModeUpperPanel = wx.Panel(audioModeSb)
audioModeUpperPanelSizer = wx.FlexGridSizer(2, 3, (0, 0))
audioModeHighQualityRadioButton = wx.RadioButton(audioModeUpperPanel, label=_('High Quality (one-to-one)'),
style=wx.RB_GROUP)
audioModeGamingRadioButton = wx.RadioButton(audioModeUpperPanel, label=_('Gaming (one-to-one)'))
audioModeBroadcastRadioButton = wx.RadioButton(audioModeUpperPanel, label=_('Broadcast'))
def aux_input_broadcast_enable(enable):
if enable and saved_name in nameInputDevices:
auxInputComboBox.SetValue(saved_name)
looper.set_input(saved_device)
else:
# auxInputComboBox.SetValue("None")
looper.set_input(None)
def audio_mode_sel_set(mode):
if hwWithAnalogInput:
settingsPanelSizer.Show(usbInputCheckBox)
settingsPanelSizer.Show(usbInputEnableButton)
else:
settingsPanelSizer.Hide(usbInputCheckBox)
settingsPanelSizer.Hide(usbInputEnableButton)
if audioMode == 0:
settingsPanelSizer.Show(aptxLosslessCheckBox)
settingsPanelSizer.Show(aptxLosslessEnableButton)
settingsPanelSizer.Hide(gattClientWithBroadcastCheckBox)
settingsPanelSizer.Hide(gattClientWithBroadcastEnableButton)
leBroadcastSb.Disable()
elif audioMode == 1:
settingsPanelSizer.Hide(aptxLosslessCheckBox)
settingsPanelSizer.Hide(aptxLosslessEnableButton)
settingsPanelSizer.Hide(gattClientWithBroadcastCheckBox)
settingsPanelSizer.Hide(gattClientWithBroadcastEnableButton)
leBroadcastSb.Disable()
elif audioMode == 2:
settingsPanelSizer.Hide(aptxLosslessCheckBox)
settingsPanelSizer.Hide(aptxLosslessEnableButton)
settingsPanelSizer.Show(gattClientWithBroadcastCheckBox)
settingsPanelSizer.Show(gattClientWithBroadcastEnableButton)
leBroadcastSb.Enable()
broadcastUsbVolCtrCheckBox.Enable(broadcastUsbVolCtrSupported)
broadcastUsbVolCtrButton.Enable(broadcastUsbVolCtrSupported)
broadcast2QualityCheckBox.Enable(broadcast2QualitySupported)
broadcast2QualityButton.Enable(broadcast2QualitySupported)
aux_input_broadcast_enable(audioMode == 2)
settingsPanelSizer.Layout()
def audio_mode_sel(event):
global audioMode
selectedLabel = (event.GetEventObject().GetLabel())
if selectedLabel == audioModeHighQualityRadioButton.GetLabel():
audioMode = 0
elif selectedLabel == audioModeGamingRadioButton.GetLabel():
audioMode = 1
else:
audioMode = 2
audio_mode_sel_set(audioMode + (0x80 if hwWithAnalogInput else 0x00))
settingsPanelSizer.Layout()
flooSm.setAudioMode(audioMode)
audioModeUpperPanel.Bind(wx.EVT_RADIOBUTTON, audio_mode_sel)
dongleStateSb = wx.StaticBox(audioModeUpperPanel, wx.ID_ANY, _('Dongle State'))
dongleStateSbSizer = wx.StaticBoxSizer(dongleStateSb, wx.VERTICAL)
dongleStateText = wx.StaticText(dongleStateSb, wx.ID_ANY, _("Initializing"))
dongleStateSbSizer.Add(dongleStateText, flag=wx.ALIGN_CENTER_HORIZONTAL | wx.TOP | wx.BOTTOM, border=4)
leaStateSb = wx.StaticBox(audioModeUpperPanel, wx.ID_ANY, _('LE Audio State'))
leaStateSbSizer = wx.StaticBoxSizer(leaStateSb, wx.VERTICAL)
leaStateText = wx.StaticText(leaStateSb, wx.ID_ANY, _("Disconnected"))
leaStateSbSizer.Add(leaStateText, flag=wx.ALIGN_CENTER_HORIZONTAL | wx.TOP | wx.BOTTOM, border=4)
codecInUseSb = wx.StaticBox(audioModeUpperPanel, wx.ID_ANY, _('Codec in Use'))
codecInUseSbSizer = wx.StaticBoxSizer(codecInUseSb, wx.VERTICAL)
codecInUseText = wx.StaticText(codecInUseSb, wx.ID_ANY, codecStr[0])
codecInUseSbSizer.Add(codecInUseText, flag=wx.ALIGN_CENTER_HORIZONTAL | wx.TOP | wx.BOTTOM, border=4)
audioModeUpperPanelSizer.Add(audioModeHighQualityRadioButton, flag=wx.EXPAND | wx.ALL, border=4)
audioModeUpperPanelSizer.Add(audioModeGamingRadioButton, flag=wx.EXPAND | wx.ALL, border=4)
audioModeUpperPanelSizer.Add(audioModeBroadcastRadioButton, flag=wx.EXPAND | wx.ALL, border=4)
audioModeUpperPanelSizer.Add(dongleStateSbSizer, flag=wx.EXPAND | wx.ALL, border=4)
audioModeUpperPanelSizer.Add(leaStateSbSizer, flag=wx.EXPAND | wx.ALL, border=4)
audioModeUpperPanelSizer.Add(codecInUseSbSizer, flag=wx.EXPAND | wx.ALL, border=4)
audioModeUpperPanelSizer.AddGrowableRow(0, 1)
audioModeUpperPanelSizer.AddGrowableRow(1, 1)
audioModeUpperPanelSizer.AddGrowableCol(0, 1)
audioModeUpperPanelSizer.AddGrowableCol(1, 1)
audioModeUpperPanelSizer.AddGrowableCol(2, 2)
audioModeUpperPanel.SetSizer(audioModeUpperPanelSizer)
audioModeLowerPanel = wx.Panel(audioModeSb)
audioModeLowerPanelSizer = wx.BoxSizer(wx.HORIZONTAL)
preferLeaEnable = None
def prefer_lea_enable_switch_set(enable, isNotify):
global preferLeaEnable
preferLeaEnable = enable
preferLeButton.SetBitmap(on if preferLeaEnable else off)
preferLeButton.SetToolTip(
_('Toggle switch for') + ' ' + _('Prefer using LE audio for dual-mode devices') + ' ' + (_(
'On') if preferLeaEnable else _(
'Off')))
if isNotify:
preferLeaCheckBox.SetValue(enable)
else:
flooSm.setPreferLea(enable)
newPairingButton.Enable(False if preferLeaEnable and pairedDeviceListbox.GetCount() > 0 else True)
def prefer_lea_enable_button(event):
preferLeaCheckBox.SetValue(not preferLeaEnable)
prefer_lea_enable_switch_set(not preferLeaEnable, False)
def prefer_lea_enable_switch(event):
prefer_lea_enable_switch_set(not preferLeaEnable, False)
preferLeaCheckBox = wx.CheckBox(audioModeLowerPanel, wx.ID_ANY,
label=_('Prefer using LE audio for dual-mode devices') + ' (' + _(
'Must be disabled for') + ' ' + 'aptX\u2122 Lossless' + ')')
preferLeButton = wx.Button(audioModeLowerPanel, wx.ID_ANY, style=wx.NO_BORDER | wx.MINIMIZE)
preferLeButton.SetToolTip(
_('Toggle switch for') + ' ' + _('Prefer using LE audio for dual-mode devices') + ' ' + _('Off'))
preferLeButton.SetBitmap(off)
audioModeLowerPanel.Bind(wx.EVT_CHECKBOX, prefer_lea_enable_switch, preferLeaCheckBox)
preferLeButton.Bind(wx.EVT_BUTTON, prefer_lea_enable_button)
audioModeLowerPanelSizer.Add(preferLeaCheckBox, flag=wx.EXPAND, proportion=1)
audioModeLowerPanelSizer.Add(preferLeButton, proportion=0)
audioModeLowerPanel.SetSizer(audioModeLowerPanelSizer)
audioModeSbSizer.Add(audioModeUpperPanel, flag=wx.EXPAND) # , proportion=5
audioModeSbSizer.Add(audioModeLowerPanel, flag=wx.EXPAND) # , proportion=1
# Window panel
ID_SHOW = wx.NewIdRef()
ID_MINIMIZE = wx.NewIdRef()
ID_QUIT = wx.NewIdRef()
class FlooCastTaskBarIcon(wx.adv.TaskBarIcon):
def __init__(self, frame):
super().__init__()
self.frame = frame
icon = wx.Icon(app_path + os.sep + appIcon, wx.BITMAP_TYPE_ICO)
self.SetIcon(icon, "FlooCast")
# Bind tray events
self.Bind(wx.EVT_MENU, self.on_show, id=ID_SHOW)
self.Bind(wx.EVT_MENU, self.on_minimize, id=ID_MINIMIZE)
self.Bind(wx.EVT_MENU, self.on_quit, id=ID_QUIT)
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DCLICK, self.on_show)
def CreatePopupMenu(self):
menu = wx.Menu()
menu.Append(ID_SHOW, _("Show Window"))
menu.Append(ID_MINIMIZE, _("Minimize to System Tray"))
menu.AppendSeparator()
menu.Append(ID_QUIT, _("Quit"))
return menu
# ---- helpers ----
def restore_window(self):
def _restore():
# 1) show if hidden
if not self.frame.IsShown():
self.frame.Show(True)
# 2) un-minimize if iconized
if self.frame.IsIconized():
self.frame.Iconize(False)
# 3) bring to front
try:
self.frame.Restore() # clear maximized/minimized state if needed
except Exception:
pass
self.frame.Raise()
# 4) ensure focus lands somewhere sensible
child = self.frame.FindFocus() or self.frame.FindWindowById(wx.ID_ANY)
(child or self.frame).SetFocus()
# optional: flash/bounce if not focused (safe across wx versions)
if not self.frame.IsActive():
try:
flag = getattr(wx, "USER_ATTENTION_INFO", 0) # gentle notify
self.frame.RequestUserAttention(flag)
except Exception:
try:
self.frame.RequestUserAttention() # some builds accept no arg
except Exception:
pass
# run immediately (keep your original structure)
_restore()
# ---- event handlers ----
def on_show(self, event):
self.restore_window()
def on_minimize(self, event):
# minimize to tray: mark minimized, then hide
if not self.frame.IsIconized():
self.frame.Iconize(True)
if self.frame.IsShown():
self.frame.Hide()
def on_quit(self, event):
self.frame.Close()
def quit_all():
appFrame.Close()
# Define a function for quit the window
def quit_window(event):
windowIcon.Destroy()
appFrame.Destroy()
# Hide the window and show on the system taskbar
def hide_window(event):
if appFrame.IsShown():
appFrame.Hide()
windowIcon = FlooCastTaskBarIcon(appFrame)
#appFrame.Bind(wx.EVT_ICONIZE, hide_window)
appFrame.Bind(wx.EVT_CLOSE, quit_window)
windowSb = wx.StaticBox(appPanel, wx.ID_ANY, _('Window'))
windowSbSizer = wx.StaticBoxSizer(windowSb, wx.VERTICAL)
minimizeButton = wx.Button(windowSb, label=_('Minimize to System Tray'))
minimizeButton.Bind(wx.EVT_BUTTON, hide_window)
quitButton = wx.Button(windowSb, label=_('Quit App'))
quitButton.Bind(wx.EVT_BUTTON, quit_window)
def start_minimized_enable_switch_set(enable):
global startMinimized
startMinimized = enable
settings.set_item("start_minimized", enable) # or False
settings.save()
startMinimizedButton.SetBitmap(on if startMinimized else off)
startMinimizedButton.SetToolTip(
_('Toggle switch for') + ' ' + _('Start Minimized') + ' ' + (_('On') if startMinimized else _(
'Off')))
def start_minimized_enable_button(event):
startMinimizedCheckBox.SetValue(not startMinimized)
start_minimized_enable_switch_set(not startMinimized)
def start_minimized_enable_switch(event):
start_minimized_enable_switch_set(not startMinimized)
startMinimizedPanel = wx.Panel(windowSb)
startMinimizedPanelSizer = wx.BoxSizer(wx.HORIZONTAL)
startMinimizedCheckBox = wx.CheckBox(startMinimizedPanel, wx.ID_ANY, label=_('Start Minimized'))
startMinimizedCheckBox.SetValue(startMinimized)
startMinimizedButton = wx.Button(startMinimizedPanel, wx.ID_ANY, style=wx.NO_BORDER | wx.MINIMIZE)
if startMinimized:
startMinimizedButton.SetToolTip(_('Toggle switch for') + ' ' + _('Start Minimized') + ' ' + _('On'))
startMinimizedButton.SetBitmap(on)
else:
startMinimizedButton.SetToolTip(_('Toggle switch for') + ' ' + _('Start Minimized') + ' ' + _('Off'))
startMinimizedButton.SetBitmap(off)
windowSb.Bind(wx.EVT_CHECKBOX, start_minimized_enable_switch, startMinimizedCheckBox)
startMinimizedButton.Bind(wx.EVT_BUTTON, start_minimized_enable_button)
startMinimizedPanelSizer.Add(startMinimizedCheckBox, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 0)
startMinimizedPanelSizer.AddStretchSpacer(1)
startMinimizedPanelSizer.Add(startMinimizedButton, 0, wx.ALIGN_CENTER_VERTICAL)
startMinimizedPanel.SetSizer(startMinimizedPanelSizer)
windowSbSizer.AddStretchSpacer()
windowSbSizer.Add(minimizeButton, proportion=2, flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=10)
windowSbSizer.AddStretchSpacer()
windowSbSizer.Add(quitButton, proportion=2, flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=10)
windowSbSizer.AddStretchSpacer()
windowSbSizer.Add(startMinimizedPanel, proportion=2, flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=0)
#windowSbSizer.AddStretchSpacer()
# A combined panel for broadcast settings and paired devices
broadcastAndPairedDevicePanel = wx.Panel(appPanel)
broadcastAndPairedDeviceSizer = wx.BoxSizer(wx.VERTICAL)
leBroadcastSb = wx.StaticBox(broadcastAndPairedDevicePanel, wx.ID_ANY, _('LE Broadcast'))
leBroadcastSbSizer = wx.StaticBoxSizer(leBroadcastSb, wx.VERTICAL)
leBroadcastSwitchPanel = wx.Panel(leBroadcastSb)
leBroadcastSwitchPanelSizer = wx.FlexGridSizer(6, 2, (0, 0))
publicBroadcastEnable = None
def public_broadcast_enable_switch_set(enable, isNotify):
global publicBroadcastEnable
publicBroadcastEnable = enable
publicBroadcastButton.SetBitmap(on if publicBroadcastEnable else off)
publicBroadcastButton.SetToolTip(
_('Toggle switch for') + ' ' + _('Public broadcast') + ' ' + (_('On') if publicBroadcastEnable else _(
'Off')))
if isNotify:
publicBroadcastCheckBox.SetValue(enable)
else:
flooSm.setPublicBroadcast(enable)
def public_broadcast_enable_button(event):
publicBroadcastCheckBox.SetValue(not publicBroadcastEnable)
public_broadcast_enable_switch_set(not publicBroadcastEnable, False)
# Broadcast enable switch function
def public_broadcast_enable_switch(event):
public_broadcast_enable_switch_set(not publicBroadcastEnable, False)
publicBroadcastCheckBox = wx.CheckBox(leBroadcastSwitchPanel, wx.ID_ANY, label=_('Public broadcast') + ' (' + _(
'Must be enabled for compatibility with') + ' Auracast\u2122)')
publicBroadcastButton = wx.Button(leBroadcastSwitchPanel, wx.ID_ANY, style=wx.NO_BORDER | wx.MINIMIZE)
publicBroadcastButton.SetToolTip(_('Toggle switch for') + ' ' + _('Public broadcast') + ' ' + _('Off'))
publicBroadcastButton.SetBitmap(off)
leBroadcastSwitchPanel.Bind(wx.EVT_CHECKBOX, public_broadcast_enable_switch, publicBroadcastCheckBox)
publicBroadcastButton.Bind(wx.EVT_BUTTON, public_broadcast_enable_button)
broadcastUsbVolCtrEnable = None
broadcastUsbVolCtrSupported = False
def broadcast_usb_vol_ctr_switch_set(enable, isNotify):
global broadcastUsbVolCtrEnable
broadcastUsbVolCtrEnable = enable
broadcastUsbVolCtrButton.SetBitmap(on if broadcastUsbVolCtrEnable else off)
broadcastUsbVolCtrButton.SetToolTip(
_('Toggle switch for') + ' ' + _('Follow USB volume for broadcast level') + ' ' + (_(
'On') if broadcastUsbVolCtrEnable else _(
'Off')))
if isNotify:
broadcastUsbVolCtrCheckBox.SetValue(enable)
else:
flooSm.setBroadcastUsbVolCtr(enable)
def broadcast_usb_vol_ctr_enable_button(event):
broadcastUsbVolCtrCheckBox.SetValue(not broadcastUsbVolCtrEnable)
broadcast_usb_vol_ctr_switch_set(not broadcastUsbVolCtrEnable, False)
# Broadcast high quality enable switch function
def broadcast_usb_vol_ctr_enable_switch(event):
broadcast_usb_vol_ctr_switch_set(not broadcastUsbVolCtrEnable, False)
broadcastUsbVolCtrCheckBox = wx.CheckBox(leBroadcastSwitchPanel, wx.ID_ANY,
label=_('Follow USB volume for broadcast level'))
broadcastUsbVolCtrCheckBox.Enable(False)
broadcastUsbVolCtrButton = wx.Button(leBroadcastSwitchPanel, wx.ID_ANY, style=wx.NO_BORDER | wx.MINIMIZE)
broadcastUsbVolCtrButton.SetToolTip(
_('Toggle switch for') + ' ' + _('Follow USB volume for broadcast level') + ' ' + _('Off'))
broadcastUsbVolCtrButton.SetBitmap(off)
broadcastUsbVolCtrButton.Enable(False)
leBroadcastSwitchPanel.Bind(wx.EVT_CHECKBOX, broadcast_usb_vol_ctr_enable_switch, broadcastUsbVolCtrCheckBox)
broadcastUsbVolCtrButton.Bind(wx.EVT_BUTTON, broadcast_usb_vol_ctr_enable_button)
broadcast2QualityEnable = None
broadcast2QualitySupported = False
def broadcast_2_quality_switch_set(enable, isNotify):
global broadcast2QualityEnable
broadcast2QualityEnable = enable
broadcast2QualityButton.SetBitmap(on if broadcast2QualityEnable else off)
broadcast2QualityButton.SetToolTip(
_('Toggle switch for') + ' ' + _('Simultaneous standard and high-quality broadcast') + ' ' + (_(
'On') if broadcast2QualityEnable else _(
'Off')))
if isNotify:
broadcast2QualityCheckBox.SetValue(enable)
else:
flooSm.setBroadcast2Quality(enable)
def broadcast_2_quality_enable_button(event):
broadcast2QualityCheckBox.SetValue(not broadcast2QualityEnable)
broadcast_2_quality_switch_set(not broadcast2QualityEnable, False)
# Broadcast high quality enable switch function
def broadcast_2_quality_enable_switch(event):
broadcast_2_quality_switch_set(not broadcast2QualityEnable, False)
broadcast2QualityCheckBox = wx.CheckBox(leBroadcastSwitchPanel, wx.ID_ANY,
label=_('Simultaneous standard and high-quality broadcast'))
broadcast2QualityCheckBox.Enable(False)
broadcast2QualityButton = wx.Button(leBroadcastSwitchPanel, wx.ID_ANY, style=wx.NO_BORDER | wx.MINIMIZE)
broadcast2QualityButton.SetToolTip(
_('Toggle switch for') + ' ' + _('Simultaneous standard and high-quality broadcast') + ' ' + _('Off'))
broadcast2QualityButton.SetBitmap(off)
broadcast2QualityButton.Enable(False)
leBroadcastSwitchPanel.Bind(wx.EVT_CHECKBOX, broadcast_2_quality_enable_switch, broadcast2QualityCheckBox)
broadcast2QualityButton.Bind(wx.EVT_BUTTON, broadcast_2_quality_enable_button)
broadcastHighQualityEnable = None
def broadcast_high_quality_switch_set(enable, isNotify):
global broadcastHighQualityEnable
broadcastHighQualityEnable = enable
broadcastHighQualityButton.SetBitmap(on if broadcastHighQualityEnable else off)
broadcastHighQualityButton.SetToolTip(
_('Toggle switch for') + ' ' + _('Broadcast high-quality music, otherwise, voice') + ' ' + (_(
'On') if broadcastHighQualityEnable else _(
'Off')))
if isNotify:
broadcastHighQualityCheckBox.SetValue(enable)
else:
flooSm.setBroadcastHighQuality(enable)
def broadcast_high_quality_enable_button(event):
broadcastHighQualityCheckBox.SetValue(not broadcastHighQualityEnable)
broadcast_high_quality_switch_set(not broadcastHighQualityEnable, False)
# Broadcast high quality enable switch function
def broadcast_high_quality_enable_switch(event):
broadcast_high_quality_switch_set(not broadcastHighQualityEnable, False)
broadcastHighQualityCheckBox = wx.CheckBox(leBroadcastSwitchPanel, wx.ID_ANY,
label=_('Broadcast high-quality music, otherwise, voice') + ' (' + _(
'Must be disabled for compatibility with') + ' Auracast\u2122)')
broadcastHighQualityButton = wx.Button(leBroadcastSwitchPanel, wx.ID_ANY, style=wx.NO_BORDER | wx.MINIMIZE)
broadcastHighQualityButton.SetToolTip(
_('Toggle switch for') + ' ' + _('Broadcast high-quality music, otherwise, voice') + ' ' + _('Off'))
broadcastHighQualityButton.SetBitmap(off)
leBroadcastSwitchPanel.Bind(wx.EVT_CHECKBOX, broadcast_high_quality_enable_switch, broadcastHighQualityCheckBox)
broadcastHighQualityButton.Bind(wx.EVT_BUTTON, broadcast_high_quality_enable_button)
broadcastEncryptEnable = None
def broadcast_encrypt_switch_set(enable, isNotify):
global broadcastEncryptEnable
broadcastEncryptEnable = enable
broadcastEncryptButton.SetBitmap(on if broadcastEncryptEnable else off)
broadcastEncryptButton.SetToolTip(
_('Toggle switch for') + ' ' + _('Encrypt broadcast; please set a key first') + ' ' + (_(
'On') if broadcastEncryptEnable else _('Off')))
if isNotify:
broadcastEncryptCheckBox.SetValue(enable)
else:
flooSm.setBroadcastEncrypt(enable)
# Broadcast encrypt enable button function
def broadcast_encrypt_enable_button(event):
broadcastEncryptCheckBox.SetValue(not broadcastEncryptEnable)
broadcast_encrypt_switch_set(not broadcastEncryptEnable, False)
# Broadcast encrypt enable switch function
def broadcast_encrypt_enable_switch(event):
broadcast_encrypt_switch_set(not broadcastEncryptEnable, False)
broadcastEncryptCheckBox = wx.CheckBox(leBroadcastSwitchPanel, wx.ID_ANY,
label=_('Encrypt broadcast; please set a key first'))
broadcastEncryptButton = wx.Button(leBroadcastSwitchPanel, wx.ID_ANY, style=wx.NO_BORDER | wx.MINIMIZE)
broadcastEncryptButton.SetToolTip(
_('Toggle switch for') + ' ' + _('Encrypt broadcast; please set a key first') + ' ' + _('Off'))
broadcastEncryptButton.SetBitmap(off)
leBroadcastSwitchPanel.Bind(wx.EVT_CHECKBOX, broadcast_encrypt_enable_switch, broadcastEncryptCheckBox)
broadcastEncryptButton.Bind(wx.EVT_BUTTON, broadcast_encrypt_enable_button)
broadcastStopOnIdleEnable = None
def broadcast_stop_on_idle_switch_set(enable, isNotify):
global broadcastStopOnIdleEnable
broadcastStopOnIdleEnable = enable
broadcastStopOnIdleButton.SetBitmap(on if broadcastStopOnIdleEnable else off)
broadcastStopOnIdleButton.SetToolTip(
_('Toggle switch for') + ' ' + _('Stop broadcasting immediately when USB audio playback ends') + ' ' + (_(
'On') if broadcastStopOnIdleEnable else _('Off')))
if isNotify:
broadcastStopOnIdleCheckBox.SetValue(enable)
else:
flooSm.setBroadcastStopOnIdle(enable)
# Broadcast stops when USB idle enable button function
def broadcast_stop_on_idle_enable_button(event):
broadcastStopOnIdleCheckBox.SetValue(not broadcastStopOnIdleEnable)
broadcast_stop_on_idle_switch_set(not broadcastStopOnIdleEnable, False)
# BBroadcast stops when USB idle enable switch function
def broadcast_stop_on_idle_enable_switch(event):
broadcast_stop_on_idle_switch_set(not broadcastStopOnIdleEnable, False)
broadcastStopOnIdleCheckBox = wx.CheckBox(leBroadcastSwitchPanel, wx.ID_ANY,
label=_('Stop broadcasting immediately when USB audio playback ends'))
broadcastStopOnIdleButton = wx.Button(leBroadcastSwitchPanel, wx.ID_ANY, style=wx.NO_BORDER | wx.MINIMIZE)
broadcastStopOnIdleButton.SetToolTip(
_('Toggle switch for') + ' ' + _('Stop broadcasting immediately when USB audio playback ends') + ' ' + _('Off'))
broadcastStopOnIdleButton.SetBitmap(off)
leBroadcastSwitchPanel.Bind(wx.EVT_CHECKBOX, broadcast_stop_on_idle_enable_switch, broadcastStopOnIdleCheckBox)
broadcastStopOnIdleButton.Bind(wx.EVT_BUTTON, broadcast_stop_on_idle_enable_button)
leBroadcastSwitchPanelSizer.Add(publicBroadcastCheckBox, flag=wx.ALIGN_LEFT)
leBroadcastSwitchPanelSizer.Add(publicBroadcastButton, flag=wx.ALIGN_RIGHT)
leBroadcastSwitchPanelSizer.Add(broadcastUsbVolCtrCheckBox, flag=wx.ALIGN_LEFT)
leBroadcastSwitchPanelSizer.Add(broadcastUsbVolCtrButton, flag=wx.ALIGN_RIGHT)
leBroadcastSwitchPanelSizer.Add(broadcast2QualityCheckBox, flag=wx.ALIGN_LEFT)
leBroadcastSwitchPanelSizer.Add(broadcast2QualityButton, flag=wx.ALIGN_RIGHT)
leBroadcastSwitchPanelSizer.Add(broadcastHighQualityCheckBox, flag=wx.ALIGN_LEFT)
leBroadcastSwitchPanelSizer.Add(broadcastHighQualityButton, flag=wx.ALIGN_RIGHT)
leBroadcastSwitchPanelSizer.Add(broadcastEncryptCheckBox, flag=wx.ALIGN_LEFT)
leBroadcastSwitchPanelSizer.Add(broadcastEncryptButton, flag=wx.ALIGN_RIGHT)
leBroadcastSwitchPanelSizer.Add(broadcastStopOnIdleCheckBox, flag=wx.ALIGN_LEFT)
leBroadcastSwitchPanelSizer.Add(broadcastStopOnIdleButton, flag=wx.ALIGN_RIGHT)
leBroadcastSwitchPanelSizer.AddGrowableCol(0, 0)
leBroadcastSwitchPanelSizer.AddGrowableCol(1, 1)
leBroadcastEntryPanel = wx.Panel(leBroadcastSb)
leBroadcastEntryPanelSizer = wx.FlexGridSizer(2, 2, (0, 0))
# Broadcast name entry function
def broadcast_name_entry(event):
name = broadcastNameEntry.GetValue()
# print("new broadcast name", name)
nameBytes = name.encode('utf-8')
if 0 < len(nameBytes) < 31:
flooSm.setBroadcastName(name)
event.Skip()
broadcastNameLabel = wx.StaticText(leBroadcastEntryPanel, wx.ID_ANY, label=_('Broadcast Name, maximum 30 characters'))
broadcastNameEntry = wx.SearchCtrl(leBroadcastEntryPanel, wx.ID_ANY)
broadcastNameEntry.ShowSearchButton(False)
broadcastNameEntry.SetHint(_("Input a new name of no more than 30 characters then press <ENTER>"))
broadcastNameEntry.SetDescriptiveText(_("Input a new name of no more than 30 characters then press <ENTER>"))
broadcastNameEntry.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, broadcast_name_entry)
broadcastNameEntry.Bind(wx.EVT_KILL_FOCUS, broadcast_name_entry)
# Broadcast key entry function
def broadcast_key_entry(event):
key = broadcastKeyEntry.GetValue()
keyBytes = key.encode('utf-8')
if 0 < len(keyBytes) < 17:
flooSm.setBroadcastKey(key)
event.Skip()
broadcastKey = wx.StaticText(leBroadcastEntryPanel, wx.ID_ANY, label=_('Broadcast Key, maximum 16 characters'))
broadcastKeyEntry = wx.SearchCtrl(leBroadcastEntryPanel, wx.ID_ANY, style=wx.TE_PASSWORD)
broadcastKeyEntry.ShowSearchButton(False)
# broadcastKeyEntry.SetHint(_("Input a new key then press <ENTER>"))
broadcastKeyEntry.SetDescriptiveText(_("Input a new key then press <ENTER>"))
broadcastKeyEntry.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, broadcast_key_entry)
broadcastKeyEntry.Bind(wx.EVT_KILL_FOCUS, broadcast_key_entry)
leBroadcastEntryPanelSizer.Add(broadcastNameLabel, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
leBroadcastEntryPanelSizer.Add(broadcastNameEntry, flag=wx.EXPAND | wx.LEFT, border=8)
leBroadcastEntryPanelSizer.Add(broadcastKey, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
leBroadcastEntryPanelSizer.Add(broadcastKeyEntry, flag=wx.EXPAND | wx.LEFT, border=8)
leBroadcastEntryPanelSizer.AddGrowableCol(0, 1)
leBroadcastEntryPanelSizer.AddGrowableCol(1, 1)
leBroadcastEntryPanel.SetSizer(leBroadcastEntryPanelSizer)
leBroadcastLatencyPanel = wx.Panel(leBroadcastSb)
leBroadcastLatencyPanelSizer = wx.FlexGridSizer(1, 2, (0, 0))
broadcastLatencyLabel = wx.StaticText(leBroadcastLatencyPanel, wx.ID_ANY, label=_('Broadcast Latency'))
leBroadcastLatencyPanelSizer.Add(broadcastLatencyLabel, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
leBroadcastLatencyRadioPanel = wx.Panel(leBroadcastLatencyPanel)
leBroadcastLatencyRadioPanelSizer = wx.BoxSizer(wx.HORIZONTAL)
latencyLowestRadioButton = wx.RadioButton(leBroadcastLatencyRadioPanel, label=_('Lowest'),
style=wx.RB_GROUP)
latencyLowerRadioButton = wx.RadioButton(leBroadcastLatencyRadioPanel, label=_('Lower'))
latencyDefaultRadioButton = wx.RadioButton(leBroadcastLatencyRadioPanel, label=_('Default'))
leBroadcastLatencyRadioPanelSizer.Add(latencyLowestRadioButton, 0, wx.EXPAND | wx.LEFT, 10)
leBroadcastLatencyRadioPanelSizer.Add(latencyLowerRadioButton, 0, wx.EXPAND | wx.LEFT, 10)
leBroadcastLatencyRadioPanelSizer.Add(latencyDefaultRadioButton, 0, wx.EXPAND | wx.LEFT, 10)
#leBroadcastLatencyRadioPanelSizer.AddGrowableCol(0, 1)
#leBroadcastLatencyRadioPanelSizer.AddGrowableCol(1, 1)
#leBroadcastLatencyRadioPanelSizer.AddGrowableCol(2, 1)
leBroadcastLatencyRadioPanel.SetSizer(leBroadcastLatencyRadioPanelSizer)
leBroadcastLatencyPanelSizer.Add(leBroadcastLatencyRadioPanel, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, border=8)
#leBroadcastLatencyPanelSizer.AddGrowableCol(0, 1)
leBroadcastLatencyPanelSizer.AddGrowableCol(1, 1)
leBroadcastLatencyPanel.SetSizer(leBroadcastLatencyPanelSizer)
def broadcast_latency_sel(event):
selectedLabel = (event.GetEventObject().GetLabel())
if selectedLabel == latencyLowestRadioButton.GetLabel():
mode = 1
elif selectedLabel == latencyLowerRadioButton.GetLabel():
mode = 2
else:
mode = 3
flooSm.setBroadcastLatency(mode)
leBroadcastLatencyRadioPanel.Bind(wx.EVT_RADIOBUTTON, broadcast_latency_sel)
leBroadcastAuxInputPanel = wx.Panel(leBroadcastSb)
leBroadcastAuxInputPanelSizer = wx.FlexGridSizer(1, 2, (0, 0))
saved_bs = settings.get_item("aux_blocksize") # e.g., 128 or None
looper = FlooAuxInput(blocksize=saved_bs)
# --- macOS specific latency profile ---
if sys.platform == "darwin":
# choose one: "safe" 400ms | "low" 120ms | "ultra" 60ms | "jack" 250ms
profile = settings.get_item("aux_latency_profile", "ultra")
looper.set_latency_profile_mac(profile)
auxInput = None
inputDevices = looper.list_additional_inputs()
nameInputDevices = {d["name"]: d for d in inputDevices}
saved_device = settings.get_item("aux_input") # may be None
saved_name = (saved_device or {}).get("name", "None")
# AUX Input device select function
def input_device_on_select(event):
global saved_device
global saved_name
saved_name = auxInputComboBox.GetValue()
dev = nameInputDevices.get(saved_name)
# Save new selection
saved_device = looper.serialize_input_device(dev)
settings.set_item("aux_input", saved_device)
settings.save()
# Apply runtime
looper.set_input(saved_device)
print(f"User chose: {saved_name} -> applied and saved")
auxInputLabel = wx.StaticText(leBroadcastAuxInputPanel, wx.ID_ANY, label=_('Broadcast Additional Audio Input'))
auxInputComboBox = wx.ComboBox(leBroadcastAuxInputPanel, style=wx.CB_READONLY, choices=[d["name"] for d in inputDevices])
auxInputComboBox.Bind(wx.EVT_COMBOBOX, input_device_on_select)
leBroadcastAuxInputPanelSizer.Add(auxInputLabel, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
leBroadcastAuxInputPanelSizer.Add(auxInputComboBox, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, border=8)
#leBroadcastLatencyPanelSizer.AddGrowableCol(0, 1)
leBroadcastAuxInputPanelSizer.AddGrowableCol(1, 1)
leBroadcastAuxInputPanel.SetSizer(leBroadcastAuxInputPanelSizer)
leBroadcastSbSizer.Add(leBroadcastSwitchPanel, flag=wx.EXPAND | wx.TOP, border=4)
leBroadcastSbSizer.Add(leBroadcastEntryPanel, flag=wx.EXPAND | wx.TOP, border=4)
leBroadcastSbSizer.Add(leBroadcastLatencyPanel, flag=wx.EXPAND | wx.TOP, border=4)
leBroadcastSbSizer.Add(leBroadcastAuxInputPanel, flag=wx.EXPAND | wx.TOP, border=4)
leBroadcastSwitchPanel.SetSizer(leBroadcastSwitchPanelSizer)
pairedDevicesSb = wx.StaticBox(broadcastAndPairedDevicePanel, wx.ID_ANY, _('Most Recently Used Devices'))
pairedDevicesSbPanelSizer = wx.StaticBoxSizer(pairedDevicesSb, wx.VERTICAL)
pairedDevicesSbButtonPanel = wx.Panel(pairedDevicesSb)
pairedDevicesSbButtonPanelSizer = wx.BoxSizer(wx.HORIZONTAL)
# New pairing button function
def button_new_pairing(event):
flooSm.setNewPairing()
# Clear all paired device function
def button_clear_all(event):
flooSm.clearAllPairedDevices()
newPairingButton = wx.Button(pairedDevicesSbButtonPanel, wx.ID_ANY, label=_('Add device'))
clearAllButton = wx.Button(pairedDevicesSbButtonPanel, wx.ID_ANY, label=_('Clear All'))
pairedDevicesSbButtonPanelSizer.Add(newPairingButton, flag=wx.LEFT)
pairedDevicesSbButtonPanelSizer.AddStretchSpacer()
pairedDevicesSbButtonPanelSizer.Add(clearAllButton, flag=wx.RIGHT)
newPairingButton.Bind(wx.EVT_BUTTON, button_new_pairing)
clearAllButton.Bind(wx.EVT_BUTTON, button_clear_all)
pairedDevicesSbButtonPanel.SetSizer(pairedDevicesSbButtonPanelSizer)
class PopMenu(wx.Menu):
def __init__(self, parent):
super(PopMenu, self).__init__()
self.parent = parent
listBox = parent
self.index = listBox.GetSelection()
# menu item Connect/Disconnect
menuItemConnection = wx.MenuItem(self, wx.ID_ANY, _("Connect") if self.index > 0 or
flooSm.sourceState < 4 else _("Disconnect"))
self.Bind(wx.EVT_MENU, self.connect_disconnect_selected, menuItemConnection)
self.Append(menuItemConnection)
# menu item clear
menuItemDelete = wx.MenuItem(self, wx.ID_ANY, _("Delete"))
self.Bind(wx.EVT_MENU, self.delete_selected, menuItemDelete)
self.Append(menuItemDelete)
def delete_selected(self, e):
flooSm.clearIndexedDevice(self.index)
def connect_disconnect_selected(self, e):
flooSm.toggleConnection(self.index)
def OnContextMenu(Event):
listBox = Event.GetEventObject()
listBox.PopupMenu(PopMenu(listBox), listBox.ScreenToClient(Event.GetPosition())) # wx.GetMousePosition()
pairedDeviceListbox = wx.ListBox(pairedDevicesSb, style=wx.LB_SINGLE | wx.LB_ALWAYS_SB)
pairedDeviceListbox.Bind(wx.EVT_CONTEXT_MENU, OnContextMenu)
currentPairedDeviceList = []
pairedDevicesSbPanelSizer.Add(pairedDevicesSbButtonPanel, proportion=0, flag=wx.EXPAND)
pairedDevicesSbPanelSizer.Add(pairedDeviceListbox, proportion=1, flag=wx.EXPAND)
broadcastAndPairedDeviceSizer.Add(leBroadcastSbSizer, proportion=0, flag=wx.EXPAND)
broadcastAndPairedDeviceSizer.Add(pairedDevicesSbPanelSizer, proportion=1, flag=wx.EXPAND)
broadcastAndPairedDevicePanel.SetSizer(broadcastAndPairedDeviceSizer)
# Settings panel
aboutSb = wx.StaticBox(appPanel, wx.ID_ANY, _('Settings'))
aboutSbSizer = wx.StaticBoxSizer(aboutSb, wx.VERTICAL)
settingsPanel = wx.Panel(aboutSb)
settingsPanelSizer = wx.FlexGridSizer(4, 2, (5, 0))
usbInputEnable = None
def usb_input_enable_switch_set(enable, isNotify):
global usbInputEnable
usbInputEnable = enable
usbInputEnableButton.SetBitmap(on if usbInputEnable else off)
usbInputEnableButton.SetToolTip(_('Toggle switch for') + ' ' + _('USB Audio Input') + ' '
+ (_('On') if usbInputEnable else _('Off')))
if isNotify:
usbInputCheckBox.SetValue(enable)
else:
flooSm.enableUsbInput(enable)
# usb input enable button function
def usb_input_enable_button(event):
usbInputCheckBox.SetValue(not usbInputEnable)
usb_input_enable_switch_set(not usbInputEnable, False)
# usb input enable switch function
def usb_input_enable_switch(event):
usb_input_enable_switch_set(not usbInputEnable, False)
usbInputCheckBox = wx.CheckBox(settingsPanel, wx.ID_ANY, label=_('USB Audio Input'))
usbInputEnableButton = wx.Button(settingsPanel, wx.ID_ANY, style=wx.NO_BORDER | wx.MINIMIZE)
usbInputEnableButton.SetToolTip(_('Toggle switch for') + ' ' + _('USB Audio Input') + ' ' + _(' Off'))
usbInputEnableButton.SetBitmap(off)
settingsPanel.Bind(wx.EVT_CHECKBOX, usb_input_enable_switch, usbInputCheckBox)
usbInputEnableButton.Bind(wx.EVT_BUTTON, usb_input_enable_button)
ledEnable = None
def led_enable_switch_set(enable, isNotify):
global ledEnable
ledEnable = enable
ledEnableButton.SetBitmap(on if ledEnable else off)
ledEnableButton.SetToolTip(_('Toggle switch for') + ' ' + _('LED') + ' ' + (_('On') if ledEnable else _('Off')))
if isNotify:
ledCheckBox.SetValue(enable)
else:
flooSm.enableLed(enable)
# led enable button function
def led_enable_button(event):
ledCheckBox.SetValue(not ledEnable)
led_enable_switch_set(not ledEnable, False)
# led enable switch function
def led_enable_switch(event):
led_enable_switch_set(not ledEnable, False)
ledCheckBox = wx.CheckBox(settingsPanel, wx.ID_ANY, label=_('LED'))
ledEnableButton = wx.Button(settingsPanel, wx.ID_ANY, style=wx.NO_BORDER | wx.MINIMIZE)
ledEnableButton.SetToolTip(_('Toggle switch for') + ' ' + _('LED') + ' ' + _(' Off'))
ledEnableButton.SetBitmap(off)
settingsPanel.Bind(wx.EVT_CHECKBOX, led_enable_switch, ledCheckBox)
ledEnableButton.Bind(wx.EVT_BUTTON, led_enable_button)
aptxLosslessEnable = None
def aptxLossless_enable_switch_set(enable, isNotify):
global aptxLosslessEnable
aptxLosslessEnable = enable
aptxLosslessEnableButton.SetBitmap(on if aptxLosslessEnable else off)
aptxLosslessEnableButton.SetToolTip(
_('Toggle switch for') + ' ' + _('aptX Lossless') + ' ' + (_('On') if aptxLosslessEnable else _('Off')))
if isNotify:
aptxLosslessCheckBox.SetValue(enable)
else:
flooSm.enableAptxLossless(enable)
def aptxLossless_enable_button(event):
aptxLosslessCheckBox.SetValue(not aptxLosslessEnable)
aptxLossless_enable_switch_set(not aptxLosslessEnable, False)
# aptxLossless enable switch function
def aptxLossless_enable_switch(event):
aptxLossless_enable_switch_set(not aptxLosslessEnable, False)
aptxLosslessCheckBox = wx.CheckBox(settingsPanel, wx.ID_ANY, label='aptX\u2122 Lossless')
aptxLosslessEnableButton = wx.Button(settingsPanel, wx.ID_ANY, style=wx.NO_BORDER | wx.MINIMIZE)
aptxLosslessEnableButton.SetToolTip(_('Toggle switch for') + ' ' + _('aptX Lossless') + ' ' + _('Off'))
aptxLosslessEnableButton.SetBitmap(off) # , wx.RIGHT
settingsPanel.Bind(wx.EVT_CHECKBOX, aptxLossless_enable_switch, aptxLosslessCheckBox)
aptxLosslessEnableButton.Bind(wx.EVT_BUTTON, aptxLossless_enable_button)
gattClientWithBroadcastEnable = None
def gatt_client_enable_switch_set(enable, isNotify):
global gattClientWithBroadcastEnable
gattClientWithBroadcastEnable = enable
gattClientWithBroadcastEnableButton.SetBitmap(on if gattClientWithBroadcastEnable else off)
gattClientWithBroadcastEnableButton.SetToolTip(
_('Toggle switch for') + ' ' + 'GATT ' + _('Client') + ' ' + (
_('On') if gattClientWithBroadcastEnable else _('Off')))
if isNotify:
gattClientWithBroadcastCheckBox.SetValue(enable)
else:
flooSm.enableGattClient(enable)
# gatt client enable button function
def gatt_client_enable_button(event):
gattClientWithBroadcastCheckBox.SetValue(not gattClientWithBroadcastEnable)
gatt_client_enable_switch_set(not gattClientWithBroadcastEnable, False)
# gatt client enable switch function
def gatt_client_enable_switch(event):
gatt_client_enable_switch_set(not gattClientWithBroadcastEnable, False)
gattClientWithBroadcastCheckBox = wx.CheckBox(settingsPanel, wx.ID_ANY, label='GATT ' + _('Client'))
gattClientWithBroadcastEnableButton = wx.Button(settingsPanel, wx.ID_ANY, style=wx.NO_BORDER | wx.MINIMIZE)
gattClientWithBroadcastEnableButton.SetToolTip(_('Toggle switch for') + ' ' + ('GATT ') + _('Client') + ' ' + _('Off'))
gattClientWithBroadcastEnableButton.SetBitmap(off) # , wx.RIGHT
settingsPanel.Bind(wx.EVT_CHECKBOX, gatt_client_enable_switch, gattClientWithBroadcastCheckBox)
gattClientWithBroadcastEnableButton.Bind(wx.EVT_BUTTON, gatt_client_enable_button)
settingsPanelSizer.Add(usbInputCheckBox, 1, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
settingsPanelSizer.Add(usbInputEnableButton, flag=wx.ALIGN_RIGHT)
settingsPanelSizer.Add(ledCheckBox, 1, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)