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

Function Documentation

◆ GetMIDIDeviceInfo()

wxString GetMIDIDeviceInfo ( )

Definition at line 884 of file NoteTrack.cpp.

885{
886 wxStringOutputStream o;
887 wxTextOutputStream s(o, wxEOL_UNIX);
888
889 if (AudioIOBase::Get()->IsStreamActive()) {
890 return XO("Stream is active ... unable to gather information.\n")
891 .Translation();
892 }
893
894
895 // XXX: May need to trap errors as with the normal device info
896 int recDeviceNum = Pm_GetDefaultInputDeviceID();
897 int playDeviceNum = Pm_GetDefaultOutputDeviceID();
898 int cnt = Pm_CountDevices();
899
900 // PRL: why only into the log?
901 wxLogDebug(wxT("PortMidi reports %d MIDI devices"), cnt);
902
903 s << wxT("==============================\n");
904 s << XO("Default recording device number: %d\n").Format( recDeviceNum );
905 s << XO("Default playback device number: %d\n").Format( playDeviceNum );
906
907 auto recDevice = MIDIRecordingDevice.Read();
908 auto playDevice = MIDIPlaybackDevice.Read();
909
910 // This gets info on all available audio devices (input and output)
911 if (cnt <= 0) {
912 s << XO("No devices found\n");
913 return o.GetString();
914 }
915
916 for (int i = 0; i < cnt; i++) {
917 s << wxT("==============================\n");
918
919 const PmDeviceInfo* info = Pm_GetDeviceInfo(i);
920 if (!info) {
921 s << XO("Device info unavailable for: %d\n").Format( i );
922 continue;
923 }
924
925 wxString name = wxSafeConvertMB2WX(info->name);
926 wxString hostName = wxSafeConvertMB2WX(info->interf);
927
928 s << XO("Device ID: %d\n").Format( i );
929 s << XO("Device name: %s\n").Format( name );
930 s << XO("Host name: %s\n").Format( hostName );
931 /* i18n-hint: Supported, meaning made available by the system */
932 s << XO("Supports output: %d\n").Format( info->output );
933 /* i18n-hint: Supported, meaning made available by the system */
934 s << XO("Supports input: %d\n").Format( info->input );
935 s << XO("Opened: %d\n").Format( info->opened );
936
937 if (name == playDevice && info->output)
938 playDeviceNum = i;
939
940 if (name == recDevice && info->input)
941 recDeviceNum = i;
942
943 // XXX: This is only done because the same was applied with PortAudio
944 // If PortMidi returns -1 for the default device, use the first one
945 if (recDeviceNum < 0 && info->input){
946 recDeviceNum = i;
947 }
948 if (playDeviceNum < 0 && info->output){
949 playDeviceNum = i;
950 }
951 }
952
953 bool haveRecDevice = (recDeviceNum >= 0);
954 bool havePlayDevice = (playDeviceNum >= 0);
955
956 s << wxT("==============================\n");
957 if (haveRecDevice)
958 s << XO("Selected MIDI recording device: %d - %s\n").Format( recDeviceNum, recDevice );
959 else
960 s << XO("No MIDI recording device found for '%s'.\n").Format( recDevice );
961
962 if (havePlayDevice)
963 s << XO("Selected MIDI playback device: %d - %s\n").Format( playDeviceNum, playDevice );
964 else
965 s << XO("No MIDI playback device found for '%s'.\n").Format( playDevice );
966
967 // Mention our conditional compilation flags for Alpha only
968#ifdef IS_ALPHA
969
970 // Not internationalizing these alpha-only messages
971 s << wxT("==============================\n");
972#ifdef EXPERIMENTAL_MIDI_IN
973 s << wxT("EXPERIMENTAL_MIDI_IN is enabled\n");
974#else
975 s << wxT("EXPERIMENTAL_MIDI_IN is NOT enabled\n");
976#endif
977
978#endif
979
980 return o.GetString();
981}
wxT("CloseDown"))
const TranslatableString name
Definition: Distortion.cpp:76
XO("Cut/Copy/Paste")
StringSetting MIDIRecordingDevice
Definition: NoteTrack.cpp:984
StringSetting MIDIPlaybackDevice
Definition: NoteTrack.cpp:983
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:94
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 AudioIOBase::Get(), MIDIPlaybackDevice, MIDIRecordingDevice, name, Setting< T >::Read(), wxT(), and XO().

Referenced by anonymous_namespace{MIDIPlay.h}::MIDIPlay::Dump(), and anonymous_namespace{NoteTrackMenuItems.cpp}::OnMidiDeviceInfo().

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

562{
563 static const Track::TypeInfo info{
564 { "note", "midi", XO("Note Track") }, true,
566 return info;
567}
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 984 of file NoteTrack.cpp.

Referenced by GetMIDIDeviceInfo(), and MidiIOPrefs::Populate().

◆ MIDISynthLatency_ms

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

◆ readerEntry

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

Definition at line 132 of file NoteTrack.cpp.