21#include "../lib-src/header-substitutes/allegro.h"
27#include "../NoteTrack.h"
31#include "../ProjectWindow.h"
34#include "../SelectUtilities.h"
36#include "../widgets/FileHistory.h"
43 auto newTrack = std::make_shared<NoteTrack>();
44 bool initiallyEmpty = tracks.empty();
49 auto pTrack = tracks.Add( newTrack );
50 pTrack->SetSelected(
true);
55 const bool projectHasSolo =
57#ifdef EXPERIMENTAL_MIDI_OUT
59 pTrack->SetMute(
true);
64 XO(
"Imported MIDI from '%s'").
Format( fileName ),
73 if (initiallyEmpty && projectFileIO.IsTemporary()) {
74 wxFileName
fn(fileName);
77 projectFileIO.SetProjectTitle();
87 if (fName.length() <= 4){
89 XO(
"Could not open file %s: Filename too short.").
Format( fName ) );
94 if (fName.Right(4).CmpNoCase(
wxT(
".mid")) == 0 || fName.Right(5).CmpNoCase(
wxT(
".midi")) == 0)
96 else if(fName.Right(4).CmpNoCase(
wxT(
".gro")) != 0) {
98 XO(
"Could not open file %s: Incorrect filetype.").
Format( fName ) );
102 wxFFile mf(fName,
wxT(
"rb"));
103 if (!mf.IsOpened()) {
105 XO(
"Could not open file %s.").
Format( fName ) );
110 auto new_seq = std::make_unique<Alg_seq>(fName.mb_str(), is_midi, &offset);
113 if(new_seq->get_read_error() == alg_error_open){
115 XO(
"Could not open file %s.").
Format( fName ) );
122 wxString trackNameBase = fName.AfterLast(wxFILE_SEP_PATH).BeforeLast(
'.');
131#include "../commands/CommandContext.h"
132#include "../commands/CommandManager.h"
133#include "../CommonCommandFlags.h"
140 auto &project = context.
project;
143 wxString fileName =
SelectFile(FileNames::Operation::Open,
144 XO(
"Select a MIDI file"),
149 {
XO(
"MIDI and Allegro files"),
150 {
wxT(
"mid"),
wxT(
"midi"),
wxT(
"gro"), },
true },
152 {
wxT(
"mid"),
wxT(
"midi"), },
true },
153 {
XO(
"Allegro files"),
154 {
wxT(
"gro"), },
true },
160 if (!fileName.empty())
165 {
wxT(
"File/Import-Export/Import"),
166 { OrderingHint::After, {
"ImportAudio"} } },
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
const ReservedCommandFlag & AudioIONotBusyFlag()
XXO("&Cut/Copy/Paste Toolbar")
bool DoImportMIDI(AudacityProject &project, const FilePath &fileName)
bool ImportMIDI(const FilePath &fName, NoteTrack *dest)
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
accessors for certain important windows associated with each project
FilePath SelectFile(FileNames::Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
void SetInitialImportPath(const FilePath &path)
void SetProjectName(const wxString &name)
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
AudacityProject & project
void Append(const FilePath &file)
static FileHistory & Global()
FILES_API const FileType AllFiles
A Track that is used for Midi notes. (Somewhat old code).
void SetSequence(std::unique_ptr< Alg_seq > &&seq)
void ZoomAllNotes()
Zooms so that all notes are visible.
AudioTrack subclass that can also be audibly replayed by the program.
static ProjectFileIO & Get(AudacityProject &project)
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
void ZoomAfterImport(Track *pTrack)
static ProjectWindow & Get(AudacityProject &project)
virtual void SetOffset(double o)
void SetName(const wxString &n)
static TrackList & Get(AudacityProject &project)
void SelectNone(AudacityProject &project)
void OnImportMIDI(const CommandContext &context)