Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MidiIOPrefs Class Referencefinal

A PrefsPanel used to select recording and playback devices and other settings. More...

#include <MidiIOPrefs.h>

Inheritance diagram for MidiIOPrefs:
[legend]
Collaboration diagram for MidiIOPrefs:
[legend]

Public Member Functions

 MidiIOPrefs (wxWindow *parent, wxWindowID winid)
 
virtual ~MidiIOPrefs ()
 
ComponentInterfaceSymbol GetSymbol () const override
 
TranslatableString GetDescription () const override
 
bool Commit () override
 
bool Validate () override
 
ManualPageID HelpPageName () override
 If not empty string, the Help button is added below the panel. More...
 
void PopulateOrExchange (ShuttleGui &S) override
 
- Public Member Functions inherited from PrefsPanel
 PrefsPanel (wxWindow *parent, wxWindowID winid, const TranslatableString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
virtual bool Commit ()=0
 
virtual PluginPath GetPath () const override
 
virtual VendorSymbol GetVendor () const override
 
virtual wxString GetVersion () const override
 
virtual bool ShowsPreviewButton ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual ManualPageID HelpPageName ()
 If not empty string, the Help button is added below the panel. More...
 
virtual void Cancel ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void Populate ()
 
void GetNamesAndLabels ()
 
void OnHost (wxCommandEvent &e)
 

Private Attributes

TranslatableStrings mHostNames
 
wxArrayStringEx mHostLabels
 
wxString mPlayDevice
 
wxChoice * mHost
 
wxChoice * mPlay
 
wxTextCtrl * mLatency
 

Additional Inherited Members

- Public Types inherited from PrefsPanel
using Factories = std::vector< PrefsPanel::PrefsNode >
 
using Factory = std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) >
 
- Static Public Member Functions inherited from PrefsPanel
static FactoriesDefaultFactories ()
 

Detailed Description

A PrefsPanel used to select recording and playback devices and other settings.

Presents interface for user to select the recording device and playback device, from the list of choices that PortMidi makes available.

Also lets user decide whether or not to record in stereo, and whether or not to play other tracks while recording one (duplex).

Definition at line 25 of file MidiIOPrefs.h.

Constructor & Destructor Documentation

◆ MidiIOPrefs()

MidiIOPrefs::MidiIOPrefs ( wxWindow *  parent,
wxWindowID  winid 
)

Definition at line 53 of file MidiIOPrefs.cpp.

55: PrefsPanel(parent, winid, XO("MIDI Devices"))
56{
57 Populate();
58}
XO("Cut/Copy/Paste")
void Populate()
Definition: MidiIOPrefs.cpp:79
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:94

◆ ~MidiIOPrefs()

MidiIOPrefs::~MidiIOPrefs ( )
virtual

Definition at line 60 of file MidiIOPrefs.cpp.

61{
62}

Member Function Documentation

◆ Commit()

bool MidiIOPrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 259 of file MidiIOPrefs.cpp.

260{
263
264 const PmDeviceInfo *info;
265
266 info = (const PmDeviceInfo *) mPlay->GetClientData(mPlay->GetSelection());
267 if (info) {
269 wxString::Format(wxT("%s: %s"),
270 wxString(wxSafeConvertMB2WX(info->interf)),
271 wxString(wxSafeConvertMB2WX(info->name))));
272 }
273#ifdef EXPERIMENTAL_MIDI_IN
274 info = (const PmDeviceInfo *) mRecord->GetClientData(mRecord->GetSelection());
275 if (info) {
276 MidiRecordingDevice.Write(
277 wxString::Format(wxT("%s: %s"),
278 wxString(wxSafeConvertMB2WX(info->interf)),
279 wxString(wxSafeConvertMB2WX(info->name))));
280 }
281#endif
283 return gPrefs->Flush();
284}
wxT("CloseDown"))
IntSetting MIDISynthLatency_ms
Definition: NoteTrack.cpp:985
StringSetting MIDIPlaybackDevice
Definition: NoteTrack.cpp:983
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
#define S(N)
Definition: ToChars.cpp:64
void PopulateOrExchange(ShuttleGui &S) override
wxChoice * mPlay
Definition: MidiIOPrefs.h:55
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:259
void Invalidate() override
Definition: Prefs.h:289
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
virtual bool Flush() noexcept=0

