29#ifdef EXPERIMENTAL_MIDI_OUT
34#include <wx/textctrl.h>
51 EVT_CHOICE(
HostID, MidiIOPrefs::OnHost)
62MidiIOPrefs::~MidiIOPrefs()
68 return MIDI_IO_PREFS_PLUGIN_SYMBOL;
73 return XO(
"Preferences for MidiIO");
78 return "MIDI_Devices_Preferences";
81void MidiIOPrefs::Populate()
88#ifdef EXPERIMENTAL_MIDI_IN
98 PopulateOrExchange(
S);
109void MidiIOPrefs::GetNamesAndLabels() {
113 int nDevices = Pm_CountDevices();
114 for (
int i = 0; i < nDevices; i++) {
115 const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
116 if (info->output || info->input) {
117 wxString
name = wxSafeConvertMB2WX(info->interf);
121 mHostLabels.push_back(
name);
127 mHostNames.push_back(
XO(
"No MIDI interfaces"));
128 mHostLabels.push_back(
wxT(
"No MIDI interfaces"));
132void MidiIOPrefs::PopulateOrExchange(
ShuttleGui &
S )
142 S.StartStatic(
XC(
"Interface",
"MIDI"));
144 S.StartMultiColumn(2);
150 S.AddPrompt(
XXO(
"Using: PortMidi"));
156 S.StartStatic(
XO(
"Playback"));
158 S.StartMultiColumn(2);
161 mPlay =
S.AddChoice(
XXO(
"&Device:"),
163 mLatency =
S.TieIntegerTextBox(
XXO(
"MIDI Synth L&atency (ms):"),
169#ifdef EXPERIMENTAL_MIDI_IN
170 S.StartStatic(
XO(
"Recording"));
172 S.StartMultiColumn(2);
175 mRecord =
S.AddChoice(
XO(
"De&vice:"),
193void MidiIOPrefs::OnHost(wxCommandEvent & WXUNUSED(e))
195 wxString itemAtIndex;
196 int index = mHost->GetCurrentSelection();
197 if (index >= 0 && index < (
int)mHostNames.size())
198 itemAtIndex = mHostLabels[index];
199 int nDevices = Pm_CountDevices();
202#ifdef EXPERIMENTAL_MIDI_IN
209 for (
int i = 0; i < nDevices; i++) {
210 const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
211 wxString interf = wxSafeConvertMB2WX(info->interf);
212 if (itemAtIndex == interf) {
213 wxString
name = wxSafeConvertMB2WX(info->name);
214 wxString device = wxString::Format(
wxT(
"%s: %s"),
218 playnames.push_back(
name);
219 index = mPlay->Append(
name, (
void *) info);
220 if (device == mPlayDevice) {
221 mPlay->SetSelection(index);
224#ifdef EXPERIMENTAL_MIDI_IN
226 recordnames.push_back(
name);
227 index = mRecord->Append(
name, (
void *) info);
228 if (device == mRecordDevice) {
229 mRecord->SetSelection(index);
236 if (mPlay->GetCount() == 0) {
237 playnames.push_back(
_(
"No devices found"));
238 mPlay->Append(playnames[0], (
void *) NULL);
240#ifdef EXPERIMENTAL_MIDI_IN
241 if (mRecord->GetCount() == 0) {
242 recordnames.push_back(
_(
"No devices found"));
243 mRecord->Append(recordnames[0], (
void *) NULL);
246 if (mPlay->GetCount() && mPlay->GetSelection() == wxNOT_FOUND) {
247 mPlay->SetSelection(0);
249#ifdef EXPERIMENTAL_MIDI_IN
250 if (mRecord->GetCount() && mRecord->GetSelection() == wxNOT_FOUND) {
251 mRecord->SetSelection(0);
255#ifdef EXPERIMENTAL_MIDI_IN
261bool MidiIOPrefs::Commit()
264 PopulateOrExchange(
S);
266 const PmDeviceInfo *info;
268 info = (
const PmDeviceInfo *) mPlay->GetClientData(mPlay->GetSelection());
271 wxString::Format(
wxT(
"%s: %s"),
272 wxString(wxSafeConvertMB2WX(info->interf)),
273 wxString(wxSafeConvertMB2WX(info->name))));
275#ifdef EXPERIMENTAL_MIDI_IN
276 info = (
const PmDeviceInfo *) mRecord->GetClientData(mRecord->GetSelection());
278 MidiRecordingDevice.Write(
279 wxString::Format(
wxT(
"%s: %s"),
280 wxString(wxSafeConvertMB2WX(info->interf)),
281 wxString(wxSafeConvertMB2WX(info->name))));
288bool MidiIOPrefs::Validate()
291 if (!mLatency->GetValue().ToLong(&latency)) {
293"The MIDI Synthesizer Latency must be an integer") );
299#ifdef EXPERIMENTAL_MIDI_OUT
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
const TranslatableString name
XXO("&Cut/Copy/Paste Toolbar")
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
IntSetting MIDISynthLatency_ms
StringSetting MIDIRecordingDevice
StringSetting MIDIPlaybackDevice
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...
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
A PrefsPanel used to select recording and playback devices and other settings.
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
bool Write(const T &value)
Write value to config and return true if successful.
void Invalidate() override
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined */
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
static void SetMinSize(wxWindow *window, const TranslatableStrings &items)
Holds a msgid for the translation catalog; may also bind format arguments.
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.