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);
143#ifndef USE_AQUA_THEME
144 wxSize s =
mSizer->GetSize();
145 wxPoint p =
mSizer->GetPosition();
147 wxRect bevelRect(p.x, p.y, s.GetWidth() - 1, s.GetHeight() - 1);
170 int flags = wxALIGN_CENTER | wxRIGHT;
176 std::unique_ptr < wxSizer > {
mSizer};
188 SetMinSize(
GetSizer()->GetMinSize());
193 bool isAudioSetupDown =
false;
203 std::unique_ptr < wxSizer > {
mSizer};
209 if (isAudioSetupDown)
230 menu.AppendSeparator();
235 menu.AppendSeparator();
240 menu.AppendSeparator();
245 menu.AppendSeparator();
254 wxRect r = btn->GetRect();
257 { r.GetLeft(), r.GetBottom() }
268 wxString oldHost = selectedHost ? *selectedHost : wxString{};
274 if (oldHost != hostName)
280 if (sourceName.empty())
283 desc = devName +
wxT(
": ") + sourceName;
290 for (
size_t i = 0; i < inMaps.size(); i++) {
291 if (inMaps[i].hostString == hostName &&
312 if (sourceName.empty())
315 desc = devName +
wxT(
": ") + sourceName;
319 for (
size_t i = 0; i < outMaps.size(); i++) {
320 if (outMaps[i].hostString == hostName &&
344 if (newChannels > 0 && oldChannels != newChannels)
348 if (!hostName.empty() && selectedHost && *selectedHost != hostName)
376 bool audioStreamActive = gAudioIO->IsStreamActive() && !gAudioIO->IsMonitoring();
378 if (audioStreamActive) {
392 auto pCtrl =
static_cast<AButton*
>(this->FindWindow(iWinID));
397 name =
wxT(
"Open Audio Setup");
400 std::vector<ComponentInterfaceSymbol> commands(
433 for (
auto & device : inMaps) {
435 hosts.push_back(device.hostString);
439 for (
auto & device : outMaps) {
441 hosts.push_back(device.hostString);
455 int foundHostIndex = -1;
464 for (
auto & device : outMaps) {
465 if (device.hostString == host) {
466 foundHostIndex = device.hostIndex;
471 if (foundHostIndex == -1) {
472 for (
auto & device : inMaps) {
473 if (device.hostString == host) {
474 foundHostIndex = device.hostIndex;
481 if (foundHostIndex == -1) {
482 if (outMaps.size()) {
483 foundHostIndex = outMaps[0].hostIndex;
485 else if (inMaps.size()) {
486 foundHostIndex = inMaps[0].hostIndex;
495 if (foundHostIndex == -1) {
501 for (
size_t i = 0; i < inMaps.size(); ++i) {
502 auto& device = inMaps[i];
503 if (foundHostIndex == device.hostIndex) {
506 host = device.hostString;
512 mInput.
Set(std::move(mInputDeviceNames));
515 for (
size_t i = 0; i < outMaps.size(); ++i) {
516 auto& device = outMaps[i];
517 if (foundHostIndex == device.hostIndex) {
520 host = device.hostString;
539 long newChannels = 0;
545 for (
auto & dev: inMaps) {
546 if (source == dev.sourceString &&
547 device == dev.deviceString &&
548 host == dev.hostString) {
551 for (
size_t j = 0; j < (
unsigned int)dev.numChannels; j++) {
555 name =
_(
"1 (Mono) Recording Channel");
558 name =
_(
"2 (Stereo) Recording Channels");
561 name = wxString::Format(
wxT(
"%d"), (
int)j + 1);
565 newChannels = dev.numChannels;
566 if (oldChannels <= newChannels && oldChannels >= 1) {
567 newChannels = oldChannels;
574 if (newChannels >= 1)
580 wxMenu& menu,
const wxArrayString &labels,
int checkedItem,
583 auto subMenu = std::make_unique<wxMenu>();
585 for (
const auto &
label : labels) {
587 auto subMenuItem = subMenu->AppendRadioItem(wxID_ANY,
label);
588 if (ii == checkedItem)
589 subMenuItem->Check();
590 subMenu->Bind(wxEVT_MENU,
591 [&toolbar, callback, ii](wxCommandEvent &){ (toolbar.*callback)(ii); },
592 subMenuItem->GetId());
595 auto menuItem = menu.AppendSubMenu(subMenu.release(),
title);
597 menuItem->Enable(
false);
624 const auto newHost = *
name;
626 if (oldHost == newHost)
666 int deviceId,
Choices &choices,
bool isInput)
674 if (choices.
Set(deviceId)) {
676 wxString newDevice = *choices.
Get();
677 for (
size_t i = 0; i < maps.size(); ++i) {
679 if (
name == newDevice && maps[i].hostString == host)
685 wxLogDebug(
wxT(
"AudioSetupToolBar::ChangeDeviceLabel(): couldn't find device indices"));
689 SetDevices(isInput ? &maps[newIndex] :
nullptr,
690 isInput ?
nullptr : &maps[newIndex]);
749 if (gAudioIO->IsMonitoring())
751 gAudioIO->StopStream();
752 while (gAudioIO->IsBusy()) {
753 using namespace std::chrono;
754 std::this_thread::sleep_for(100ms);
758 if (audioSettingsChosen) {
762 ViewDeviceSettingsDialog dialog(
764 dialog.SetSize(600, 420);
767 if (0 != dialog.ShowModal()) {
772 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)
const TranslatableString name
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.
static void Bevel(wxDC &dc, bool up, const wxRect &r)
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