References eIsSavingToPrefs, audacity::BasicSettings::Flush(), gPrefs, Setting< T >::Invalidate(), MIDIPlaybackDevice, MIDISynthLatency_ms, mPlay, PopulateOrExchange(), S, Setting< T >::Write(), and wxT().

Here is the call graph for this function:

◆ GetDescription()

TranslatableString MidiIOPrefs::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 69 of file MidiIOPrefs.cpp.

70{
71 return XO("Preferences for MidiIO");
72}

References XO().

Here is the call graph for this function:

◆ GetNamesAndLabels()

void MidiIOPrefs::GetNamesAndLabels ( )
private

Gets the lists of names and lists of labels which are used in the choice controls. The names are what the user sees in the wxChoice. The corresponding labels are what gets stored.

Definition at line 107 of file MidiIOPrefs.cpp.

107 {
108 // Gather list of hosts. Only added hosts that have devices attached.
109 Pm_Terminate(); // close and open to refresh device lists
110 Pm_Initialize();
111 int nDevices = Pm_CountDevices();
112 for (int i = 0; i < nDevices; i++) {
113 const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
114 if (info->output || info->input) { //should always happen
115 wxString name = wxSafeConvertMB2WX(info->interf);
117 .contains( Verbatim( name ) )) {
118 mHostNames.push_back( Verbatim( name ) );
119 mHostLabels.push_back(name);
120 }
121 }
122 }
123
124 if (nDevices == 0) {
125 mHostNames.push_back(XO("No MIDI interfaces"));
126 mHostLabels.push_back(wxT("No MIDI interfaces"));
127 }
128}
const TranslatableString name
Definition: Distortion.cpp:76
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: IteratorX.h:210
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
wxArrayStringEx mHostLabels
Definition: MidiIOPrefs.h:46
TranslatableStrings mHostNames
Definition: MidiIOPrefs.h:45

References make_iterator_range(), mHostLabels, mHostNames, name, Verbatim(), wxT(), and XO().

Referenced by Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol MidiIOPrefs::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 64 of file MidiIOPrefs.cpp.

65{
67}
#define MIDI_IO_PREFS_PLUGIN_SYMBOL
Definition: MidiIOPrefs.h:23

References MIDI_IO_PREFS_PLUGIN_SYMBOL.

◆ HelpPageName()

ManualPageID MidiIOPrefs::HelpPageName ( )
overridevirtual

If not empty string, the Help button is added below the panel.

Default returns empty string.

Reimplemented from PrefsPanel.

Definition at line 74 of file MidiIOPrefs.cpp.

75{
76 return "MIDI_Devices_Preferences";
77}

◆ OnHost()

void MidiIOPrefs::OnHost ( wxCommandEvent &  e)
private

Definition at line 191 of file MidiIOPrefs.cpp.

