Audacity 3.2.0
Namespaces | Macros | Functions | Variables
NoteTrack.cpp File Reference
#include "NoteTrack.h"
#include <wx/wxcrtvararg.h>
#include <wx/dc.h>
#include <wx/brush.h>
#include <wx/pen.h>
#include "../lib-src/header-substitutes/allegro.h"
#include <sstream>
#include "AColor.h"
#include "Prefs.h"
#include "Project.h"
#include "prefs/ImportExportPrefs.h"
#include "InconsistencyException.h"
#include "TimeWarper.h"
#include "AllThemeResources.h"
#include "Theme.h"
#include <wx/log.h>
#include <wx/sstream.h>
#include <wx/txtstrm.h>
#include "AudioIOBase.h"
#include "portmidi.h"
Include dependency graph for NoteTrack.cpp:

Go to the source code of this file.

Namespaces

namespace  anonymous_namespace{NoteTrack.cpp}
 

Macros

#define ROUND(x)   ((int) ((x) + 0.5))
 
#define CHANNEL_ON_IS_DOWN   1
 

Functions

static const Track::TypeInfotypeInfo ()
 
void anonymous_namespace{NoteTrack.cpp}::swap (std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
 
bool anonymous_namespace{NoteTrack.cpp}::IsValidVisibleChannels (const int nValue)
 
wxString GetMIDIDeviceInfo ()
 

Variables

static ProjectFileIORegistry::ObjectReaderEntry readerEntry
 
StringSetting MIDIPlaybackDevice { L"/MidiIO/PlaybackDevice", L"" }
 
StringSetting MIDIRecordingDevice { L"/MidiIO/RecordingDevice", L"" }
 
IntSetting MIDISynthLatency_ms { L"/MidiIO/SynthLatency", 5 }
 

Macro Definition Documentation

◆ CHANNEL_ON_IS_DOWN

#define CHANNEL_ON_IS_DOWN   1

◆ ROUND

#define ROUND (   x)    ((int) ((x) + 0.5))

Definition at line 32 of file NoteTrack.cpp.

Function Documentation

◆ GetMIDIDeviceInfo()

wxString GetMIDIDeviceInfo ( )

Definition at line 1180 of file NoteTrack.cpp.

1181{
1182 wxStringOutputStream o;
1183 wxTextOutputStream s(o, wxEOL_UNIX);
1184
1185 if (AudioIOBase::Get()->IsStreamActive()) {
1186 return XO("Stream is active ... unable to gather information.\n")
1187 .Translation();
1188 }
1189
1190
1191 // XXX: May need to trap errors as with the normal device info
1192 int recDeviceNum = Pm_GetDefaultInputDeviceID();
1193 int playDeviceNum = Pm_GetDefaultOutputDeviceID();
1194 int cnt = Pm_CountDevices();
1195
1196 // PRL: why only into the log?
1197 wxLogDebug(wxT("PortMidi reports %d MIDI devices"), cnt);
1198
1199 s << wxT("==============================\n");
1200 s << XO("Default recording device number: %d\n").Format( recDeviceNum );
1201 s << XO("Default playback device number: %d\n").Format( playDeviceNum );
1202
1203 auto recDevice = MIDIRecordingDevice.Read();
1204 auto playDevice = MIDIPlaybackDevice.Read();
1205
1206 // This gets info on all available audio devices (input and output)
1207 if (cnt <= 0) {
1208 s << XO("No devices found\n");
1209 return o.GetString();
1210 }
1211
1212 for (int i = 0; i < cnt; i++) {
1213 s << wxT("==============================\n");
1214
1215 const PmDeviceInfo* info = Pm_GetDeviceInfo(i);
1216 if (!info) {
1217 s << XO("Device info unavailable for: %d\n").Format( i );
1218 continue;
1219 }
1220
1221 wxString name = wxSafeConvertMB2WX(info->name);
1222 wxString hostName = wxSafeConvertMB2WX(info->interf);
1223
1224 s << XO("Device ID: %d\n").Format( i );
1225 s << XO("Device name: %s\n").Format( name );
1226 s << XO("Host name: %s\n").Format( hostName );
1227 /* i18n-hint: Supported, meaning made available by the system */
1228 s << XO("Supports output: %d\n").Format( info->output );
1229 /* i18n-hint: Supported, meaning made available by the system */
1230 s << XO("Supports input: %d\n").Format( info->input );
1231 s << XO("Opened: %d\n").Format( info->opened );
1232
1233 if (name == playDevice && info->output)
1234 playDeviceNum = i;
1235
1236 if (name == recDevice && info->input)
1237 recDeviceNum = i;
1238
1239 // XXX: This is only done because the same was applied with PortAudio
1240 // If PortMidi returns -1 for the default device, use the first one
1241 if (recDeviceNum < 0 && info->input){
1242 recDeviceNum = i;
1243 }
1244 if (playDeviceNum < 0 && info->output){
1245 playDeviceNum = i;
1246 }
1247 }
1248
1249 bool haveRecDevice = (recDeviceNum >= 0);
1250 bool havePlayDevice = (playDeviceNum >= 0);
1251
1252 s << wxT("==============================\n");
1253 if (haveRecDevice)
1254 s << XO("Selected MIDI recording device: %d - %s\n").Format( recDeviceNum, recDevice );
1255 else
1256 s << XO("No MIDI recording device found for '%s'.\n").Format( recDevice );
1257
1258 if (havePlayDevice)
1259 s << XO("Selected MIDI playback device: %d - %s\n").Format( playDeviceNum, playDevice );
1260 else
1261 s << XO("No MIDI playback device found for '%s'.\n").Format( playDevice );
1262
1263 // Mention our conditional compilation flags for Alpha only
1264#ifdef IS_ALPHA
1265
1266 // Not internationalizing these alpha-only messages
1267 s << wxT("==============================\n");
1268#ifdef EXPERIMENTAL_MIDI_OUT
1269 s << wxT("EXPERIMENTAL_MIDI_OUT is enabled\n");
1270#else
1271 s << wxT("EXPERIMENTAL_MIDI_OUT is NOT enabled\n");
1272#endif
1273#ifdef EXPERIMENTAL_MIDI_IN
1274 s << wxT("EXPERIMENTAL_MIDI_IN is enabled\n");
1275#else
1276 s << wxT("EXPERIMENTAL_MIDI_IN is NOT enabled\n");
1277#endif
1278
1279#endif
1280
1281 return o.GetString();
1282}
wxT("CloseDown"))
const TranslatableString name
Definition: Distortion.cpp:74
XO("Cut/Copy/Paste")
StringSetting MIDIRecordingDevice
Definition: NoteTrack.cpp:1285
StringSetting MIDIPlaybackDevice
Definition: NoteTrack.cpp:1284
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:91
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:200

References AudioIOBase::Get(), MIDIPlaybackDevice, MIDIRecordingDevice, name, Setting< T >::Read(), wxT(), and XO().

Referenced by anonymous_namespace{MIDIPlay.h}::MIDIPlay::Dump().

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

◆ typeInfo()

static const Track::TypeInfo & typeInfo ( )
static

Definition at line 686 of file NoteTrack.cpp.

687{
688 static const Track::TypeInfo info{
689 { "note", "midi", XO("Note Track") }, true,
691 return info;
692}
static const TypeInfo & ClassTypeInfo()
Definition: Track.cpp:1326

References PlayableTrack::ClassTypeInfo(), and XO().

Referenced by NoteTrack::ClassTypeInfo(), and NoteTrack::GetTypeInfo().

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

Variable Documentation

◆ MIDIPlaybackDevice

StringSetting MIDIPlaybackDevice { L"/MidiIO/PlaybackDevice", L"" }

◆ MIDIRecordingDevice

StringSetting MIDIRecordingDevice { L"/MidiIO/RecordingDevice", L"" }

Definition at line 1285 of file NoteTrack.cpp.

Referenced by GetMIDIDeviceInfo().

◆ MIDISynthLatency_ms

IntSetting MIDISynthLatency_ms { L"/MidiIO/SynthLatency", 5 }

◆ readerEntry

Initial value:
{
"notetrack",
}
static NoteTrack * New(AudacityProject &project)
Definition: NoteTrack.cpp:114

Definition at line 109 of file NoteTrack.cpp.