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");
82:
ToolBar( project,
XO(
"Audio Setup"), ID() )
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();
252 wxRect r = btn->GetRect();
255 { r.GetLeft(), r.GetBottom() }
266 wxString oldHost = selectedHost ? *selectedHost : wxString{};
272 if (oldHost != hostName)
278 if (sourceName.empty())
281 desc = devName +
wxT(
": ") + sourceName;
288 for (
size_t i = 0; i < inMaps.size(); i++) {
289 if (inMaps[i].hostString == hostName &&
310 if (sourceName.empty())
313 desc = devName +
wxT(
": ") + sourceName;
317 for (
size_t i = 0; i < outMaps.size(); i++) {
318 if (outMaps[i].hostString == hostName &&
342 if (newChannels > 0 && oldChannels != newChannels)
346 if (!hostName.empty() && selectedHost && *selectedHost != hostName)
374 bool audioStreamActive = gAudioIO->IsStreamActive() && !gAudioIO->IsMonitoring();
376 if (audioStreamActive) {
390 auto pCtrl =
static_cast<AButton*
>(this->FindWindow(iWinID));
395 name =
wxT(
"Open Audio Setup");
398 std::vector<ComponentInterfaceSymbol> commands(
431 for (
auto & device : inMaps) {
433 hosts.push_back(device.hostString);
437 for (
auto & device : outMaps) {
439 hosts.push_back(device.hostString);
453 int foundHostIndex = -1;
462 for (
auto & device : outMaps) {
463 if (device.hostString == host) {
464 foundHostIndex = device.hostIndex;
469 if (foundHostIndex == -1) {
470 for (
auto & device : inMaps) {
471 if (device.hostString == host) {
472 foundHostIndex = device.hostIndex;
479 if (foundHostIndex == -1) {
480 if (outMaps.size()) {
481 foundHostIndex = outMaps[0].hostIndex;
483 else if (inMaps.size()) {
484 foundHostIndex = inMaps[0].hostIndex;
493 if (foundHostIndex == -1) {
499 for (
size_t i = 0; i < inMaps.size(); ++i) {
500 auto& device = inMaps[i];
501 if (foundHostIndex == device.hostIndex) {
504 host = device.hostString;
510 mInput.
Set(std::move(mInputDeviceNames));
513 for (
size_t i = 0; i < outMaps.size(); ++i) {
514 auto& device = outMaps[i];
515 if (foundHostIndex == device.hostIndex) {
518 host = device.hostString;
537 long newChannels = 0;
543 for (
auto & dev: inMaps) {
544 if (source == dev.sourceString &&
545 device == dev.deviceString &&
546 host == dev.hostString) {
549 for (
size_t j = 0; j < (
unsigned int)dev.numChannels; j++) {
553 name =
_(
"1 (Mono) Recording Channel");
556 name =
_(
"2 (Stereo) Recording Channels");
559 name = wxString::Format(
wxT(
"%d"), (
int)j + 1);
563 newChannels = dev.numChannels;
564 if (oldChannels <= newChannels && oldChannels >= 1) {
565 newChannels = oldChannels;
572 if (newChannels >= 1)
578 wxMenu& menu,
const wxArrayString &labels,
int checkedItem,
581 auto subMenu = std::make_unique<wxMenu>();
583 for (
const auto &
label : labels) {
585 auto subMenuItem = subMenu->AppendRadioItem(wxID_ANY,
label);
586 if (ii == checkedItem)
587 subMenuItem->Check();
588 subMenu->Bind(wxEVT_MENU,
589 [&toolbar, callback, ii](wxCommandEvent &){ (toolbar.*callback)(ii); },
590 subMenuItem->GetId());
593 auto menuItem = menu.AppendSubMenu(subMenu.release(),
title);
595 menuItem->Enable(
false);
622 const auto newHost = *
name;
624 if (oldHost == newHost)
664 int deviceId,
Choices &choices,
bool isInput)
672 if (choices.
Set(deviceId)) {
674 wxString newDevice = *choices.
Get();
675 for (
size_t i = 0; i < maps.size(); ++i) {
677 if (
name == newDevice && maps[i].hostString == host)
683 wxLogDebug(
wxT(
"AudioSetupToolBar::ChangeDeviceLabel(): couldn't find device indices"));
687 SetDevices(isInput ? &maps[newIndex] :
nullptr,
688 isInput ?
nullptr : &maps[newIndex]);
739 if (gAudioIO->IsMonitoring())
741 gAudioIO->StopStream();
742 while (gAudioIO->IsBusy()) {
743 using namespace std::chrono;
744 std::this_thread::sleep_for(100ms);
748 if (audioSettingsChosen) {
752 ViewDeviceSettingsDialog dialog(
754 dialog.SetSize(600, 420);
757 if (0 != dialog.ShowModal()) {
762 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
const TranslatableString desc
XXO("&Cut/Copy/Paste Toolbar")
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
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.
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
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.
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
void OnFocus(wxWindow &window, wxFocusEvent &event)
a function useful to implement a focus event handler The window releases the keyboard if the event is...