192{
193 wxString itemAtIndex;
194 int index = mHost->GetCurrentSelection();
195 if (index >= 0 && index < (int)mHostNames.size())
196 itemAtIndex = mHostLabels[index];
197 int nDevices = Pm_CountDevices();
198
199 mPlay->Clear();
200#ifdef EXPERIMENTAL_MIDI_IN
201 mRecord->Clear();
202#endif
203
204 wxArrayStringEx playnames;
205 wxArrayStringEx recordnames;
206
207 for (int i = 0; i < nDevices; i++) {
208 const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
209 wxString interf = wxSafeConvertMB2WX(info->interf);
210 if (itemAtIndex == interf) {
211 wxString name = wxSafeConvertMB2WX(info->name);
212 wxString device = wxString::Format(wxT("%s: %s"),
213 interf,
214 name);
215 if (info->output) {
216 playnames.push_back(name);
217 index = mPlay->Append(name, (void *) info);
218 if (device == mPlayDevice) {
219 mPlay->SetSelection(index);
220 }
221 }
222#ifdef EXPERIMENTAL_MIDI_IN
223 if (info->input) {
224 recordnames.push_back(name);
225 index = mRecord->Append(name, (void *) info);
226 if (device == mRecordDevice) {
227 mRecord->SetSelection(index);
228 }
229 }
230#endif
231 }
232 }
233
234 if (mPlay->GetCount() == 0) {
235 playnames.push_back(_("No devices found"));
236 mPlay->Append(playnames[0], (void *) NULL);
237 }
238#ifdef EXPERIMENTAL_MIDI_IN
239 if (mRecord->GetCount() == 0) {
240 recordnames.push_back(_("No devices found"));
241 mRecord->Append(recordnames[0], (void *) NULL);
242 }
243#endif
244 if (mPlay->GetCount() && mPlay->GetSelection() == wxNOT_FOUND) {
245 mPlay->SetSelection(0);
246 }
247#ifdef EXPERIMENTAL_MIDI_IN
248 if (mRecord->GetCount() && mRecord->GetSelection() == wxNOT_FOUND) {
249 mRecord->SetSelection(0);
250 }
251#endif
252 ShuttleGui::SetMinSize(mPlay, playnames);
253#ifdef EXPERIMENTAL_MIDI_IN
254 ShuttleGui::SetMinSize(mRecord, recordnames);
255#endif
256// OnDevice(e);
257}
#define _(s)
Definition: Internat.h:73
wxChoice * mHost
Definition: MidiIOPrefs.h:54
wxString mPlayDevice
Definition: MidiIOPrefs.h:48
static void SetMinSize(wxWindow *window, const TranslatableStrings &items)
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.

References _, mHost, mHostLabels, mHostNames, mPlay, mPlayDevice, name, ShuttleGui::SetMinSize(), and wxT().

Referenced by Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Populate()

void MidiIOPrefs::Populate ( )
private

Definition at line 79 of file MidiIOPrefs.cpp.

80{
81 // First any pre-processing for constructing the GUI.
83
84 // Get current setting for devices
86#ifdef EXPERIMENTAL_MIDI_IN
87 mRecordDevice = MIDIRecordingDevice.Read();
88#endif
89// mRecordChannels = gPrefs->Read(wxT("/MidiIO/RecordChannels"), 2L);
90
91 //------------------------- Main section --------------------
92 // Now construct the GUI itself.
93 // Use 'eIsCreatingFromPrefs' so that the GUI is
94 // initialised with values from gPrefs.
97 // ----------------------- End of main section --------------
98
99 wxCommandEvent e;
100 OnHost(e);
101}
StringSetting MIDIRecordingDevice
Definition: NoteTrack.cpp:984
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
void OnHost(wxCommandEvent &e)
void GetNamesAndLabels()
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:207

References eIsCreatingFromPrefs, GetNamesAndLabels(), MIDIPlaybackDevice, MIDIRecordingDevice, mPlayDevice, OnHost(), PopulateOrExchange(), Setting< T >::Read(), and S.

Here is the call graph for this function:

◆ PopulateOrExchange()

void MidiIOPrefs::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 130 of file MidiIOPrefs.cpp.

