21#include <wx/tooltip.h>
23#include "../ActiveProject.h"
29#include "../KeyboardCapture.h"
31#include "../ProjectWindows.h"
33#include "../prefs/PrefsDialog.h"
34#include "../prefs/DevicePrefs.h"
35#include "../widgets/AButton.h"
36#include "../widgets/BasicMenu.h"
77 return wxT(
"Audio Setup");
108 wxSizeEvent event(GetSize(), GetId());
109 event.SetEventObject(
this);
110 GetEventHandler()->ProcessEvent(event);
131 wxToolTip::Enable(
true);
132 wxToolTip::SetDelay(1000);
170 SetMinSize(
GetSizer()->GetMinSize());
175 const auto isAudioSetupDown =
mAudioSetup !=
nullptr
181 if (isAudioSetupDown)
202 menu.AppendSeparator();
207 menu.AppendSeparator();
212 menu.AppendSeparator();
217 menu.AppendSeparator();
226 wxRect r = btn->GetRect();
229 { r.GetLeft(), r.GetBottom() }
240 wxString oldHost = selectedHost ? *selectedHost : wxString{};
246 if (oldHost != hostName)
252 if (sourceName.empty())
255 desc = devName +
wxT(
": ") + sourceName;
262 for (
size_t i = 0; i < inMaps.size(); i++) {
263 if (inMaps[i].hostString == hostName &&
284 if (sourceName.empty())
287 desc = devName +
wxT(
": ") + sourceName;
291 for (
size_t i = 0; i < outMaps.size(); i++) {
292 if (outMaps[i].hostString == hostName &&
316 if (newChannels > 0 && oldChannels != newChannels)
320 if (!hostName.empty() && selectedHost && *selectedHost != hostName)
348 bool audioStreamActive = gAudioIO->IsStreamActive() && !gAudioIO->IsMonitoring();
350 if (audioStreamActive) {
364 auto pCtrl =
static_cast<AButton*
>(this->FindWindow(iWinID));
369 name =
wxT(
"Open Audio Setup");
372 std::vector<ComponentInterfaceSymbol> commands(
405 for (
auto & device : inMaps) {
407 hosts.push_back(device.hostString);
411 for (
auto & device : outMaps) {
413 hosts.push_back(device.hostString);
427 int foundHostIndex = -1;
436 for (
auto & device : outMaps) {
437 if (device.hostString == host) {
438 foundHostIndex = device.hostIndex;
443 if (foundHostIndex == -1) {
444 for (
auto & device : inMaps) {
445 if (device.hostString == host) {
446 foundHostIndex = device.hostIndex;
453 if (foundHostIndex == -1) {
454 if (outMaps.size()) {
455 foundHostIndex = outMaps[0].hostIndex;
457 else if (inMaps.size()) {
458 foundHostIndex = inMaps[0].hostIndex;
467 if (foundHostIndex == -1) {
473 for (
size_t i = 0; i < inMaps.size(); ++i) {
474 auto& device = inMaps[i];
475 if (foundHostIndex == device.hostIndex) {
478 host = device.hostString;
484 mInput.
Set(std::move(mInputDeviceNames));
487 for (
size_t i = 0; i < outMaps.size(); ++i) {
488 auto& device = outMaps[i];
489 if (foundHostIndex == device.hostIndex) {
492 host = device.hostString;
511 long newChannels = 0;
517 for (
auto & dev: inMaps) {
518 if (source == dev.sourceString &&
519 device == dev.deviceString &&
520 host == dev.hostString) {
523 for (
size_t j = 0; j < (
unsigned int)dev.numChannels; j++) {
527 name =
_(
"1 (Mono) Recording Channel");
530 name =
_(
"2 (Stereo) Recording Channels");
533 name = wxString::Format(
wxT(
"%d"), (
int)j + 1);
537 newChannels = dev.numChannels;
538 if (oldChannels <= newChannels && oldChannels >= 1) {
539 newChannels = oldChannels;
546 if (newChannels >= 1)
552 wxMenu& menu,
const wxArrayString &labels,
int checkedItem,
555 auto subMenu = std::make_unique<wxMenu>();
557 for (
const auto &
label : labels) {
559 auto subMenuItem = subMenu->AppendRadioItem(wxID_ANY,
label);
560 if (ii == checkedItem)
561 subMenuItem->Check();
562 subMenu->Bind(wxEVT_MENU,
563 [&toolbar, callback, ii](wxCommandEvent &){ (toolbar.*callback)(ii); },
564 subMenuItem->GetId());
567 auto menuItem = menu.AppendSubMenu(subMenu.release(),
title);
569 menuItem->Enable(
false);
596 const auto newHost = *
name;
598 if (oldHost == newHost)
638 int deviceId,
Choices &choices,
bool isInput)
646 if (choices.
Set(deviceId)) {
648 wxString newDevice = *choices.
Get();
649 for (
size_t i = 0; i < maps.size(); ++i) {
651 if (
name == newDevice && maps[i].hostString == host)
657 wxLogDebug(
wxT(
"AudioSetupToolBar::ChangeDeviceLabel(): couldn't find device indices"));
661 SetDevices(isInput ? &maps[newIndex] :
nullptr,
662 isInput ?
nullptr : &maps[newIndex]);
721 if (gAudioIO->IsMonitoring())
723 gAudioIO->StopStream();
724 while (gAudioIO->IsBusy()) {
725 using namespace std::chrono;
726 std::this_thread::sleep_for(100ms);
730 if (audioSettingsChosen) {
734 ViewDeviceSettingsDialog dialog(
736 dialog.SetSize(600, 420);
739 if (0 != dialog.ShowModal()) {
744 gAudioIO->HandleDeviceChange();
StringSetting AudioIORecordingSource
StringSetting AudioIOPlaybackSource
StringSetting AudioIOPlaybackDevice
StringSetting AudioIORecordingDevice
StringSetting AudioIOHost
IntSetting AudioIORecordingSourceIndex
IntSetting AudioIORecordChannels
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
wxString MakeDeviceSourceString(const DeviceSourceMap *map)
PrefsPanel * DevicePrefsFactory(wxWindow *parent, wxWindowID winid, AudacityProject *project)
XXO("&Cut/Copy/Paste Toolbar")
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
audacity::BasicSettings * gPrefs
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
static AudioIOBase * Get()
void Popup(const BasicUI::WindowPlacement &window, const Point &pos={})
Display the menu at pos, invoke at most one action, then hide it.
size_t size() const
How many attachment pointers are in the Site.
DeviceSourceMap * GetDefaultInputDevice(int hostIndex)
const std::vector< DeviceSourceMap > & GetInputDeviceMaps()
const std::vector< DeviceSourceMap > & GetOutputDeviceMaps()
static DeviceManager * Instance()
Gets the singleton instance.
An explicitly nonlocalized string, not meant for the user to see.
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Dialog that shows the current PrefsPanel in a tabbed divider.
static void Broadcast(int id=0)
Call this static function to notify all PrefsListener objects.
virtual void UpdateSelectedPrefs(int id)
std::vector< PrefsPanel::PrefsNode > Factories
bool Write(const T &value)
Write value to config and return true if successful.
bool ReadWithDefault(T *pVar, const T &defaultValue) const
overload of ReadWithDefault returning a boolean that is true if the value was previously defined */
bool Reset()
Reset to the default value.
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined */
wxColour & Colour(int iIndex)
wxImage & Image(int iIndex)
Holds a msgid for the translation catalog; may also bind format arguments.
virtual bool Flush() noexcept=0
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
void OnFocus(wxWindow &window, wxFocusEvent &event)
a function useful to implement a focus event handler The window releases the keyboard if the event is...
const TranslatableString desc