45 auto newTrack = std::make_shared<NoteTrack>();
46 bool initiallyEmpty =
tracks.empty();
51 auto pTrack =
tracks.Add( newTrack );
52 pTrack->SetSelected(
true);
57 const bool projectHasSolo =
60 pTrack->SetMute(
true);
64 XO(
"Imported MIDI from '%s'").
Format( fileName ),
73 if (initiallyEmpty && projectFileIO.IsTemporary()) {
74 wxFileName
fn(fileName);
76 project.SetInitialImportPath(
fn.GetPath());
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(
'.');
145 wxString fileName =
SelectFile(FileNames::Operation::Open,
146 XO(
"Select a MIDI file"),
151 {
XO(
"MIDI and Allegro files"),
152 {
wxT(
"mid"),
wxT(
"midi"),
wxT(
"gro"), },
true },
154 {
wxT(
"mid"),
wxT(
"midi"), },
true },
155 {
XO(
"Allegro files"),
156 {
wxT(
"gro"), },
true },
162 if (!fileName.empty())
169 {
wxT(
"File/Import-Export/Import"),
170 { OrderingHint::After, {
"ImportAudio"} } }
185 : mFileName{ fileName }
211 std::optional<LibFileFormats::AcidizerTags>& outAcidTags)
override;
221void MIDIImportFileHandle::Import(
223 TrackHolders& outTracks,
Tags*, std::optional<LibFileFormats::AcidizerTags>&)
225 auto newTrack = std::make_shared<NoteTrack>();
227 outTracks.push_back(newTrack);
251 return std::make_unique<MIDIImportFileHandle>(fileName);
256 std::make_unique<MIDIImportPlugin>()
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
const ReservedCommandFlag & AudioIONotBusyFlag()
XXO("&Cut/Copy/Paste Toolbar")
The interface that all file import "plugins" (if you want to call them that) must implement....
std::vector< std::shared_ptr< Track > > TrackHolders
#define DEFINE_MODULE_ENTRIES
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)
std::vector< TranslatableString > TranslatableStrings
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
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
Base class for FlacImportFileHandle, LOFImportFileHandle, MP3ImportFileHandle, OggImportFileHandle an...
unsigned long long ByteCount
Base class for FlacImportPlugin, LOFImportPlugin, MP3ImportPlugin, OggImportPlugin and PCMImportPlugi...
Interface used to report on import state and progress.
virtual void OnImportResult(ImportResult result)=0
Used to report on import result for file handle passed as argument to OnImportFileOpened.
A Track that is used for Midi notes. (Somewhat old code).
void SetSequence(std::unique_ptr< Alg_seq > &&seq)
void MoveTo(double origin) override
Change start time to given time point.
static NoteTrackRange & Get(const NoteTrack &track)
Allow mutative access to attached data of a const track.
void ZoomAllNotes(Alg_seq *pSeq)
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)
Generates classes whose instances register items at construction.
void SetName(const wxString &n)
static TrackList & Get(AudacityProject &project)
Holds a msgid for the translation catalog; may also bind format arguments.
void ZoomFitHorizontallyAndShowTrack(Track *pTrack)
static Viewport & Get(AudacityProject &project)
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
~MIDIImportPlugin() override
TranslatableString GetPluginFormatDescription() override
std::unique_ptr< ImportFileHandle > Open(const FilePath &fileName, AudacityProject *project) override
wxString GetPluginStringID() override
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
void SelectNone(AudacityProject &project)
bool DoImportMIDI(AudacityProject &project, const FilePath &fileName)
Importer::RegisteredImportPlugin registered
void OnImportMIDI(const CommandContext &context)
bool ImportMIDI(const FilePath &fName, NoteTrack *dest)
const char * end(const char *str) noexcept
const char * begin(const char *str) noexcept
TranslatableString GetFileDescription() override
MIDIImportFileHandle(const FilePath &fileName)
const TranslatableStrings & GetStreamInfo() override
~MIDIImportFileHandle() override
ByteCount GetFileUncompressedBytes() override
FilePath GetFilename() const override
void SetStreamUsage(wxInt32, bool) override
wxInt32 GetStreamCount() override