Audacity  2.3.1
Import.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  Import.h
6 
7  Dominic Mazzoni
8 
9 **********************************************************************/
10 
11 #ifndef _IMPORT_
12 #define _IMPORT_
13 
14 #include "ImportRaw.h" // defines TrackHolders
15 #include "ImportForwards.h"
16 #include <vector>
17 #include <wx/arrstr.h>
18 #include <wx/string.h>
19 #include <wx/listbox.h>
20 #include <wx/tokenzr.h>
21 
22 #include "../widgets/wxPanelWrapper.h"
23 
24 class Tags;
25 class TrackFactory;
26 class Track;
27 class ImportPlugin;
28 class ImportFileHandle;
30 typedef bool (*progress_callback_t)( void *userData, float percent );
31 
32 class Format {
33 public:
34  wxString formatName;
35  wxArrayString formatExtensions;
36 
37  Format(const wxString &_formatName, const wxArrayString &_formatExtensions):
38  formatName(_formatName),
39  formatExtensions(_formatExtensions)
40  {
41  }
42 };
43 
44 class ExtImportItem;
45 
46 using FormatList = std::vector<Format> ;
47 using ExtImportItems = std::vector< std::unique_ptr<ExtImportItem> >;
48 
50 {
51  public:
59  wxArrayString filters;
60 
68  int divider;
69 
73  std::vector<ImportPlugin*> filter_objects;
74 
79  wxArrayString extensions;
80 
85  wxArrayString mime_types;
86 };
87 
88 class Importer {
89 public:
90  Importer();
91  ~Importer();
92 
96  static Importer & Get();
97 
101  bool Initialize();
102  bool Terminate();
103 
107  void GetSupportedImportFormats(FormatList *formatList);
108 
113  void ReadImportItems();
114 
118  void WriteImportItems();
119 
125  void StringToList(wxString &str, wxString &delims, wxArrayString &list, wxStringTokenizerMode mod = wxTOKEN_RET_EMPTY_ALL);
126 
132 
137  std::unique_ptr<ExtImportItem> CreateDefaultImportItem();
138 
139  static bool IsMidi(const wxString &fName);
140 
141  // if false, the import failed and errorMessage will be set.
142  bool Import(const wxString &fName,
143  TrackFactory *trackFactory,
144  TrackHolders &tracks,
145  Tags *tags,
146  wxString &errorMessage);
147 
148 private:
150 
154 };
155 
156 //----------------------------------------------------------------------------
157 // ImportStreamDialog
158 //----------------------------------------------------------------------------
159 
161 {
162 public:
163  // constructors and destructors
165  wxWindow *parent, wxWindowID id, const wxString &title,
166  const wxPoint& pos = wxDefaultPosition,
167  const wxSize& size = wxDefaultSize,
168  long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
169  virtual ~ImportStreamDialog();
170 
171 private:
173  wxInt32 scount;
174  wxListBox *StreamList;
175 
176 private:
177  void OnOk( wxCommandEvent &event );
178  void OnCancel( wxCommandEvent &event );
179 
180 private:
181  DECLARE_EVENT_TABLE()
182 };
183 
184 #endif
void OnCancel(wxCommandEvent &event)
Definition: Import.cpp:743
Class which actulaly imports the auido, using functions defined in ImportPCM.cpp, ImportMP3...
Definition: Import.h:88
Used in place of a real plug in for plug ins that have not been compiled or are not available in this...
Definition: ImportPlugin.h:181
An ImportFileHandle for data.
Definition: ImportPlugin.h:119
static Importer mInstance
Definition: Import.h:149
wxArrayString filters
Definition: Import.h:59
Abstract base class used in importing a file.
Definition: Import.h:32
ExtImportItems mExtImportItems
Definition: Import.h:151
static bool IsMidi(const wxString &fName)
Definition: Import.cpp:326
wxInt32 scount
Definition: Import.h:173
Importer()
Definition: Import.cpp:77
bool Initialize()
Definition: Import.cpp:85
void StringToList(wxString &str, wxString &delims, wxArrayString &list, wxStringTokenizerMode mod=wxTOKEN_RET_EMPTY_ALL)
Definition: Import.cpp:133
bool Import(const wxString &fName, TrackFactory *trackFactory, TrackHolders &tracks, Tags *tags, wxString &errorMessage)
Definition: Import.cpp:336
ExtImportItems & GetImportItems()
Definition: Import.h:131
Used to create a WaveTrack, or a LabelTrack.. Implementation of the functions of this class are dispe...
Definition: Track.h:1617
void GetSupportedImportFormats(FormatList *formatList)
Definition: Import.cpp:124
void ReadImportItems()
Definition: Import.cpp:141
void OnOk(wxCommandEvent &event)
Definition: Import.cpp:734
ImportPluginList mImportPluginList
Definition: Import.h:152
void WriteImportItems()
Definition: Import.cpp:250
virtual ~ImportStreamDialog()
Definition: Import.cpp:729
Format(const wxString &_formatName, const wxArrayString &_formatExtensions)
Definition: Import.h:37
~Importer()
Definition: Import.cpp:81
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:191
wxArrayString mime_types
Definition: Import.h:85
std::vector< std::unique_ptr< ExtImportItem > > ExtImportItems
Definition: Import.h:47
ImportStreamDialog(ImportFileHandle *_mFile, wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
Definition: Import.cpp:696
ID3 Tags (for MP3)
Definition: Tags.h:70
Base class for FlacImportPlugin, LOFImportPlugin, MP3ImportPlugin, OggImportPlugin and PCMImportPlugi...
Definition: ImportPlugin.h:73
UnusableImportPluginList mUnusableImportPluginList
Definition: Import.h:153
std::vector< NewChannelGroup > TrackHolders
Definition: ImportRaw.h:27
wxArrayString formatExtensions
Definition: Import.h:35
wxListBox * StreamList
Definition: Import.h:174
bool(* progress_callback_t)(void *userData, float percent)
Definition: Import.h:30
An UnusableImportPlugin list.
An ImportPlugin list.
wxArrayString extensions
Definition: Import.h:79
std::vector< ImportPlugin * > filter_objects
Definition: Import.h:73
static Importer & Get()
Definition: Import.cpp:72
int divider
Definition: Import.h:68
std::unique_ptr< ExtImportItem > CreateDefaultImportItem()
Definition: Import.cpp:311
ImportFileHandle * mFile
Definition: Import.h:172
std::vector< Format > FormatList
Definition: Import.h:46
wxString formatName
Definition: Import.h:34
bool Terminate()
Definition: Import.cpp:115