Audacity 3.2.0
Namespaces | Macros | Functions | Variables
NoteTrack.cpp File Reference
#include "NoteTrack.h"
#include <wx/wxcrtvararg.h>
#include "WrapAllegro.h"
#include <sstream>
#include "Prefs.h"
#include "Project.h"
#include "InconsistencyException.h"
#include "TimeWarper.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))
 

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

◆ ROUND

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

Definition at line 29 of file NoteTrack.cpp.

Function Documentation

◆ GetMIDIDeviceInfo()

wxString GetMIDIDeviceInfo ( )

Definition at line 906 of file NoteTrack.cpp.

907{
908 wxStringOutputStream o;
909 wxTextOutputStream s(o, wxEOL_UNIX);
910
911 if (AudioIOBase::Get()->IsStreamActive()) {
912 return XO("Stream is active ... unable to gather information.\n")
913 .Translation();
914 }
915
916
917 // XXX: May need to trap errors as with the normal device info
918 int recDeviceNum = Pm_GetDefaultInputDeviceID();
919 int playDeviceNum = Pm_GetDefaultOutputDeviceID();
920 int cnt = Pm_CountDevices();
921
922 // PRL: why only into the log?
923 wxLogDebug(wxT("PortMidi reports %d MIDI devices"), cnt);
924
925 s << wxT("==============================\n");
926 s << XO("Default recording device number: %d\n").Format( recDeviceNum );
927 s << XO("Default playback device number: %d\n").Format( playDeviceNum );
928
929 auto recDevice = MIDIRecordingDevice.Read();
930 auto playDevice = MIDIPlaybackDevice.Read();
931
932 // This gets info on all available audio devices (input and output)
933 if (cnt <= 0) {
934 s << XO("No devices found\n");
935 return o.GetString();
936 }
937
938 for (int i = 0; i < cnt; i++) {
939 s << wxT("==============================\n");
940
941 const PmDeviceInfo* info = Pm_GetDeviceInfo(i);
942 if (!info) {
943 s << XO("Device info unavailable for: %d\n").Format( i );
944 continue;
945 }
946
947 wxString name = wxSafeConvertMB2WX(info->name);
948 wxString hostName = wxSafeConvertMB2WX(info->interf);
949
950 s << XO("Device ID: %d\n").Format( i );
951 s << XO("Device name: %s\n").Format( name );
952 s << XO("Host name: %s\n").Format( hostName );
953 /* i18n-hint: Supported, meaning made available by the system */
954 s << XO("Supports output: %d\n").Format( info->output );
955 /* i18n-hint: Supported, meaning made available by the system */
956 s << XO("Supports input: %d\n").Format( info->input );
957 s << XO("Opened: %d\n").Format( info->opened );
958
959 if (name == playDevice && info->output)
960 playDeviceNum = i;
961
962 if (name == recDevice && info->input)
963 recDeviceNum = i;
964
965 // XXX: This is only done because the same was applied with PortAudio
966 // If PortMidi returns -1 for the default device, use the first one
967 if (recDeviceNum < 0 && info->input){
968 recDeviceNum = i;
969 }
970 if (playDeviceNum < 0 && info->output){
971 playDeviceNum = i;
972 }
973 }
974
975 bool haveRecDevice = (recDeviceNum >= 0);
976 bool havePlayDevice = (playDeviceNum >= 0);
977
978 s << wxT("==============================\n");
979 if (haveRecDevice)
980 s << XO("Selected MIDI recording device: %d - %s\n").Format( recDeviceNum, recDevice );
981 else
982 s << XO("No MIDI recording device found for '%s'.\n").Format( recDevice );
983
984 if (havePlayDevice)
985 s << XO("Selected MIDI playback device: %d - %s\n").Format( playDeviceNum, playDevice );
986 else
987 s << XO("No MIDI playback device found for '%s'.\n").Format( playDevice );
988
989 // Mention our conditional compilation flags for Alpha only
990#ifdef IS_ALPHA
991
992 // Not internationalizing these alpha-only messages
993 s << wxT("==============================\n");
994#ifdef EXPERIMENTAL_MIDI_OUT
995 s << wxT("EXPERIMENTAL_MIDI_OUT is enabled\n");
996#else
997 s << wxT("EXPERIMENTAL_MIDI_OUT is NOT enabled\n");
998#endif
999#ifdef EXPERIMENTAL_MIDI_IN
1000 s << wxT("EXPERIMENTAL_MIDI_IN is enabled\n");
1001#else
1002 s << wxT("EXPERIMENTAL_MIDI_IN is NOT enabled\n");
1003#endif
1004
1005#endif
1006
1007 return o.GetString();
1008}
wxT("CloseDown"))
const TranslatableString name
Definition: Distortion.cpp:76
XO("Cut/Copy/Paste")
StringSetting MIDIRecordingDevice
Definition: NoteTrack.cpp:1011
StringSetting MIDIPlaybackDevice
Definition: NoteTrack.cpp:1010
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:93
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:205

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 574 of file NoteTrack.cpp.

575{
576 static const Track::TypeInfo info{
577 { "note", "midi", XO("Note Track") }, true,
579 return info;
580}
static const TypeInfo & ClassTypeInfo()

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 1011 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:125

Definition at line 120 of file NoteTrack.cpp.