ConfigAudio.cpp 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631
  1. /*
  2. ==============================================================================
  3. This is an automatically generated GUI class created by the Introjucer!
  4. Be careful when adding custom code to these files, as only the code within
  5. the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
  6. and re-saved.
  7. Created with Introjucer version: 3.1.1
  8. ------------------------------------------------------------------------------
  9. The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions"
  10. Copyright 2004-13 by Raw Material Software Ltd.
  11. ==============================================================================
  12. */
  13. //[Headers] You can add your own extra header files here...
  14. #include "Constants.h"
  15. #include "./Trace/TraceConfig.h"
  16. //[/Headers]
  17. #include "ConfigAudio.h"
  18. //[MiscUserDefs] You can add your own user definitions and misc code here...
  19. //[/MiscUserDefs]
  20. //==============================================================================
  21. ConfigAudio::ConfigAudio (ValueTree audio_store)
  22. : audioStore(audio_store)
  23. {
  24. //[Constructor_pre] You can add your own custom stuff here..
  25. //[/Constructor_pre]
  26. addAndMakeVisible (ioGroup = new GroupComponent ("ioGroup",
  27. TRANS("i/o")));
  28. ioGroup->setTextLabelPosition (Justification::centredLeft);
  29. ioGroup->setColour (GroupComponent::outlineColourId, Colours::grey);
  30. ioGroup->setColour (GroupComponent::textColourId, Colours::white);
  31. addAndMakeVisible (formatGroup = new GroupComponent ("formatGroup",
  32. TRANS("format")));
  33. formatGroup->setTextLabelPosition (Justification::centredLeft);
  34. formatGroup->setColour (GroupComponent::outlineColourId, Colours::grey);
  35. formatGroup->setColour (GroupComponent::textColourId, Colours::white);
  36. addAndMakeVisible (buffersGroup = new GroupComponent ("buffersGroup",
  37. TRANS("buffers (122.2ms)")));
  38. buffersGroup->setTextLabelPosition (Justification::centredLeft);
  39. buffersGroup->setColour (GroupComponent::outlineColourId, Colours::grey);
  40. buffersGroup->setColour (GroupComponent::textColourId, Colours::white);
  41. addAndMakeVisible (routingGroup = new GroupComponent ("routingGroup",
  42. TRANS("routing")));
  43. routingGroup->setTextLabelPosition (Justification::centredLeft);
  44. routingGroup->setColour (GroupComponent::outlineColourId, Colours::grey);
  45. routingGroup->setColour (GroupComponent::textColourId, Colours::white);
  46. addAndMakeVisible (defaultsButton = new TextButton ("defaultsButton"));
  47. defaultsButton->setButtonText (TRANS("defaults"));
  48. defaultsButton->addListener (this);
  49. addAndMakeVisible (asioButton = new TextButton ("asioButton"));
  50. asioButton->setButtonText (TRANS("asio config"));
  51. asioButton->addListener (this);
  52. addAndMakeVisible (modeLabel = new Label ("modeLabel",
  53. TRANS("interface:")));
  54. modeLabel->setFont (Font (15.00f, Font::plain));
  55. modeLabel->setJustificationType (Justification::centredLeft);
  56. modeLabel->setEditable (false, false, false);
  57. modeLabel->setColour (Label::textColourId, Colours::white);
  58. modeLabel->setColour (TextEditor::textColourId, Colours::black);
  59. modeLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  60. addAndMakeVisible (apiComboBox = new ComboBox ("apiComboBox"));
  61. apiComboBox->setExplicitFocusOrder (1);
  62. apiComboBox->setEditableText (false);
  63. apiComboBox->setJustificationType (Justification::centredLeft);
  64. apiComboBox->setTextWhenNothingSelected (String());
  65. apiComboBox->setTextWhenNoChoicesAvailable (TRANS("(no choices)"));
  66. apiComboBox->addListener (this);
  67. addAndMakeVisible (driverLabel = new Label ("driverLabel",
  68. TRANS("driver:")));
  69. driverLabel->setFont (Font (15.00f, Font::plain));
  70. driverLabel->setJustificationType (Justification::centredLeft);
  71. driverLabel->setEditable (false, false, false);
  72. driverLabel->setColour (Label::textColourId, Colours::white);
  73. driverLabel->setColour (TextEditor::textColourId, Colours::black);
  74. driverLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  75. addAndMakeVisible (driverComboBox = new ComboBox ("driverComboBox"));
  76. driverComboBox->setExplicitFocusOrder (1);
  77. driverComboBox->setEditableText (false);
  78. driverComboBox->setJustificationType (Justification::centredLeft);
  79. driverComboBox->setTextWhenNothingSelected (String());
  80. driverComboBox->setTextWhenNoChoicesAvailable (TRANS("(no choices)"));
  81. driverComboBox->addListener (this);
  82. addAndMakeVisible (sourceLabel = new Label ("sourceLabel",
  83. TRANS("input:")));
  84. sourceLabel->setFont (Font (15.00f, Font::plain));
  85. sourceLabel->setJustificationType (Justification::centredLeft);
  86. sourceLabel->setEditable (false, false, false);
  87. sourceLabel->setColour (Label::textColourId, Colours::white);
  88. sourceLabel->setColour (TextEditor::textColourId, Colours::black);
  89. sourceLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  90. addAndMakeVisible (sourceComboBox = new ComboBox ("sourceComboBox"));
  91. sourceComboBox->setExplicitFocusOrder (2);
  92. sourceComboBox->setEditableText (false);
  93. sourceComboBox->setJustificationType (Justification::centredLeft);
  94. sourceComboBox->setTextWhenNothingSelected (String());
  95. sourceComboBox->setTextWhenNoChoicesAvailable (TRANS("(no choices)"));
  96. sourceComboBox->addListener (this);
  97. addAndMakeVisible (sinkLabel = new Label ("sinkLabel",
  98. TRANS("output:")));
  99. sinkLabel->setFont (Font (15.00f, Font::plain));
  100. sinkLabel->setJustificationType (Justification::centredLeft);
  101. sinkLabel->setEditable (false, false, false);
  102. sinkLabel->setColour (Label::textColourId, Colours::white);
  103. sinkLabel->setColour (TextEditor::textColourId, Colours::black);
  104. sinkLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  105. addAndMakeVisible (sinkComboBox = new ComboBox ("sinkComboBox"));
  106. sinkComboBox->setExplicitFocusOrder (3);
  107. sinkComboBox->setEditableText (false);
  108. sinkComboBox->setJustificationType (Justification::centredLeft);
  109. sinkComboBox->setTextWhenNothingSelected (String());
  110. sinkComboBox->setTextWhenNoChoicesAvailable (TRANS("(no choices)"));
  111. sinkComboBox->addListener (this);
  112. addAndMakeVisible (bitdepthLabel = new Label ("bitdepthLabel",
  113. TRANS("bit depth:")));
  114. bitdepthLabel->setFont (Font (15.00f, Font::plain));
  115. bitdepthLabel->setJustificationType (Justification::centredLeft);
  116. bitdepthLabel->setEditable (false, false, false);
  117. bitdepthLabel->setColour (Label::textColourId, Colours::white);
  118. bitdepthLabel->setColour (TextEditor::textColourId, Colours::black);
  119. bitdepthLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  120. addAndMakeVisible (bps16Button = new ToggleButton ("bps16Button"));
  121. bps16Button->setExplicitFocusOrder (4);
  122. bps16Button->setButtonText (TRANS("16bit"));
  123. bps16Button->setRadioGroupId (1);
  124. bps16Button->addListener (this);
  125. bps16Button->setToggleState (true, dontSendNotification);
  126. bps16Button->setColour (ToggleButton::textColourId, Colours::white);
  127. addAndMakeVisible (bps24Button = new ToggleButton ("bps24Button"));
  128. bps24Button->setExplicitFocusOrder (5);
  129. bps24Button->setButtonText (TRANS("24bit"));
  130. bps24Button->setRadioGroupId (1);
  131. bps24Button->addListener (this);
  132. bps24Button->setColour (ToggleButton::textColourId, Colours::white);
  133. addAndMakeVisible (bps32Button = new ToggleButton ("bps32Button"));
  134. bps32Button->setExplicitFocusOrder (6);
  135. bps32Button->setButtonText (TRANS("32bit"));
  136. bps32Button->setRadioGroupId (1);
  137. bps32Button->addListener (this);
  138. bps32Button->setColour (ToggleButton::textColourId, Colours::white);
  139. addAndMakeVisible (samplerateLabel = new Label ("samplerateLabel",
  140. TRANS("sample rate:")));
  141. samplerateLabel->setFont (Font (15.00f, Font::plain));
  142. samplerateLabel->setJustificationType (Justification::centredLeft);
  143. samplerateLabel->setEditable (false, false, false);
  144. samplerateLabel->setColour (Label::textColourId, Colours::white);
  145. samplerateLabel->setColour (TextEditor::textColourId, Colours::black);
  146. samplerateLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  147. addAndMakeVisible (kHz44Button = new ToggleButton ("kHz44Button"));
  148. kHz44Button->setExplicitFocusOrder (7);
  149. kHz44Button->setButtonText (TRANS("44.1kHz"));
  150. kHz44Button->setRadioGroupId (2);
  151. kHz44Button->addListener (this);
  152. kHz44Button->setToggleState (true, dontSendNotification);
  153. kHz44Button->setColour (ToggleButton::textColourId, Colours::white);
  154. addAndMakeVisible (kHz48Button = new ToggleButton ("kHz48Button"));
  155. kHz48Button->setExplicitFocusOrder (8);
  156. kHz48Button->setButtonText (TRANS("48kHz"));
  157. kHz48Button->setRadioGroupId (2);
  158. kHz48Button->addListener (this);
  159. kHz48Button->setColour (ToggleButton::textColourId, Colours::white);
  160. addAndMakeVisible (kHz96Button = new ToggleButton ("kHz96Button"));
  161. kHz96Button->setExplicitFocusOrder (9);
  162. kHz96Button->setButtonText (TRANS("96kHz"));
  163. kHz96Button->setRadioGroupId (2);
  164. kHz96Button->addListener (this);
  165. kHz96Button->setColour (ToggleButton::textColourId, Colours::white);
  166. addAndMakeVisible (buffersLabel = new Label ("buffersLabel",
  167. TRANS("# of buffers")));
  168. buffersLabel->setFont (Font (15.00f, Font::plain));
  169. buffersLabel->setJustificationType (Justification::centredLeft);
  170. buffersLabel->setEditable (false, false, false);
  171. buffersLabel->setColour (Label::textColourId, Colours::white);
  172. buffersLabel->setColour (TextEditor::textColourId, Colours::black);
  173. buffersLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  174. addAndMakeVisible (nBuffersSlider = new Slider ("nBuffersSlider"));
  175. nBuffersSlider->setExplicitFocusOrder (10);
  176. nBuffersSlider->setRange (0, 16, 1);
  177. nBuffersSlider->setSliderStyle (Slider::IncDecButtons);
  178. nBuffersSlider->setTextBoxStyle (Slider::TextBoxLeft, true, 80, 20);
  179. nBuffersSlider->addListener (this);
  180. addAndMakeVisible (xLabel = new Label ("xLabel",
  181. TRANS("x")));
  182. xLabel->setFont (Font (15.00f, Font::plain));
  183. xLabel->setJustificationType (Justification::centredLeft);
  184. xLabel->setEditable (false, false, false);
  185. xLabel->setColour (Label::textColourId, Colours::white);
  186. xLabel->setColour (TextEditor::textColourId, Colours::black);
  187. xLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  188. addAndMakeVisible (bufferComboBox = new ComboBox ("bufferComboBox"));
  189. bufferComboBox->setExplicitFocusOrder (11);
  190. bufferComboBox->setEditableText (false);
  191. bufferComboBox->setJustificationType (Justification::centredLeft);
  192. bufferComboBox->setTextWhenNothingSelected (String());
  193. bufferComboBox->setTextWhenNoChoicesAvailable (TRANS("(no choices)"));
  194. bufferComboBox->addListener (this);
  195. addAndMakeVisible (bytesLabel = new Label ("bytesLabel",
  196. TRANS("bytes")));
  197. bytesLabel->setFont (Font (15.00f, Font::plain));
  198. bytesLabel->setJustificationType (Justification::centredLeft);
  199. bytesLabel->setEditable (false, false, false);
  200. bytesLabel->setColour (Label::textColourId, Colours::white);
  201. bytesLabel->setColour (TextEditor::textColourId, Colours::black);
  202. bytesLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  203. addAndMakeVisible (jackNameLabel = new Label ("jackNameLabel",
  204. TRANS("client name")));
  205. jackNameLabel->setFont (Font (15.00f, Font::plain));
  206. jackNameLabel->setJustificationType (Justification::centredLeft);
  207. jackNameLabel->setEditable (false, false, false);
  208. jackNameLabel->setColour (Label::textColourId, Colours::white);
  209. jackNameLabel->setColour (TextEditor::textColourId, Colours::black);
  210. jackNameLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  211. addAndMakeVisible (jackNameText = new TextEditor ("jackNameText"));
  212. jackNameText->setExplicitFocusOrder (12);
  213. jackNameText->setMultiLine (false);
  214. jackNameText->setReturnKeyStartsNewLine (false);
  215. jackNameText->setReadOnly (false);
  216. jackNameText->setScrollbarsShown (true);
  217. jackNameText->setCaretVisible (true);
  218. jackNameText->setPopupMenuEnabled (false);
  219. jackNameText->setColour (TextEditor::textColourId, Colours::grey);
  220. jackNameText->setColour (TextEditor::backgroundColourId, Colours::black);
  221. jackNameText->setText (String());
  222. addAndMakeVisible (nSourcesLabel = new Label ("nSourcesLabel",
  223. TRANS("# of sources")));
  224. nSourcesLabel->setFont (Font (15.00f, Font::plain));
  225. nSourcesLabel->setJustificationType (Justification::centredLeft);
  226. nSourcesLabel->setEditable (false, false, false);
  227. nSourcesLabel->setColour (Label::textColourId, Colours::white);
  228. nSourcesLabel->setColour (TextEditor::textColourId, Colours::black);
  229. nSourcesLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  230. addAndMakeVisible (nSourcesSlider = new Slider ("nSourcesSlider"));
  231. nSourcesSlider->setExplicitFocusOrder (14);
  232. nSourcesSlider->setRange (0, 16, 1);
  233. nSourcesSlider->setSliderStyle (Slider::IncDecButtons);
  234. nSourcesSlider->setTextBoxStyle (Slider::TextBoxLeft, true, 80, 20);
  235. nSourcesSlider->addListener (this);
  236. addAndMakeVisible (nSinksLabel = new Label ("nSinksLabel",
  237. TRANS("# of sinks")));
  238. nSinksLabel->setFont (Font (15.00f, Font::plain));
  239. nSinksLabel->setJustificationType (Justification::centredLeft);
  240. nSinksLabel->setEditable (false, false, false);
  241. nSinksLabel->setColour (Label::textColourId, Colours::white);
  242. nSinksLabel->setColour (TextEditor::textColourId, Colours::black);
  243. nSinksLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  244. addAndMakeVisible (nSinksSlider = new Slider ("nSinksSlider"));
  245. nSinksSlider->setExplicitFocusOrder (15);
  246. nSinksSlider->setRange (0, 16, 1);
  247. nSinksSlider->setSliderStyle (Slider::IncDecButtons);
  248. nSinksSlider->setTextBoxStyle (Slider::TextBoxLeft, true, 80, 20);
  249. nSinksSlider->addListener (this);
  250. addAndMakeVisible (jackPortsButton = new ToggleButton ("jackPortsButton"));
  251. jackPortsButton->setExplicitFocusOrder (13);
  252. jackPortsButton->setButtonText (TRANS("auto-connect ports"));
  253. jackPortsButton->addListener (this);
  254. jackPortsButton->setToggleState (true, dontSendNotification);
  255. jackPortsButton->setColour (ToggleButton::textColourId, Colours::white);
  256. //[UserPreSize]
  257. //[/UserPreSize]
  258. setSize (614, 434);
  259. //[Constructor] You can add your own custom stuff here..
  260. int audio_api_n = int(this->audioStore[CONFIG::AUDIO_API_ID]) ;
  261. this->apiComboBox ->addItemList(GUI::AUDIO_APIS , 1) ;
  262. this->apiComboBox ->setSelectedItemIndex(audio_api_n , juce::dontSendNotification) ;
  263. this->nBuffersSlider->setRange(GUI::MIN_N_BUFFERS , GUI::MAX_N_BUFFERS , 1) ;
  264. this->nSourcesSlider->setRange(GUI::MIN_N_SOURCES , GUI::MAX_N_SOURCES , 1) ;
  265. this->nSinksSlider ->setRange(GUI::MIN_N_SINKS , GUI::MAX_N_SINKS , 1) ;
  266. //[/Constructor]
  267. }
  268. ConfigAudio::~ConfigAudio()
  269. {
  270. //[Destructor_pre]. You can add your own custom destruction code here..
  271. //[/Destructor_pre]
  272. ioGroup = nullptr;
  273. formatGroup = nullptr;
  274. buffersGroup = nullptr;
  275. routingGroup = nullptr;
  276. defaultsButton = nullptr;
  277. asioButton = nullptr;
  278. modeLabel = nullptr;
  279. apiComboBox = nullptr;
  280. driverLabel = nullptr;
  281. driverComboBox = nullptr;
  282. sourceLabel = nullptr;
  283. sourceComboBox = nullptr;
  284. sinkLabel = nullptr;
  285. sinkComboBox = nullptr;
  286. bitdepthLabel = nullptr;
  287. bps16Button = nullptr;
  288. bps24Button = nullptr;
  289. bps32Button = nullptr;
  290. samplerateLabel = nullptr;
  291. kHz44Button = nullptr;
  292. kHz48Button = nullptr;
  293. kHz96Button = nullptr;
  294. buffersLabel = nullptr;
  295. nBuffersSlider = nullptr;
  296. xLabel = nullptr;
  297. bufferComboBox = nullptr;
  298. bytesLabel = nullptr;
  299. jackNameLabel = nullptr;
  300. jackNameText = nullptr;
  301. nSourcesLabel = nullptr;
  302. nSourcesSlider = nullptr;
  303. nSinksLabel = nullptr;
  304. nSinksSlider = nullptr;
  305. jackPortsButton = nullptr;
  306. //[Destructor]. You can add your own custom destruction code here..
  307. //[/Destructor]
  308. }
  309. //==============================================================================
  310. void ConfigAudio::paint (Graphics& g)
  311. {
  312. //[UserPrePaint] Add your own custom painting code here..
  313. //[/UserPrePaint]
  314. g.setColour (Colour (0xff002000));
  315. g.fillRoundedRectangle (0.0f, 0.0f, static_cast<float> (getWidth() - 0), static_cast<float> (getHeight() - 0), 10.000f);
  316. //[UserPaint] Add your own custom painting code here..
  317. //[/UserPaint]
  318. }
  319. void ConfigAudio::resized()
  320. {
  321. //[UserPreResize] Add your own custom resize code here..
  322. //[/UserPreResize]
  323. ioGroup->setBounds (132, 38, 350, 126);
  324. formatGroup->setBounds (132, 176, 350, 60);
  325. buffersGroup->setBounds (132, 250, 350, 48);
  326. routingGroup->setBounds (132, 312, 350, 74);
  327. defaultsButton->setBounds (getWidth() - 68, 4, 64, 24);
  328. asioButton->setBounds (getWidth() - 68, 4, 64, 24);
  329. modeLabel->setBounds (140, 56, 64, 18);
  330. apiComboBox->setBounds (212, 56, 256, 18);
  331. driverLabel->setBounds (140, 82, 64, 18);
  332. driverComboBox->setBounds (212, 82, 256, 18);
  333. sourceLabel->setBounds (140, 108, 64, 18);
  334. sourceComboBox->setBounds (212, 108, 256, 18);
  335. sinkLabel->setBounds (140, 134, 64, 16);
  336. sinkComboBox->setBounds (212, 134, 256, 18);
  337. bitdepthLabel->setBounds (140, 190, 64, 18);
  338. bps16Button->setBounds (212, 191, 64, 18);
  339. bps24Button->setBounds (288, 191, 64, 18);
  340. bps32Button->setBounds (364, 191, 64, 18);
  341. samplerateLabel->setBounds (140, 210, 72, 18);
  342. kHz44Button->setBounds (212, 211, 64, 18);
  343. kHz48Button->setBounds (288, 211, 64, 18);
  344. kHz96Button->setBounds (364, 211, 64, 18);
  345. buffersLabel->setBounds (140, 268, 64, 18);
  346. nBuffersSlider->setBounds (212, 268, 64, 18);
  347. xLabel->setBounds (275, 268, 16, 18);
  348. bufferComboBox->setBounds (292, 268, 52, 18);
  349. bytesLabel->setBounds (346, 268, 64, 18);
  350. jackNameLabel->setBounds (140, 332, 64, 18);
  351. jackNameText->setBounds (212, 332, 136, 18);
  352. nSourcesLabel->setBounds (140, 358, 64, 18);
  353. nSourcesSlider->setBounds (214, 358, 64, 18);
  354. nSinksLabel->setBounds (330, 358, 64, 18);
  355. nSinksSlider->setBounds (404, 358, 64, 18);
  356. jackPortsButton->setBounds (352, 332, 120, 18);
  357. //[UserResized] Add your own custom resize handling here..
  358. //[/UserResized]
  359. }
  360. void ConfigAudio::buttonClicked (Button* buttonThatWasClicked)
  361. {
  362. //[UserbuttonClicked_Pre]
  363. Identifier bit_depth_key = Identifier() ;
  364. Identifier sample_rate_key = Identifier() ;
  365. int audio_api_n = int(this->audioStore[CONFIG::AUDIO_API_ID]) ;
  366. #ifdef _WIN32
  367. switch ((audioStreamer::WinApi)audio_api_n)
  368. {
  369. case audioStreamer::WIN_AUDIO_KS:
  370. sample_rate_key = CONFIG::KS_SAMPLERATE_ID ;
  371. bit_depth_key = CONFIG::KS_BITDEPTH_ID ;
  372. break ;
  373. case audioStreamer::WIN_AUDIO_DS:
  374. sample_rate_key = CONFIG::DS_SAMPLERATE_ID ;
  375. bit_depth_key = CONFIG::DS_BITDEPTH_ID ;
  376. break ;
  377. case audioStreamer::WIN_AUDIO_WAVE:
  378. sample_rate_key = CONFIG::WAVE_SAMPLERATE_ID ;
  379. bit_depth_key = CONFIG::WAVE_BITDEPTH_ID ;
  380. break ;
  381. default: break ;
  382. }
  383. #else // _WIN32
  384. # ifndef _MAC
  385. UNUSED(audio_api_n) ;
  386. sample_rate_key = CONFIG::CA_SAMPLERATE_ID ;
  387. bit_depth_key = CONFIG::CA_BITDEPTH_ID ;
  388. # else // _MAC
  389. switch ((audioStreamer::NixApi)audio_api_n)
  390. {
  391. case audioStreamer::NIX_AUDIO_ALSA:
  392. sample_rate_key = CONFIG::ALSA_SAMPLERATE_ID ;
  393. bit_depth_key = CONFIG::ALSA_BITDEPTH_ID ;
  394. break ;
  395. default: break ;
  396. }
  397. # endif // _MAC
  398. #endif // _WIN32
  399. int bit_depth = (this->bps16Button->getToggleState())? GUI::BIT_DEPTH_16 :
  400. (this->bps24Button->getToggleState())? GUI::BIT_DEPTH_24 :
  401. (this->bps32Button->getToggleState())? GUI::BIT_DEPTH_32 : 0 ;
  402. int sample_rate = (this->kHz44Button->getToggleState())? GUI::SAMPLE_RATE_44100 :
  403. (this->kHz48Button->getToggleState())? GUI::SAMPLE_RATE_48000 :
  404. (this->kHz96Button->getToggleState())? GUI::SAMPLE_RATE_96000 : 0 ;
  405. Identifier config_key ;
  406. var value ;
  407. //[/UserbuttonClicked_Pre]
  408. if (buttonThatWasClicked == defaultsButton)
  409. {
  410. //[UserButtonCode_defaultsButton] -- add your button handler code here..
  411. restoreDefaults() ; loadParams() ;
  412. //[/UserButtonCode_defaultsButton]
  413. }
  414. else if (buttonThatWasClicked == asioButton)
  415. {
  416. //[UserButtonCode_asioButton] -- add your button handler code here..
  417. // TODO: make asioButton a checkbox
  418. config_key = CONFIG::ASIO_CONTROL_ID ;
  419. value = var(!bool(this->audioStore[CONFIG::ASIO_CONTROL_ID])) ;
  420. //[/UserButtonCode_asioButton]
  421. }
  422. else if (buttonThatWasClicked == bps16Button)
  423. {
  424. //[UserButtonCode_bps16Button] -- add your button handler code here..
  425. config_key = bit_depth_key ;
  426. value = var(bit_depth) ;
  427. //[/UserButtonCode_bps16Button]
  428. }
  429. else if (buttonThatWasClicked == bps24Button)
  430. {
  431. //[UserButtonCode_bps24Button] -- add your button handler code here..
  432. config_key = bit_depth_key ;
  433. value = var(bit_depth) ;
  434. //[/UserButtonCode_bps24Button]
  435. }
  436. else if (buttonThatWasClicked == bps32Button)
  437. {
  438. //[UserButtonCode_bps32Button] -- add your button handler code here..
  439. config_key = bit_depth_key ;
  440. value = var(bit_depth) ;
  441. //[/UserButtonCode_bps32Button]
  442. }
  443. else if (buttonThatWasClicked == kHz44Button)
  444. {
  445. //[UserButtonCode_kHz44Button] -- add your button handler code here..
  446. config_key = sample_rate_key ;
  447. value = var(sample_rate) ;
  448. //[/UserButtonCode_kHz44Button]
  449. }
  450. else if (buttonThatWasClicked == kHz48Button)
  451. {
  452. //[UserButtonCode_kHz48Button] -- add your button handler code here..
  453. config_key = sample_rate_key ;
  454. value = var(sample_rate) ;
  455. //[/UserButtonCode_kHz48Button]
  456. }
  457. else if (buttonThatWasClicked == kHz96Button)
  458. {
  459. //[UserButtonCode_kHz96Button] -- add your button handler code here..
  460. config_key = sample_rate_key ;
  461. value = var(sample_rate) ;
  462. //[/UserButtonCode_kHz96Button]
  463. }
  464. else if (buttonThatWasClicked == jackPortsButton)
  465. {
  466. //[UserButtonCode_jackPortsButton] -- add your button handler code here..
  467. //[/UserButtonCode_jackPortsButton]
  468. }
  469. //[UserbuttonClicked_Post]
  470. setConfig(config_key , value) ;
  471. //[/UserbuttonClicked_Post]
  472. }
  473. void ConfigAudio::comboBoxChanged (ComboBox* comboBoxThatHasChanged)
  474. {
  475. //[UsercomboBoxChanged_Pre]
  476. int audio_api_n = int(this->audioStore[CONFIG::AUDIO_API_ID]) ;
  477. int option_n = comboBoxThatHasChanged->getSelectedItemIndex() ;
  478. String option_text = comboBoxThatHasChanged->getText() ;
  479. Identifier key ;
  480. var value ;
  481. //[/UsercomboBoxChanged_Pre]
  482. if (comboBoxThatHasChanged == apiComboBox)
  483. {
  484. //[UserComboBoxCode_apiComboBox] -- add your combo box handling code here..
  485. key = CONFIG::AUDIO_API_ID ;
  486. value = var((~option_n) ? option_n : CONFIG::DEFAULT_AUDIO_API) ;
  487. this->apiComboBox->setSelectedItemIndex(option_n) ;
  488. //[/UserComboBoxCode_apiComboBox]
  489. }
  490. else if (comboBoxThatHasChanged == driverComboBox)
  491. {
  492. //[UserComboBoxCode_driverComboBox] -- add your combo box handling code here..
  493. #ifdef _WIN32
  494. key = CONFIG::ASIO_DRIVER_ID ;
  495. #else // _WIN32
  496. # ifndef _MAC
  497. key = CONFIG::JACK_SERVER_ID ;
  498. # endif // _MAC
  499. #endif // _WIN32
  500. value = var((~option_n) ? option_n : 0) ;
  501. this->driverComboBox->setSelectedItemIndex(option_n) ;
  502. //[/UserComboBoxCode_driverComboBox]
  503. }
  504. else if (comboBoxThatHasChanged == sourceComboBox)
  505. {
  506. //[UserComboBoxCode_sourceComboBox] -- add your combo box handling code here..
  507. #ifdef _WIN32
  508. switch ((audioStreamer::WinApi)audio_api_n)
  509. {
  510. case audioStreamer::WIN_AUDIO_ASIO:
  511. option_n = (~option_n) ? option_n : CONFIG::DEFAULT_ASIO_INPUTBN ;
  512. key = CONFIG::ASIO_INPUTB_ID ;
  513. value = var(option_n) ;
  514. this->sourceComboBox->setSelectedItemIndex(option_n) ; break ;
  515. case audioStreamer::WIN_AUDIO_KS:
  516. key = CONFIG::KS_INPUT_ID ;
  517. option_n = (~option_n) ? option_n - 1 : CONFIG::DEFAULT_KS_INPUTN ;
  518. value = var(option_n) ;
  519. this->sourceComboBox->setSelectedItemIndex(option_n + 1) ; break ;
  520. case audioStreamer::WIN_AUDIO_DS:
  521. key = CONFIG::DS_INPUT_ID ;
  522. option_n = (~option_n) ? option_n : GUI::DEFAULT_DS_INDEX ;
  523. value = var(option_text) ;
  524. this->sourceComboBox->setSelectedItemIndex(option_n) ; break ;
  525. case audioStreamer::WIN_AUDIO_WAVE:
  526. option_n = (~option_n) ? option_n - 1 : CONFIG::DEFAULT_WAVE_INPUTN ;
  527. key = CONFIG::WAVE_INPUT_ID ;
  528. value = var(option_n) ;
  529. this->sourceComboBox->setSelectedItemIndex(option_n + 1) ; break ;
  530. default: break ;
  531. }
  532. #else // _WIN32
  533. # ifdef _MAC
  534. UNUSED(audio_api_n) ;
  535. key = CONFIG::CA_INPUT_ID ;
  536. option_n = (~option_n) ? option_n : GUI::DEFAULT_CA_INDEX ;
  537. value = var(option_text) ;
  538. this->sourceComboBox->setSelectedItemIndex(option_n) ;
  539. # else // _MAC
  540. switch ((audioStreamer::NixApi)audio_api_n)
  541. {
  542. case audioStreamer::NIX_AUDIO_ALSA:
  543. key = CONFIG::ALSA_INPUT_ID ;
  544. option_n = (~option_n) ? option_n : GUI::DEFAULT_ALSA_INDEX ;
  545. value = var(option_text) ;
  546. this->sourceComboBox->setSelectedItemIndex(option_n) ; break ;
  547. default: break ;
  548. }
  549. # endif // _MAC
  550. #endif // _WIN32
  551. //[/UserComboBoxCode_sourceComboBox]
  552. }
  553. else if (comboBoxThatHasChanged == sinkComboBox)
  554. {
  555. //[UserComboBoxCode_sinkComboBox] -- add your combo box handling code here..
  556. #ifdef _WIN32
  557. switch ((audioStreamer::WinApi)audio_api_n)
  558. {
  559. case audioStreamer::WIN_AUDIO_ASIO:
  560. option_n = (~option_n) ? option_n : CONFIG::DEFAULT_ASIO_OUTPUTBN ;
  561. key = CONFIG::ASIO_OUTPUTB_ID ;
  562. value = var(option_n) ;
  563. this->sinkComboBox->setSelectedItemIndex(option_n) ; break ;
  564. case audioStreamer::WIN_AUDIO_KS:
  565. key = CONFIG::KS_OUTPUT_ID ;
  566. option_n = (~option_n) ? option_n - 1 : CONFIG::DEFAULT_KS_OUTPUTN ;
  567. value = var(option_n) ;
  568. this->sinkComboBox->setSelectedItemIndex(option_n + 1) ; break ;
  569. case audioStreamer::WIN_AUDIO_DS:
  570. key = CONFIG::DS_OUTPUT_ID ;
  571. option_n = (~option_n) ? option_n : GUI::DEFAULT_DS_INDEX ;
  572. value = var(option_text) ;
  573. this->sinkComboBox->setSelectedItemIndex(option_n) ; break ;
  574. case audioStreamer::WIN_AUDIO_WAVE:
  575. option_n = (~option_n) ? option_n - 1 : CONFIG::DEFAULT_WAVE_OUTPUTN ;
  576. key = CONFIG::WAVE_OUTPUT_ID ;
  577. value = var(option_n) ;
  578. this->sinkComboBox->setSelectedItemIndex(option_n + 1) ; break ;
  579. default: break ;
  580. }
  581. #else // _WIN32
  582. # ifdef _MAC
  583. UNUSED(audio_api_n) ;
  584. key = CONFIG::CA_OUTPUT_ID ;
  585. option_n = (~option_n) ? option_n : GUI::DEFAULT_CA_INDEX ;
  586. value = var(option_text) ;
  587. this->sourceComboBox->setSelectedItemIndex(option_n) ;
  588. # else // _MAC
  589. switch ((audioStreamer::NixApi)audio_api_n)
  590. {
  591. case audioStreamer::NIX_AUDIO_ALSA:
  592. key = CONFIG::ALSA_OUTPUT_ID ;
  593. option_n = (~option_n) ? option_n : GUI::DEFAULT_ALSA_INDEX ;
  594. value = var(option_text) ;
  595. this->sinkComboBox->setSelectedItemIndex(option_n) ; break ;
  596. default: break ;
  597. }
  598. # endif // _MAC
  599. #endif // _WIN32
  600. //[/UserComboBoxCode_sinkComboBox]
  601. }
  602. else if (comboBoxThatHasChanged == bufferComboBox)
  603. {
  604. //[UserComboBoxCode_bufferComboBox] -- add your combo box handling code here..
  605. #ifdef _WIN32
  606. switch ((audioStreamer::WinApi)audio_api_n)
  607. {
  608. case audioStreamer::WIN_AUDIO_KS: key = CONFIG::KS_BLOCKSIZE_ID ; break ;
  609. case audioStreamer::WIN_AUDIO_DS: key = CONFIG::DS_BLOCKSIZE_ID ; break ;
  610. case audioStreamer::WIN_AUDIO_WAVE: key = CONFIG::WAVE_BLOCKSIZE_ID ; break ;
  611. default: break ;
  612. }
  613. #else // _WIN32
  614. # ifndef _MAC
  615. switch ((audioStreamer::NixApi)audio_api_n)
  616. {
  617. case audioStreamer::NIX_AUDIO_ALSA: key = CONFIG::ALSA_BLOCKSIZE_ID ; break ;
  618. default: break ;
  619. }
  620. # endif // _MAC
  621. #endif // _WIN32
  622. value = var(option_text.getIntValue()) ;
  623. //[/UserComboBoxCode_bufferComboBox]
  624. }
  625. //[UsercomboBoxChanged_Post]
  626. setConfig(key , value) ;
  627. if (comboBoxThatHasChanged == this->bufferComboBox) updateLatency() ;
  628. //[/UsercomboBoxChanged_Post]
  629. }
  630. void ConfigAudio::sliderValueChanged (Slider* sliderThatWasMoved)
  631. {
  632. //[UsersliderValueChanged_Pre]
  633. int audio_api_n = int(this->audioStore[CONFIG::AUDIO_API_ID]) ;
  634. Identifier config_key ;
  635. var value = var((int)sliderThatWasMoved->getValue()) ;
  636. //[/UsersliderValueChanged_Pre]
  637. if (sliderThatWasMoved == nBuffersSlider)
  638. {
  639. //[UserSliderCode_nBuffersSlider] -- add your slider handling code here..
  640. #ifdef _WIN32
  641. switch ((audioStreamer::WinApi)audio_api_n)
  642. {
  643. case audioStreamer::WIN_AUDIO_KS: config_key = CONFIG::KS_NBLOCKS_ID ; break ;
  644. case audioStreamer::WIN_AUDIO_DS: config_key = CONFIG::DS_NBLOCKS_ID ; break ;
  645. case audioStreamer::WIN_AUDIO_WAVE: config_key = CONFIG::WAVE_NBLOCKS_ID ; break ;
  646. default: break ;
  647. }
  648. #else // _WIN32
  649. # ifndef _MAC
  650. switch ((audioStreamer::NixApi)audio_api_n)
  651. {
  652. case audioStreamer::NIX_AUDIO_ALSA: config_key = CONFIG::ALSA_NBLOCKS_ID ; break ;
  653. default: break ;
  654. }
  655. # endif // _MAC
  656. #endif // _WIN32
  657. //[/UserSliderCode_nBuffersSlider]
  658. }
  659. else if (sliderThatWasMoved == nSourcesSlider)
  660. {
  661. //[UserSliderCode_nSourcesSlider] -- add your slider handling code here..
  662. #ifndef _WIN32
  663. # ifdef _MAC
  664. UNUSED(audio_api_n) ;
  665. config_key = CONFIG::CA_NCHANNELS_ID ;
  666. # else // _MAC
  667. switch ((audioStreamer::NixApi)audio_api_n)
  668. {
  669. case audioStreamer::NIX_AUDIO_JACK: config_key = CONFIG::JACK_NINPUTS_ID ; break ;
  670. case audioStreamer::NIX_AUDIO_ALSA: config_key = CONFIG::ALSA_NCHANNELS_ID ; break ;
  671. default: break ;
  672. }
  673. # endif // _MAC
  674. #endif // _WIN32
  675. //[/UserSliderCode_nSourcesSlider]
  676. }
  677. else if (sliderThatWasMoved == nSinksSlider)
  678. {
  679. //[UserSliderCode_nSinksSlider] -- add your slider handling code here..
  680. #ifndef _WIN32
  681. # ifndef _MAC
  682. switch ((audioStreamer::NixApi)audio_api_n)
  683. {
  684. case audioStreamer::NIX_AUDIO_JACK: config_key = CONFIG::JACK_NOUTPUTS_ID ; break ;
  685. default: break ;
  686. }
  687. # endif // _MAC
  688. #endif // _WIN32
  689. //[/UserSliderCode_nSinksSlider]
  690. }
  691. //[UsersliderValueChanged_Post]
  692. setConfig(config_key , value) ;
  693. if (sliderThatWasMoved == this->nBuffersSlider) updateLatency() ;
  694. //[/UsersliderValueChanged_Post]
  695. }
  696. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  697. /* ConfigAudio class private instance methods */
  698. void ConfigAudio::loadParams()
  699. {
  700. // initialize or reset GUI state
  701. populateDevices() ;
  702. // load config
  703. int audio_api_n = int(this->audioStore[CONFIG::AUDIO_API_ID ]) ;
  704. #ifdef _WIN32
  705. int asio_driver_n = int(this->audioStore[CONFIG::ASIO_DRIVER_ID ]) ;
  706. int asio_input_b_n = int(this->audioStore[CONFIG::ASIO_INPUTB_ID ]) ;
  707. int asio_input_e_n = int(this->audioStore[CONFIG::ASIO_INPUTE_ID ]) ;
  708. int asio_output_b_n = int(this->audioStore[CONFIG::ASIO_OUTPUTB_ID ]) ;
  709. int asio_output_e_n = int(this->audioStore[CONFIG::ASIO_OUTPUTE_ID ]) ;
  710. int should_show_asio_cp = int(this->audioStore[CONFIG::ASIO_CONTROL_ID ]) ;
  711. int ks_input_device_n = int(this->audioStore[CONFIG::KS_INPUT_ID ]) ;
  712. int ks_output_device_n = int(this->audioStore[CONFIG::KS_OUTPUT_ID ]) ;
  713. int ks_sample_rate = int(this->audioStore[CONFIG::KS_SAMPLERATE_ID ]) ;
  714. int ks_bit_depth = int(this->audioStore[CONFIG::KS_BITDEPTH_ID ]) ;
  715. int ks_n_buffers = int(this->audioStore[CONFIG::KS_NBLOCKS_ID ]) ;
  716. int ks_buffer_size = int(this->audioStore[CONFIG::KS_BLOCKSIZE_ID ]) ;
  717. String ds_input_device = str(this->audioStore[CONFIG::DS_INPUT_ID ]) ;
  718. String ds_output_device = str(this->audioStore[CONFIG::DS_OUTPUT_ID ]) ;
  719. int ds_sample_rate = int(this->audioStore[CONFIG::DS_SAMPLERATE_ID ]) ;
  720. int ds_bit_depth = int(this->audioStore[CONFIG::DS_BITDEPTH_ID ]) ;
  721. int ds_n_buffers = int(this->audioStore[CONFIG::DS_NBLOCKS_ID ]) ;
  722. int ds_buffer_size = int(this->audioStore[CONFIG::DS_BLOCKSIZE_ID ]) ;
  723. int wave_input_device_n = int(this->audioStore[CONFIG::WAVE_INPUT_ID ]) ;
  724. int wave_output_device_n = int(this->audioStore[CONFIG::WAVE_OUTPUT_ID ]) ;
  725. int wave_sample_rate = int(this->audioStore[CONFIG::WAVE_SAMPLERATE_ID]) ;
  726. int wave_bit_depth = int(this->audioStore[CONFIG::WAVE_BITDEPTH_ID ]) ;
  727. int wave_n_buffers = int(this->audioStore[CONFIG::WAVE_NBLOCKS_ID ]) ;
  728. int wave_buffer_size = int(this->audioStore[CONFIG::WAVE_BLOCKSIZE_ID ]) ;
  729. #else // _WIN32
  730. # ifdef _MAC
  731. String ca_input_device = str(this->audioStore[CONFIG::CA_INPUT_ID ]) ;
  732. String ca_output_device = str(this->audioStore[CONFIG::CA_OUTPUT_ID ]) ;
  733. int ca_n_channels = int(this->audioStore[CONFIG::CA_NCHANNELS_ID ]) ;
  734. int ca_sample_rate = int(this->audioStore[CONFIG::CA_SAMPLERATE_ID ]) ;
  735. int ca_bit_depth = int(this->audioStore[CONFIG::CA_BITDEPTH_ID ]) ;
  736. # else // _MAC
  737. int jack_server_n = int(this->audioStore[CONFIG::JACK_SERVER_ID ]) ;
  738. String jack_client_name = str(this->audioStore[CONFIG::JACK_NAME_ID ]) ;
  739. int jack_n_inputs = int(this->audioStore[CONFIG::JACK_NINPUTS_ID ]) ;
  740. int jack_n_outputs = int(this->audioStore[CONFIG::JACK_NOUTPUTS_ID ]) ;
  741. String alsa_input_device = str(this->audioStore[CONFIG::ALSA_INPUT_ID ]) ;
  742. String alsa_output_device = str(this->audioStore[CONFIG::ALSA_OUTPUT_ID ]) ;
  743. int alsa_n_channels = int(this->audioStore[CONFIG::ALSA_NCHANNELS_ID ]) ;
  744. int alsa_sample_rate = int(this->audioStore[CONFIG::ALSA_SAMPLERATE_ID]) ;
  745. int alsa_bit_depth = int(this->audioStore[CONFIG::ALSA_BITDEPTH_ID ]) ;
  746. int alsa_n_buffers = int(this->audioStore[CONFIG::ALSA_NBLOCKS_ID ]) ;
  747. int alsa_buffer_size = int(this->audioStore[CONFIG::ALSA_BLOCKSIZE_ID ]) ;
  748. # endif // _MAC
  749. #endif // _WIN32
  750. int driver_n = -1 ;
  751. int source_n = -1 ;
  752. int sink_n = -1 ;
  753. int n_inputs = 0 ;
  754. int n_outputs = 0 ;
  755. int sample_rate = 0 ;
  756. int bit_depth = 0 ;
  757. int n_buffers = 0 ;
  758. int buffer_size = 0 ;
  759. String jack_name_text = "" ;
  760. String n_sources_text = GUI::NSOURCES_LABEL_TEXT ;
  761. // set API-specific GUI state
  762. #ifdef _WIN32
  763. switch ((audioStreamer::WinApi)audio_api_n)
  764. {
  765. case audioStreamer::WIN_AUDIO_ASIO:
  766. {
  767. /* TODO: nyi GUI (issue #12)
  768. asio_input_e_n
  769. asio_output_e_n
  770. */
  771. driver_n = asio_driver_n ;
  772. source_n = asio_input_b_n ;
  773. sink_n = asio_output_b_n ;
  774. this->asioButton->setToggleState(should_show_asio_cp , juce::dontSendNotification) ;
  775. break ;
  776. }
  777. case audioStreamer::WIN_AUDIO_KS:
  778. {
  779. source_n = ks_input_device_n + 1 ;
  780. sink_n = ks_output_device_n + 1 ;
  781. sample_rate = ks_sample_rate ;
  782. bit_depth = ks_bit_depth ;
  783. n_buffers = ks_n_buffers ;
  784. buffer_size = ks_buffer_size ;
  785. break ;
  786. }
  787. case audioStreamer::WIN_AUDIO_DS:
  788. {
  789. source_n = getItemIndex(this->sourceComboBox , ds_input_device ) ;
  790. sink_n = getItemIndex(this->sinkComboBox , ds_output_device) ;
  791. sample_rate = ds_sample_rate ;
  792. bit_depth = ds_bit_depth ;
  793. n_buffers = ds_n_buffers ;
  794. buffer_size = ds_buffer_size ;
  795. break ;
  796. }
  797. case audioStreamer::WIN_AUDIO_WAVE:
  798. {
  799. source_n = wave_input_device_n + 1 ;
  800. sink_n = wave_output_device_n + 1 ;
  801. sample_rate = wave_sample_rate ;
  802. bit_depth = wave_bit_depth ;
  803. n_buffers = wave_n_buffers ;
  804. buffer_size = wave_buffer_size ;
  805. break ;
  806. }
  807. default: break ;
  808. }
  809. #else // _WIN32
  810. # ifdef _MAC
  811. UNUSED(audio_api_n) ;
  812. source_n = getItemIndex(this->sourceComboBox , ca_input_device ) ;
  813. sink_n = getItemIndex(this->sinkComboBox , ca_output_device) ;
  814. n_inputs = ca_n_channels ;
  815. sample_rate = ca_sample_rate ;
  816. bit_depth = ca_bit_depth ;
  817. # else // _MAC
  818. switch ((audioStreamer::NixApi)audio_api_n)
  819. {
  820. case audioStreamer::NIX_AUDIO_JACK:
  821. {
  822. driver_n = jack_server_n ;
  823. n_inputs = jack_n_inputs ;
  824. n_outputs = jack_n_outputs ;
  825. jack_name_text = jack_client_name ;
  826. break ;
  827. }
  828. case audioStreamer::NIX_AUDIO_ALSA:
  829. {
  830. source_n = getItemIndex(this->sourceComboBox , alsa_input_device ) ;
  831. sink_n = getItemIndex(this->sinkComboBox , alsa_output_device) ;
  832. n_inputs = alsa_n_channels ;
  833. sample_rate = alsa_sample_rate ;
  834. bit_depth = alsa_bit_depth ;
  835. n_buffers = alsa_n_buffers ;
  836. buffer_size = alsa_buffer_size ;
  837. n_sources_text = GUI::NCHANNELS_LABEL_TEXT ;
  838. break ;
  839. }
  840. default: break ;
  841. }
  842. # endif // _MAC
  843. #endif // _WIN32
  844. bool is_44_khz = sample_rate == GUI::SAMPLE_RATE_44100 ;
  845. bool is_48_khz = sample_rate == GUI::SAMPLE_RATE_48000 ;
  846. bool is_96_khz = sample_rate == GUI::SAMPLE_RATE_96000 ;
  847. bool is_16_bps = bit_depth == GUI::BIT_DEPTH_16 ;
  848. bool is_24_bps = bit_depth == GUI::BIT_DEPTH_24 ;
  849. bool is_32_bps = bit_depth == GUI::BIT_DEPTH_32 ;
  850. int buffer_size_n = GUI::BUFFER_SIZES.indexOf(String(buffer_size)) ;
  851. this->driverComboBox->setSelectedItemIndex(driver_n) ;
  852. this->sourceComboBox->setSelectedItemIndex(source_n) ;
  853. this->sinkComboBox ->setSelectedItemIndex(sink_n) ;
  854. this->bps16Button ->setToggleState (is_16_bps , juce::dontSendNotification) ;
  855. this->bps24Button ->setToggleState (is_24_bps , juce::dontSendNotification) ;
  856. this->bps32Button ->setToggleState (is_32_bps , juce::dontSendNotification) ;
  857. this->kHz44Button ->setToggleState (is_44_khz , juce::dontSendNotification) ;
  858. this->kHz48Button ->setToggleState (is_48_khz , juce::dontSendNotification) ;
  859. this->kHz96Button ->setToggleState (is_96_khz , juce::dontSendNotification) ;
  860. this->nBuffersSlider->setValue (n_buffers) ;
  861. this->bufferComboBox->setSelectedItemIndex(buffer_size_n) ;
  862. this->jackNameText ->setText (jack_name_text , juce::dontSendNotification) ;
  863. this->nSourcesLabel ->setText (n_sources_text , juce::dontSendNotification) ;
  864. this->nSourcesSlider->setValue (n_inputs) ;
  865. this->nSinksSlider ->setValue (n_outputs) ;
  866. updateLatency() ; enableComponents() ;
  867. }
  868. void ConfigAudio::populateDevices()
  869. {
  870. // re-populate API-specific device selection comboBoxes
  871. this->driverComboBox->clear(juce::dontSendNotification) ;
  872. this->sourceComboBox->clear(juce::dontSendNotification) ;
  873. this->sinkComboBox ->clear(juce::dontSendNotification) ;
  874. this->bufferComboBox->clear(juce::dontSendNotification) ;
  875. int audio_api_n = int(this->audioStore[CONFIG::AUDIO_API_ID]) ;
  876. #ifdef _WIN32
  877. switch ((audioStreamer::WinApi)audio_api_n)
  878. {
  879. case audioStreamer::WIN_AUDIO_ASIO: if (queryAsioDevices()) break ;
  880. case audioStreamer::WIN_AUDIO_KS: if (queryKsDevices()) break ;
  881. case audioStreamer::WIN_AUDIO_DS: if (queryDsDevices()) break ;
  882. case audioStreamer::WIN_AUDIO_WAVE: if (queryWaveDevices()) break ;
  883. default: restoreDefaults() ; break ;
  884. }
  885. #else // _WIN32
  886. # ifdef _MAC
  887. UNUSED(audio_api_n) ;
  888. if (!queryCaDevices()) restoreDefaults() ;
  889. # else // _MAC
  890. switch ((audioStreamer::NixApi)audio_api_n)
  891. {
  892. case audioStreamer::NIX_AUDIO_JACK: if (queryJackServers()) break ;
  893. case audioStreamer::NIX_AUDIO_ALSA: if (queryAlsaDevices()) break ;
  894. default: restoreDefaults() ; break ;
  895. }
  896. # endif // _MAC
  897. #endif // _WIN32
  898. }
  899. void ConfigAudio::restoreDefaults()
  900. {
  901. int audio_api_n = int(this->audioStore[CONFIG::AUDIO_API_ID]) ;
  902. int n_apis = this->apiComboBox->getNumItems() ;
  903. // sanity check
  904. if (audio_api_n < 0 || audio_api_n >= n_apis)
  905. {
  906. audio_api_n = CONFIG::DEFAULT_AUDIO_API ;
  907. this->apiComboBox->setSelectedItemIndex(audio_api_n , juce::dontSendNotification) ;
  908. setConfig(CONFIG::AUDIO_API_ID , audio_api_n) ;
  909. }
  910. // set per API default params
  911. #ifdef _WIN32
  912. switch ((audioStreamer::WinApi)audio_api_n)
  913. {
  914. case audioStreamer::WIN_AUDIO_ASIO:
  915. {
  916. setConfig(CONFIG::ASIO_DRIVER_ID , CONFIG::DEFAULT_ASIO_DRIVERN ) ;
  917. setConfig(CONFIG::ASIO_INPUTB_ID , CONFIG::DEFAULT_ASIO_INPUTBN ) ;
  918. setConfig(CONFIG::ASIO_INPUTE_ID , CONFIG::DEFAULT_ASIO_INPUTEN ) ;
  919. setConfig(CONFIG::ASIO_OUTPUTB_ID , CONFIG::DEFAULT_ASIO_OUTPUTBN) ;
  920. setConfig(CONFIG::ASIO_OUTPUTE_ID , CONFIG::DEFAULT_ASIO_OUTPUTEN) ;
  921. break ;
  922. }
  923. case audioStreamer::WIN_AUDIO_KS:
  924. {
  925. setConfig(CONFIG::KS_INPUT_ID , CONFIG::DEFAULT_KS_INPUTN ) ;
  926. setConfig(CONFIG::KS_OUTPUT_ID , CONFIG::DEFAULT_KS_OUTPUTN ) ;
  927. setConfig(CONFIG::KS_SAMPLERATE_ID , CONFIG::DEFAULT_KS_SAMPLERATE) ;
  928. setConfig(CONFIG::KS_BITDEPTH_ID , CONFIG::DEFAULT_KS_BITDEPTH ) ;
  929. setConfig(CONFIG::KS_NBLOCKS_ID , CONFIG::DEFAULT_KS_NBLOCKS ) ;
  930. setConfig(CONFIG::KS_BLOCKSIZE_ID , CONFIG::DEFAULT_KS_BLOCKSIZE ) ;
  931. break ;
  932. }
  933. case audioStreamer::WIN_AUDIO_DS:
  934. {
  935. setConfig(CONFIG::DS_INPUT_ID , CONFIG::DEFAULT_DS_INPUT_NAME ) ;
  936. setConfig(CONFIG::DS_OUTPUT_ID , CONFIG::DEFAULT_DS_OUTPUT_NAME) ;
  937. setConfig(CONFIG::DS_SAMPLERATE_ID , CONFIG::DEFAULT_DS_SAMPLERATE ) ;
  938. setConfig(CONFIG::DS_BITDEPTH_ID , CONFIG::DEFAULT_DS_BITDEPTH ) ;
  939. setConfig(CONFIG::DS_NBLOCKS_ID , CONFIG::DEFAULT_DS_NBLOCKS ) ;
  940. setConfig(CONFIG::DS_BLOCKSIZE_ID , CONFIG::DEFAULT_DS_BLOCKSIZE ) ;
  941. break ;
  942. }
  943. case audioStreamer::WIN_AUDIO_WAVE:
  944. {
  945. setConfig(CONFIG::WAVE_INPUT_ID , CONFIG::DEFAULT_WAVE_INPUTN ) ;
  946. setConfig(CONFIG::WAVE_OUTPUT_ID , CONFIG::DEFAULT_WAVE_OUTPUTN ) ;
  947. setConfig(CONFIG::WAVE_SAMPLERATE_ID , CONFIG::DEFAULT_WAVE_SAMPLERATE) ;
  948. setConfig(CONFIG::WAVE_BITDEPTH_ID , CONFIG::DEFAULT_WAVE_BITDEPTH ) ;
  949. setConfig(CONFIG::WAVE_NBLOCKS_ID , CONFIG::DEFAULT_WAVE_NBLOCKS ) ;
  950. setConfig(CONFIG::WAVE_BLOCKSIZE_ID , CONFIG::DEFAULT_WAVE_BLOCKSIZE ) ;
  951. break ;
  952. }
  953. }
  954. #else // _WIN32
  955. # ifdef _MAC
  956. UNUSED(audio_api_n) ;
  957. setConfig(CONFIG::CA_INPUT_ID , CONFIG::DEFAULT_CA_INPUT_NAME ) ;
  958. setConfig(CONFIG::CA_OUTPUT_ID , CONFIG::DEFAULT_CA_OUTPUT_NAME) ;
  959. setConfig(CONFIG::CA_NCHANNELS_ID , CONFIG::DEFAULT_CA_NCHANNELS ) ;
  960. setConfig(CONFIG::CA_SAMPLERATE_ID , CONFIG::DEFAULT_CA_SAMPLERATE ) ;
  961. setConfig(CONFIG::CA_BITDEPTH_ID , CONFIG::DEFAULT_CA_BITDEPTH ) ;
  962. # else // _MAC
  963. switch ((audioStreamer::NixApi)audio_api_n)
  964. {
  965. case audioStreamer::NIX_AUDIO_JACK:
  966. {
  967. setConfig(CONFIG::JACK_SERVER_ID , CONFIG::DEFAULT_JACK_SERVERN ) ;
  968. setConfig(CONFIG::JACK_NAME_ID , CONFIG::DEFAULT_JACK_NAME ) ;
  969. setConfig(CONFIG::JACK_NINPUTS_ID , CONFIG::DEFAULT_JACK_NINPUTS ) ;
  970. setConfig(CONFIG::JACK_NOUTPUTS_ID , CONFIG::DEFAULT_JACK_NOUTPUTS) ;
  971. break ;
  972. }
  973. case audioStreamer::NIX_AUDIO_ALSA:
  974. {
  975. setConfig(CONFIG::ALSA_INPUT_ID , CONFIG::DEFAULT_ALSA_INPUT_NAME ) ;
  976. setConfig(CONFIG::ALSA_OUTPUT_ID , CONFIG::DEFAULT_ALSA_OUTPUT_NAME) ;
  977. setConfig(CONFIG::ALSA_NCHANNELS_ID , CONFIG::DEFAULT_ALSA_NCHANNELS ) ;
  978. setConfig(CONFIG::ALSA_SAMPLERATE_ID , CONFIG::DEFAULT_ALSA_SAMPLERATE ) ;
  979. setConfig(CONFIG::ALSA_BITDEPTH_ID , CONFIG::DEFAULT_ALSA_BITDEPTH ) ;
  980. setConfig(CONFIG::ALSA_NBLOCKS_ID , CONFIG::DEFAULT_ALSA_NBLOCKS ) ;
  981. setConfig(CONFIG::ALSA_BLOCKSIZE_ID , CONFIG::DEFAULT_ALSA_BLOCKSIZE ) ;
  982. break ;
  983. }
  984. }
  985. # endif // _MAC
  986. #endif // _WIN32
  987. }
  988. void ConfigAudio::disableComponents()
  989. {
  990. this->defaultsButton ->setVisible(false) ; this->asioButton ->setVisible(false) ;
  991. this->ioGroup ->setEnabled(false) ; //---------------ioGroup---------------->
  992. this->modeLabel ->setEnabled(false) ; this->apiComboBox ->setEnabled(false) ;
  993. this->driverLabel ->setEnabled(false) ; this->driverComboBox->setEnabled(false) ;
  994. this->sourceLabel ->setEnabled(false) ; this->sourceComboBox->setEnabled(false) ;
  995. this->sinkLabel ->setEnabled(false) ; this->sinkComboBox ->setEnabled(false) ;
  996. this->formatGroup ->setEnabled(false) ; //-------------formatGroup-------------->
  997. this->bitdepthLabel ->setEnabled(false) ; this->bps16Button ->setEnabled(false) ;
  998. this->bps24Button ->setEnabled(false) ; this->bps32Button ->setEnabled(false) ;
  999. this->samplerateLabel->setEnabled(false) ; this->kHz44Button ->setEnabled(false) ;
  1000. this->kHz48Button ->setEnabled(false) ; this->kHz96Button ->setEnabled(false) ;
  1001. this->buffersGroup ->setEnabled(false) ; //-------------buffersGroup------------->
  1002. this->buffersLabel ->setEnabled(false) ; this->nBuffersSlider->setEnabled(false) ;
  1003. this->xLabel ->setEnabled(false) ; this->bufferComboBox->setEnabled(false) ;
  1004. this->bytesLabel ->setEnabled(false) ;
  1005. this->routingGroup ->setEnabled(false) ; //-------------routingGroup------------->
  1006. this->jackNameLabel ->setEnabled(false) ; this->jackNameText ->setEnabled(false) ;
  1007. this->nSourcesLabel ->setEnabled(false) ; this->nSourcesSlider->setEnabled(false) ;
  1008. this->nSinksLabel ->setEnabled(false) ; this->nSinksSlider ->setEnabled(false) ;
  1009. }
  1010. void ConfigAudio::enableComponents()
  1011. {
  1012. int audio_api_n = int(this->audioStore[CONFIG::AUDIO_API_ID]) ;
  1013. bool is_asio , is_ks , is_ds , is_wave , is_ca , is_jack , is_alsa ;
  1014. is_asio = is_ks = is_ds = is_wave = is_ca = is_jack = is_alsa = false ;
  1015. #ifdef _WIN32
  1016. is_asio = audio_api_n == audioStreamer::WIN_AUDIO_ASIO ; // ASIO
  1017. is_ks = audio_api_n == audioStreamer::WIN_AUDIO_KS ; // KernelStreaming
  1018. is_ds = audio_api_n == audioStreamer::WIN_AUDIO_DS ; // DirectSound
  1019. is_wave = audio_api_n == audioStreamer::WIN_AUDIO_WAVE ; // Wave
  1020. #else // _WIN32
  1021. # ifdef _MAC
  1022. is_ca = audio_api_n == audioStreamer::MAC_AUDIO_CA ; // CoreAudio
  1023. # else // _MAC
  1024. is_jack = audio_api_n == audioStreamer::NIX_AUDIO_JACK ; // JACK
  1025. is_alsa = audio_api_n == audioStreamer::NIX_AUDIO_ALSA ; // ALSA
  1026. # endif // _MAC
  1027. #endif // _WIN32
  1028. // common
  1029. this->defaultsButton ->setVisible(!is_asio ) ;
  1030. this->asioButton ->setVisible( is_asio ) ;
  1031. // io group
  1032. this->ioGroup ->setEnabled(true ) ;
  1033. this->modeLabel ->setEnabled(!is_ca ) ;
  1034. this->apiComboBox ->setEnabled(!is_ca ) ;
  1035. this->driverLabel ->setEnabled( is_asio || is_jack ) ;
  1036. this->driverComboBox ->setEnabled( is_asio || is_jack ) ;
  1037. this->sourceLabel ->setEnabled(!is_asio && !is_jack ) ;
  1038. this->sourceComboBox ->setEnabled(!is_asio && !is_jack ) ;
  1039. this->sinkLabel ->setEnabled(!is_asio && !is_jack ) ;
  1040. this->sinkComboBox ->setEnabled(!is_asio && !is_jack ) ;
  1041. // format group
  1042. this->formatGroup ->setEnabled( is_ks || is_ds || is_wave || is_ca || is_alsa) ;
  1043. this->bitdepthLabel ->setEnabled( is_ks || is_ds || is_wave || is_ca || is_alsa) ;
  1044. this->bps16Button ->setEnabled( is_ks || is_ds || is_wave || is_ca || is_alsa) ;
  1045. this->bps24Button ->setEnabled( is_ks || is_ds || is_wave || is_ca || is_alsa) ;
  1046. this->bps32Button ->setEnabled( is_ks || is_ds || is_wave || is_ca || is_alsa) ;
  1047. this->samplerateLabel->setEnabled( is_ks || is_ds || is_wave || is_ca || is_alsa) ;
  1048. this->kHz44Button ->setEnabled( is_ks || is_ds || is_wave || is_ca || is_alsa) ;
  1049. this->kHz48Button ->setEnabled( is_ks || is_ds || is_wave || is_ca || is_alsa) ;
  1050. this->kHz96Button ->setEnabled( is_ks || is_ds || is_wave || is_ca || is_alsa) ;
  1051. // buffers group
  1052. this->buffersGroup ->setEnabled( is_ks || is_ds || is_wave || is_alsa ) ;
  1053. this->buffersLabel ->setEnabled( is_ks || is_ds || is_wave || is_alsa ) ;
  1054. this->nBuffersSlider ->setEnabled( is_ks || is_ds || is_wave || is_alsa ) ;
  1055. this->xLabel ->setEnabled( is_ks || is_ds || is_wave || is_alsa ) ;
  1056. this->bufferComboBox ->setEnabled( is_ks || is_ds || is_wave || is_alsa ) ;
  1057. this->bytesLabel ->setEnabled( is_ks || is_ds || is_wave || is_alsa ) ;
  1058. // routing group
  1059. this->routingGroup ->setEnabled( is_jack || is_alsa || is_ca ) ;
  1060. this->jackNameLabel ->setEnabled( is_jack || is_alsa ) ;
  1061. this->jackNameText ->setEnabled( is_jack || is_alsa ) ;
  1062. this->nSourcesLabel ->setEnabled( is_jack || is_ca || is_alsa ) ;
  1063. this->nSourcesSlider ->setEnabled( is_jack || is_ca || is_alsa ) ;
  1064. this->nSinksLabel ->setEnabled( is_jack ) ;
  1065. this->nSinksSlider ->setEnabled( is_jack ) ;
  1066. DEBUG_TRACE_CONFIG_AUDIO_GUI_LOAD
  1067. }
  1068. #ifdef _WIN32
  1069. bool ConfigAudio::queryAsioDevices()
  1070. {
  1071. # ifndef NO_SUPPORT_ASIO
  1072. bool is_asio_available = audioStreamer::IsNjasiodrvAvailable() ;
  1073. String asio_driver_name = audioStreamer::GetASIODriverName() ;
  1074. # else // NO_SUPPORT_ASIO
  1075. bool is_asio_available = false ;
  1076. # endif // NO_SUPPORT_ASIO
  1077. if (is_asio_available && asio_driver_name.isNotEmpty())
  1078. {
  1079. this->driverComboBox->addItem(asio_driver_name , 1) ;
  1080. this->sourceComboBox->addItem("ASIO device 0" , 1) ;
  1081. this->sinkComboBox ->addItem("ASIO device 0" , 1) ;
  1082. }
  1083. else
  1084. {
  1085. this->driverComboBox->addItem("(ASIO unavailable)" , 1) ;
  1086. this->sourceComboBox->addItem("(ASIO unavailable)" , 1) ;
  1087. this->sinkComboBox ->addItem("(ASIO unavailable)" , 1) ;
  1088. }
  1089. return is_asio_available ;
  1090. }
  1091. bool ConfigAudio::queryKsDevices()
  1092. {
  1093. # ifndef NO_SUPPORT_KS
  1094. bool is_ks_available = true ; // TODO:
  1095. # else // NO_SUPPORT_KS
  1096. bool is_ks_available = false ;
  1097. # endif // NO_SUPPORT_KS
  1098. this->sourceComboBox->clear(juce::dontSendNotification) ;
  1099. this->sinkComboBox ->clear(juce::dontSendNotification) ;
  1100. if (is_ks_available)
  1101. {
  1102. this->sourceComboBox->addItem("default device" , 1) ;
  1103. this->sinkComboBox ->addItem("default device" , 1) ;
  1104. this->bufferComboBox->addItemList(GUI::BUFFER_SIZES , 1) ;
  1105. }
  1106. else
  1107. {
  1108. this->sourceComboBox->addItem("(kernel-streaming unavailable)" , 1) ;
  1109. this->sinkComboBox ->addItem("(kernel-streaming unavailable)" , 1) ;
  1110. }
  1111. return is_ks_available ;
  1112. }
  1113. bool ConfigAudio::queryDsDevices()
  1114. {
  1115. # ifndef NO_SUPPORT_DS
  1116. String device_names = audioStreamer::GetDsNamesCSV("\n") ;
  1117. StringArray ds_device_names = StringArray::fromLines(device_names) ;
  1118. bool is_ds_available = !!ds_device_names.size() ;
  1119. if (is_ds_available)
  1120. {
  1121. this->sourceComboBox->addItemList(ds_device_names , 1) ;
  1122. this->sinkComboBox ->addItemList(ds_device_names , 1) ;
  1123. this->bufferComboBox->addItemList(GUI::BUFFER_SIZES , 1) ;
  1124. }
  1125. else
  1126. {
  1127. this->sourceComboBox->addItem("(directsound unavaliable)" , 1) ;
  1128. this->sinkComboBox ->addItem("(directsound unavaliable)" , 1) ;
  1129. }
  1130. return is_ds_available ;
  1131. # else // NO_SUPPORT_DS
  1132. return false ;
  1133. # endif // NO_SUPPORT_DS
  1134. }
  1135. bool ConfigAudio::queryWaveDevices()
  1136. {
  1137. # ifndef NO_SUPPORT_WAVE
  1138. // NOTE: see MMsystem.h
  1139. WAVEOUTCAPS capabilities ;
  1140. StringArray wave_device_names ;
  1141. UINT caps_size = sizeof(capabilities) ;
  1142. int n_devices = (int)waveOutGetNumDevs() ;
  1143. bool is_wave_available = !!n_devices ;
  1144. if (n_devices)
  1145. {
  1146. for (int device_n = -1 ; device_n < n_devices ; ++device_n)
  1147. {
  1148. if (waveOutGetDevCaps(device_n , &capabilities , caps_size) == MMSYSERR_NOERROR)
  1149. wave_device_names.add(capabilities.szPname) ;
  1150. else wave_device_names.add("(device error)" ) ;
  1151. }
  1152. this->sourceComboBox->addItemList(wave_device_names , 1) ;
  1153. this->sinkComboBox ->addItemList(wave_device_names , 1) ;
  1154. this->bufferComboBox->addItemList(GUI::BUFFER_SIZES , 1) ;
  1155. }
  1156. else
  1157. {
  1158. this->sourceComboBox->addItem("(no wave devices found)" , 1) ;
  1159. this->sinkComboBox ->addItem("(no wave devices found)" , 1) ;
  1160. }
  1161. return is_wave_available ;
  1162. # else // NO_SUPPORT_WAVE
  1163. return false ;
  1164. # endif // NO_SUPPORT_WAVE
  1165. }
  1166. #else // _WIN32
  1167. # ifdef _MAC
  1168. bool ConfigAudio::queryCaDevices() // TODO: juce or ryo ? (issue #12)
  1169. {
  1170. bool is_ca_available = true ;
  1171. this->sourceComboBox->addItem("(default coreaudio device)" , 1) ;
  1172. this->sinkComboBox ->addItem("(default coreaudio device)" , 1) ;
  1173. return is_ca_available ;
  1174. }
  1175. # else // _MAC
  1176. bool ConfigAudio::queryJackServers() // TODO: juce or ryo ? (issue #12)
  1177. {
  1178. // jackd -R -S -d portaudio -l // on windows returns wav, ds, and asio devices
  1179. bool is_jack_available = true ;
  1180. this->driverComboBox->addItem("default jack server" , 1) ;
  1181. return is_jack_available ;
  1182. }
  1183. bool ConfigAudio::queryAlsaDevices() // TODO: juce or ryo ? (issue #12)
  1184. {
  1185. this->sourceComboBox->addItem(CONFIG::DEFAULT_ALSA_INPUT_NAME , 1) ;
  1186. this->sinkComboBox ->addItem(CONFIG::DEFAULT_ALSA_OUTPUT_NAME , 1) ;
  1187. this->bufferComboBox->addItemList(GUI::BUFFER_SIZES , 1) ;
  1188. return true ;
  1189. }
  1190. # endif // _MAC
  1191. #endif // _WIN32
  1192. int ConfigAudio::getItemIndex(ComboBox* combo_box , String item_text)
  1193. {
  1194. int item_n = combo_box->getNumItems() ;
  1195. while (item_n-- && combo_box->getItemText(item_n).compare(item_text)) ;
  1196. return item_n ;
  1197. }
  1198. void ConfigAudio::updateLatency()
  1199. {
  1200. int audio_api_n = int(this->audioStore[CONFIG::AUDIO_API_ID]) ;
  1201. String latency_text = "" ;
  1202. int n_channels , sample_rate , bit_depth , n_buffers , buffer_size ;
  1203. n_channels = sample_rate = bit_depth = n_buffers = buffer_size = 0 ;
  1204. #ifdef _WIN32
  1205. switch ((audioStreamer::WinApi)audio_api_n)
  1206. {
  1207. case audioStreamer::WIN_AUDIO_KS:
  1208. {
  1209. n_channels = 2 ;
  1210. sample_rate = int(this->audioStore[CONFIG::KS_SAMPLERATE_ID]) ;
  1211. bit_depth = int(this->audioStore[CONFIG::KS_BITDEPTH_ID ]) ;
  1212. n_buffers = int(this->audioStore[CONFIG::KS_NBLOCKS_ID ]) ;
  1213. buffer_size = int(this->audioStore[CONFIG::KS_BLOCKSIZE_ID ]) ;
  1214. break ;
  1215. }
  1216. case audioStreamer::WIN_AUDIO_DS:
  1217. {
  1218. n_channels = 2 ;
  1219. sample_rate = int(this->audioStore[CONFIG::DS_SAMPLERATE_ID]) ;
  1220. bit_depth = int(this->audioStore[CONFIG::DS_BITDEPTH_ID ]) ;
  1221. n_buffers = int(this->audioStore[CONFIG::DS_NBLOCKS_ID ]) ;
  1222. buffer_size = int(this->audioStore[CONFIG::DS_BLOCKSIZE_ID ]) ;
  1223. break ;
  1224. }
  1225. case audioStreamer::WIN_AUDIO_WAVE:
  1226. {
  1227. n_channels = 2 ;
  1228. sample_rate = int(this->audioStore[CONFIG::WAVE_SAMPLERATE_ID]) ;
  1229. bit_depth = int(this->audioStore[CONFIG::WAVE_BITDEPTH_ID ]) ;
  1230. n_buffers = int(this->audioStore[CONFIG::WAVE_NBLOCKS_ID ]) ;
  1231. buffer_size = int(this->audioStore[CONFIG::WAVE_BLOCKSIZE_ID ]) ;
  1232. break ;
  1233. }
  1234. default: break ;
  1235. }
  1236. #else // _WIN32
  1237. # ifndef _MAC
  1238. switch ((audioStreamer::NixApi)audio_api_n)
  1239. {
  1240. case audioStreamer::NIX_AUDIO_JACK:
  1241. {
  1242. // TODO: ask jack? ask NJClient?
  1243. break ;
  1244. }
  1245. case audioStreamer::NIX_AUDIO_ALSA:
  1246. {
  1247. n_channels = 2 ;
  1248. n_channels = int(this->audioStore[CONFIG::ALSA_NCHANNELS_ID ]) ;
  1249. sample_rate = int(this->audioStore[CONFIG::ALSA_SAMPLERATE_ID]) ;
  1250. bit_depth = int(this->audioStore[CONFIG::ALSA_BITDEPTH_ID ]) ;
  1251. n_buffers = int(this->audioStore[CONFIG::ALSA_NBLOCKS_ID ]) ;
  1252. buffer_size = int(this->audioStore[CONFIG::ALSA_BLOCKSIZE_ID ]) ;
  1253. break ;
  1254. }
  1255. default: break ;
  1256. }
  1257. # endif // _MAC
  1258. #endif // _WIN32
  1259. if (!!n_channels)
  1260. {
  1261. int bytes_per_ms = (sample_rate * (bit_depth / 8) * n_channels) / 1000 ;
  1262. int latency_ms = (n_buffers * buffer_size) / bytes_per_ms ;
  1263. latency_text = (!!latency_ms) ? " (" + String(latency_ms) + "ms)" : "" ;
  1264. DEBUG_TRACE_UPDATE_LATENCY
  1265. }
  1266. this->buffersGroup->setText(GUI::BUFFERS_GROUP_TEXT + latency_text) ;
  1267. }
  1268. void ConfigAudio::setConfig(Identifier a_key , var a_value)
  1269. {
  1270. if (a_key.isValid()) this->audioStore.setProperty(a_key , a_value , nullptr) ;
  1271. }
  1272. //[/MiscUserCode]
  1273. //==============================================================================
  1274. #if 0
  1275. /* -- Introjucer information section --
  1276. This is where the Introjucer stores the metadata that describe this GUI layout, so
  1277. make changes in here at your peril!
  1278. BEGIN_JUCER_METADATA
  1279. <JUCER_COMPONENT documentType="Component" className="ConfigAudio" componentName=""
  1280. parentClasses="public Component" constructorParams="ValueTree audio_store"
  1281. variableInitialisers="audioStore(audio_store)" snapPixels="8"
  1282. snapActive="1" snapShown="1" overlayOpacity="0.330" fixedSize="1"
  1283. initialWidth="614" initialHeight="434">
  1284. <BACKGROUND backgroundColour="0">
  1285. <ROUNDRECT pos="0 0 0M 0M" cornerSize="10" fill="solid: ff002000" hasStroke="0"/>
  1286. </BACKGROUND>
  1287. <GROUPCOMPONENT name="ioGroup" id="35b859a43662c4ca" memberName="ioGroup" virtualName=""
  1288. explicitFocusOrder="0" pos="132 38 350 126" outlinecol="ff808080"
  1289. textcol="ffffffff" title="i/o" textpos="33"/>
  1290. <GROUPCOMPONENT name="formatGroup" id="29fbf63c3d8d3e1b" memberName="formatGroup"
  1291. virtualName="" explicitFocusOrder="0" pos="132 176 350 60" outlinecol="ff808080"
  1292. textcol="ffffffff" title="format" textpos="33"/>
  1293. <GROUPCOMPONENT name="buffersGroup" id="76ccd33b9d1f605a" memberName="buffersGroup"
  1294. virtualName="" explicitFocusOrder="0" pos="132 250 350 48" outlinecol="ff808080"
  1295. textcol="ffffffff" title="buffers (122.2ms)" textpos="33"/>
  1296. <GROUPCOMPONENT name="routingGroup" id="65c871d13e6e8329" memberName="routingGroup"
  1297. virtualName="" explicitFocusOrder="0" pos="132 312 350 74" outlinecol="ff808080"
  1298. textcol="ffffffff" title="routing" textpos="33"/>
  1299. <TEXTBUTTON name="defaultsButton" id="f03cc2695d9642e1" memberName="defaultsButton"
  1300. virtualName="" explicitFocusOrder="0" pos="68R 4 64 24" buttonText="defaults"
  1301. connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  1302. <TEXTBUTTON name="asioButton" id="130c484d97b7c34a" memberName="asioButton"
  1303. virtualName="" explicitFocusOrder="0" pos="68R 4 64 24" buttonText="asio config"
  1304. connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  1305. <LABEL name="modeLabel" id="582ccc898eac60c0" memberName="modeLabel"
  1306. virtualName="" explicitFocusOrder="0" pos="140 56 64 18" textCol="ffffffff"
  1307. edTextCol="ff000000" edBkgCol="0" labelText="interface:" editableSingleClick="0"
  1308. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  1309. fontsize="15" bold="0" italic="0" justification="33"/>
  1310. <COMBOBOX name="apiComboBox" id="d9fdbc02138c7335" memberName="apiComboBox"
  1311. virtualName="" explicitFocusOrder="1" pos="212 56 256 18" editable="0"
  1312. layout="33" items="" textWhenNonSelected="" textWhenNoItems="(no choices)"/>
  1313. <LABEL name="driverLabel" id="5cb85d669129843" memberName="driverLabel"
  1314. virtualName="" explicitFocusOrder="0" pos="140 82 64 18" textCol="ffffffff"
  1315. edTextCol="ff000000" edBkgCol="0" labelText="driver:" editableSingleClick="0"
  1316. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  1317. fontsize="15" bold="0" italic="0" justification="33"/>
  1318. <COMBOBOX name="driverComboBox" id="bc523f21b8e70676" memberName="driverComboBox"
  1319. virtualName="" explicitFocusOrder="1" pos="212 82 256 18" editable="0"
  1320. layout="33" items="" textWhenNonSelected="" textWhenNoItems="(no choices)"/>
  1321. <LABEL name="sourceLabel" id="28e9c840504ea936" memberName="sourceLabel"
  1322. virtualName="" explicitFocusOrder="0" pos="140 108 64 18" textCol="ffffffff"
  1323. edTextCol="ff000000" edBkgCol="0" labelText="input:" editableSingleClick="0"
  1324. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  1325. fontsize="15" bold="0" italic="0" justification="33"/>
  1326. <COMBOBOX name="sourceComboBox" id="195d38c0dfa0b780" memberName="sourceComboBox"
  1327. virtualName="" explicitFocusOrder="2" pos="212 108 256 18" editable="0"
  1328. layout="33" items="" textWhenNonSelected="" textWhenNoItems="(no choices)"/>
  1329. <LABEL name="sinkLabel" id="a67b459c94aba72e" memberName="sinkLabel"
  1330. virtualName="" explicitFocusOrder="0" pos="140 134 64 16" textCol="ffffffff"
  1331. edTextCol="ff000000" edBkgCol="0" labelText="output:" editableSingleClick="0"
  1332. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  1333. fontsize="15" bold="0" italic="0" justification="33"/>
  1334. <COMBOBOX name="sinkComboBox" id="3b81e2ff4dec7469" memberName="sinkComboBox"
  1335. virtualName="" explicitFocusOrder="3" pos="212 134 256 18" editable="0"
  1336. layout="33" items="" textWhenNonSelected="" textWhenNoItems="(no choices)"/>
  1337. <LABEL name="bitdepthLabel" id="cca18f8e57581cc5" memberName="bitdepthLabel"
  1338. virtualName="" explicitFocusOrder="0" pos="140 190 64 18" textCol="ffffffff"
  1339. edTextCol="ff000000" edBkgCol="0" labelText="bit depth:" editableSingleClick="0"
  1340. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  1341. fontsize="15" bold="0" italic="0" justification="33"/>
  1342. <TOGGLEBUTTON name="bps16Button" id="ccb740c03ababc9f" memberName="bps16Button"
  1343. virtualName="" explicitFocusOrder="4" pos="212 191 64 18" txtcol="ffffffff"
  1344. buttonText="16bit" connectedEdges="0" needsCallback="1" radioGroupId="1"
  1345. state="1"/>
  1346. <TOGGLEBUTTON name="bps24Button" id="2bfc206fbb162f7f" memberName="bps24Button"
  1347. virtualName="" explicitFocusOrder="5" pos="288 191 64 18" txtcol="ffffffff"
  1348. buttonText="24bit" connectedEdges="0" needsCallback="1" radioGroupId="1"
  1349. state="0"/>
  1350. <TOGGLEBUTTON name="bps32Button" id="1cc075dc412ce404" memberName="bps32Button"
  1351. virtualName="" explicitFocusOrder="6" pos="364 191 64 18" txtcol="ffffffff"
  1352. buttonText="32bit" connectedEdges="0" needsCallback="1" radioGroupId="1"
  1353. state="0"/>
  1354. <LABEL name="samplerateLabel" id="e79ba6de77a4b042" memberName="samplerateLabel"
  1355. virtualName="" explicitFocusOrder="0" pos="140 210 72 18" textCol="ffffffff"
  1356. edTextCol="ff000000" edBkgCol="0" labelText="sample rate:" editableSingleClick="0"
  1357. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  1358. fontsize="15" bold="0" italic="0" justification="33"/>
  1359. <TOGGLEBUTTON name="kHz44Button" id="56ab804241495c7b" memberName="kHz44Button"
  1360. virtualName="" explicitFocusOrder="7" pos="212 211 64 18" txtcol="ffffffff"
  1361. buttonText="44.1kHz" connectedEdges="0" needsCallback="1" radioGroupId="2"
  1362. state="1"/>
  1363. <TOGGLEBUTTON name="kHz48Button" id="415b27279e48004f" memberName="kHz48Button"
  1364. virtualName="" explicitFocusOrder="8" pos="288 211 64 18" txtcol="ffffffff"
  1365. buttonText="48kHz" connectedEdges="0" needsCallback="1" radioGroupId="2"
  1366. state="0"/>
  1367. <TOGGLEBUTTON name="kHz96Button" id="4241809c486a0995" memberName="kHz96Button"
  1368. virtualName="" explicitFocusOrder="9" pos="364 211 64 18" txtcol="ffffffff"
  1369. buttonText="96kHz" connectedEdges="0" needsCallback="1" radioGroupId="2"
  1370. state="0"/>
  1371. <LABEL name="buffersLabel" id="78ac240fcc5eed16" memberName="buffersLabel"
  1372. virtualName="" explicitFocusOrder="0" pos="140 268 64 18" textCol="ffffffff"
  1373. edTextCol="ff000000" edBkgCol="0" labelText="# of buffers" editableSingleClick="0"
  1374. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  1375. fontsize="15" bold="0" italic="0" justification="33"/>
  1376. <SLIDER name="nBuffersSlider" id="76a832d1fac666e" memberName="nBuffersSlider"
  1377. virtualName="" explicitFocusOrder="10" pos="212 268 64 18" min="0"
  1378. max="16" int="1" style="IncDecButtons" textBoxPos="TextBoxLeft"
  1379. textBoxEditable="0" textBoxWidth="80" textBoxHeight="20" skewFactor="1"/>
  1380. <LABEL name="xLabel" id="5a9596c9eb8db178" memberName="xLabel" virtualName=""
  1381. explicitFocusOrder="0" pos="275 268 16 18" textCol="ffffffff"
  1382. edTextCol="ff000000" edBkgCol="0" labelText="x" editableSingleClick="0"
  1383. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  1384. fontsize="15" bold="0" italic="0" justification="33"/>
  1385. <COMBOBOX name="bufferComboBox" id="bef2196516ab5821" memberName="bufferComboBox"
  1386. virtualName="" explicitFocusOrder="11" pos="292 268 52 18" editable="0"
  1387. layout="33" items="" textWhenNonSelected="" textWhenNoItems="(no choices)"/>
  1388. <LABEL name="bytesLabel" id="f93456e3175d33d6" memberName="bytesLabel"
  1389. virtualName="" explicitFocusOrder="0" pos="346 268 64 18" textCol="ffffffff"
  1390. edTextCol="ff000000" edBkgCol="0" labelText="bytes" editableSingleClick="0"
  1391. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  1392. fontsize="15" bold="0" italic="0" justification="33"/>
  1393. <LABEL name="jackNameLabel" id="78568b552c534b6d" memberName="jackNameLabel"
  1394. virtualName="" explicitFocusOrder="0" pos="140 332 64 18" textCol="ffffffff"
  1395. edTextCol="ff000000" edBkgCol="0" labelText="client name" editableSingleClick="0"
  1396. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  1397. fontsize="15" bold="0" italic="0" justification="33"/>
  1398. <TEXTEDITOR name="jackNameText" id="fdccbcd88a94d4bb" memberName="jackNameText"
  1399. virtualName="" explicitFocusOrder="12" pos="212 332 136 18" textcol="ff808080"
  1400. bkgcol="ff000000" initialText="" multiline="0" retKeyStartsLine="0"
  1401. readonly="0" scrollbars="1" caret="1" popupmenu="0"/>
  1402. <LABEL name="nSourcesLabel" id="fa0df2e2a11e57d8" memberName="nSourcesLabel"
  1403. virtualName="" explicitFocusOrder="0" pos="140 358 64 18" textCol="ffffffff"
  1404. edTextCol="ff000000" edBkgCol="0" labelText="# of sources" editableSingleClick="0"
  1405. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  1406. fontsize="15" bold="0" italic="0" justification="33"/>
  1407. <SLIDER name="nSourcesSlider" id="3a13d77beb71d910" memberName="nSourcesSlider"
  1408. virtualName="" explicitFocusOrder="14" pos="214 358 64 18" min="0"
  1409. max="16" int="1" style="IncDecButtons" textBoxPos="TextBoxLeft"
  1410. textBoxEditable="0" textBoxWidth="80" textBoxHeight="20" skewFactor="1"/>
  1411. <LABEL name="nSinksLabel" id="2da0a2441a20f3b0" memberName="nSinksLabel"
  1412. virtualName="" explicitFocusOrder="0" pos="330 358 64 18" textCol="ffffffff"
  1413. edTextCol="ff000000" edBkgCol="0" labelText="# of sinks" editableSingleClick="0"
  1414. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  1415. fontsize="15" bold="0" italic="0" justification="33"/>
  1416. <SLIDER name="nSinksSlider" id="182ff4a5ae799417" memberName="nSinksSlider"
  1417. virtualName="" explicitFocusOrder="15" pos="404 358 64 18" min="0"
  1418. max="16" int="1" style="IncDecButtons" textBoxPos="TextBoxLeft"
  1419. textBoxEditable="0" textBoxWidth="80" textBoxHeight="20" skewFactor="1"/>
  1420. <TOGGLEBUTTON name="jackPortsButton" id="2e760aa1269d4107" memberName="jackPortsButton"
  1421. virtualName="" explicitFocusOrder="13" pos="352 332 120 18" txtcol="ffffffff"
  1422. buttonText="auto-connect ports" connectedEdges="0" needsCallback="1"
  1423. radioGroupId="0" state="1"/>
  1424. </JUCER_COMPONENT>
  1425. END_JUCER_METADATA
  1426. */
  1427. #endif
  1428. //[EndFile] You can add extra defines here...
  1429. //[/EndFile]