131{
132 ChoiceSetting Setting{ L"/MidiIO/Host",
134 };
135
136 S.SetBorder(2);
137 S.StartScroller();
138
139 /* i18n-hint Software interface to MIDI */
140 S.StartStatic(XC("Interface", "MIDI"));
141 {
142 S.StartMultiColumn(2);
143 {
144 S.Id(HostID);
145 /* i18n-hint: (noun) */
146 mHost = S.TieChoice(XXO("&Host:"), Setting);
147
148 S.AddPrompt(XXO("Using: PortMidi"));
149 }
150 S.EndMultiColumn();
151 }
152 S.EndStatic();
153
154 S.StartStatic(XO("Playback"));
155 {
156 S.StartMultiColumn(2);
157 {
158 S.Id(PlayID);
159 mPlay = S.AddChoice(XXO("&Device:"),
160 {} );
161 mLatency = S.TieIntegerTextBox(XXO("MIDI Synth L&atency (ms):"),
163 }
164 S.EndMultiColumn();
165 }
166 S.EndStatic();
167#ifdef EXPERIMENTAL_MIDI_IN
168 S.StartStatic(XO("Recording"));
169 {
170 S.StartMultiColumn(2);
171 {
172 S.Id(RecordID);
173 mRecord = S.AddChoice(XO("De&vice:"),
174 {} );
175
176 S.Id(ChannelsID);
177 /*
178 mChannels = S.AddChoice(XO("&Channels:"),
179 wxEmptyString,
180 {} );
181 */
182 }
183 S.EndMultiColumn();
184 }
185 S.EndStatic();
186#endif
187 S.EndScroller();
188
189}
XXO("&Cut/Copy/Paste Toolbar")
#define XC(s, c)
Definition: Internat.h:37
@ ChannelsID
Definition: MidiIOPrefs.cpp:45
@ PlayID
Definition: MidiIOPrefs.cpp:43
@ HostID
Definition: MidiIOPrefs.cpp:42
@ RecordID
Definition: MidiIOPrefs.cpp:44
ByColumns_t ByColumns
Definition: Prefs.cpp:515
wxTextCtrl * mLatency
Definition: MidiIOPrefs.h:56
Definition: Prefs.h:178

References ByColumns, ChannelsID, HostID, mHost, mHostLabels, mHostNames, MIDISynthLatency_ms, mLatency, mPlay, PlayID, RecordID, S, XC, XO(), and XXO().

Referenced by Commit(), and Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Validate()

bool MidiIOPrefs::Validate ( )
override

Definition at line 286 of file MidiIOPrefs.cpp.

287{
288 long latency;
289 if (!mLatency->GetValue().ToLong(&latency)) {
291"The MIDI Synthesizer Latency must be an integer") );
292 return false;
293 }
294 return true;
295}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)

References AudacityMessageBox(), mLatency, and XO().

Here is the call graph for this function:

Member Data Documentation

◆ mHost

wxChoice* MidiIOPrefs::mHost
private

Definition at line 54 of file MidiIOPrefs.h.

Referenced by OnHost(), and PopulateOrExchange().

◆ mHostLabels

wxArrayStringEx MidiIOPrefs::mHostLabels
private

Definition at line 46 of file MidiIOPrefs.h.

Referenced by GetNamesAndLabels(), OnHost(), and PopulateOrExchange().

◆ mHostNames

TranslatableStrings MidiIOPrefs::mHostNames
private

Definition at line 45 of file MidiIOPrefs.h.

Referenced by GetNamesAndLabels(), OnHost(), and PopulateOrExchange().

◆ mLatency

wxTextCtrl* MidiIOPrefs::mLatency
private

Definition at line 56 of file MidiIOPrefs.h.

Referenced by PopulateOrExchange(), and Validate().

◆ mPlay

wxChoice* MidiIOPrefs::mPlay
private

Definition at line 55 of file MidiIOPrefs.h.

Referenced by Commit(), OnHost(), and PopulateOrExchange().

◆ mPlayDevice

wxString MidiIOPrefs::mPlayDevice
private

Definition at line 48 of file MidiIOPrefs.h.

Referenced by OnHost(), and Populate().


The documentation for this class was generated from the following files: