Audacity  2.2.0
ODDecodeTask.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  ODDecodeTask.h
6 
7  Created by Michael Chinen (mchinen) on 8/10/08.
8  Audacity(R) is copyright (c) 1999-2008 Audacity Team.
9  License: GPL v2. See License.txt.
10 
11 ******************************************************************//*******************************************************************/
24 
25 
26 
27 
28 #ifndef __AUDACITY_ODDecodeTask__
29 #define __AUDACITY_ODDecodeTask__
30 
31 #include "../MemoryX.h"
32 #include <vector>
33 #include "ODTask.h"
34 #include "ODTaskThread.h"
35 class ODDecodeBlockFile;
36 class WaveTrack;
37 class ODFileDecoder;
38 
39 
41 class ODDecodeTask /* not final */ : public ODTask
42 {
43  public:
44  ODDecodeTask();
45  virtual ~ODDecodeTask(){};
46 
47  // NEW virtual:
48  virtual bool SeekingAllowed();
49 
52  void DemandTrackUpdate(WaveTrack* track, double seconds) override;
53 
55  const char* GetTaskName() override { return "ODDecodeTask"; }
56 
57  const wxChar* GetTip() override { return _("Decoding Waveform"); }
58 
60  unsigned int GetODType() override { return eODNone; }
61 
63  virtual ODFileDecoder* CreateFileDecoder(const wxString & fileName)=0;
64 
70  // NEW virtuals:
72  virtual int GetNumFileDecoders();
73 
74 
75 protected:
76 
78  void CalculatePercentComplete() override;
79 
81  void DoSomeInternal() override;
82 
85  void Update() override;
86 
88  void OrderBlockFiles
89  (std::vector< std::weak_ptr< ODDecodeBlockFile > > &unorderedBlocks);
90 
91 
92  std::vector<std::weak_ptr<ODDecodeBlockFile>> mBlockFiles;
93  std::vector<movable_ptr<ODFileDecoder>> mDecoders;
94 
96 
97 };
98 
100 class ODFileDecoder /* not final */
101 {
102 public:
104  ODFileDecoder(const wxString& fName);
105  virtual ~ODFileDecoder();
106 
109  virtual bool ReadHeader()=0;
110  virtual bool Init(){return ReadHeader();}
111 
112  virtual bool SeekingAllowed(){return true;}
113 
121  virtual int Decode(SampleBuffer & data, sampleFormat & format, sampleCount start, size_t len, unsigned int channel) = 0;
122 
123  const wxString &GetFileName(){return mFName;}
124 
125  bool IsInitialized();
126 
127 protected:
129  void MarkInitialized();
130 
131  bool mInited;
133 
134  const wxString mFName;
135 
136  unsigned int mSampleRate;
137  unsigned int mNumSamples;//this may depend on the channel - so TODO: we should probably let the decoder create/modify the track info directly.
138  unsigned int mNumChannels;
139 };
140 
141 #endif
142 
143 
144 
virtual bool Init()
Definition: ODDecodeTask.h:110
void CalculatePercentComplete() override
recalculates the percentage complete.
Definition: ODDecodeTask.cpp:114
bool mInited
Definition: ODDecodeTask.h:131
unsigned int mNumSamples
Definition: ODDecodeTask.h:137
virtual int GetNumFileDecoders()
Definition: ODDecodeTask.cpp:286
unsigned int mSampleRate
Definition: ODDecodeTask.h:136
void DoSomeInternal() override
Computes and writes the data for one BlockFile if it still has a refcount.
Definition: ODDecodeTask.cpp:34
class to decode a particular file (one per file). Saves info such as filename and length (after the h...
Definition: ODDecodeTask.h:100
bool IsInitialized()
Definition: ODDecodeTask.cpp:304
An AliasBlockFile that references uncompressed data in an existing file.
Definition: ODDecodeBlockFile.h:39
virtual bool SeekingAllowed()
Definition: ODDecodeTask.h:112
void MarkInitialized()
Derived classes should call this after they have parsed the header.
Definition: ODDecodeTask.cpp:314
void Update() override
by default creates the order of the wavetrack to load.
Definition: ODDecodeTask.cpp:131
const wxString & GetFileName()
Definition: ODDecodeTask.h:123
unsigned int mNumChannels
Definition: ODDecodeTask.h:138
ODDecodeTask()
Creates a NEW task that decodes files.
Definition: ODDecodeTask.cpp:27
int format
Definition: ExportPCM.cpp:56
A class representing a modular task to be used with the On-Demand structures.
Definition: ODTask.h:39
Definition: SampleFormat.h:52
virtual ODFileDecoder * GetOrCreateMatchingFileDecoder(ODDecodeBlockFile *blockFile)
Definition: ODDecodeTask.cpp:262
A Track that contains audio waveform data.
Definition: WaveTrack.h:76
ODLock mInitedLock
Definition: ODDecodeTask.h:132
ODFileDecoder(const wxString &fName)
This should handle unicode converted to UTF-8 on mac/linux, but OD TODO:check on windows.
Definition: ODDecodeTask.cpp:294
virtual int Decode(SampleBuffer &data, sampleFormat &format, sampleCount start, size_t len, unsigned int channel)=0
virtual ~ODFileDecoder()
Definition: ODDecodeTask.cpp:300
int mMaxBlockFiles
Definition: ODDecodeTask.h:95
void DemandTrackUpdate(WaveTrack *track, double seconds) override
Definition: ODDecodeTask.cpp:249
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
Definition: TrackControls.cpp:137
void OrderBlockFiles(std::vector< std::weak_ptr< ODDecodeBlockFile > > &unorderedBlocks)
Orders the input as either On-Demand or default layered order.
Definition: ODDecodeTask.cpp:199
Definition: ODTaskThread.h:150
const wxString mFName
Definition: ODDecodeTask.h:134
virtual bool SeekingAllowed()
Definition: ODDecodeTask.cpp:121
unsigned int GetODType() override
Subclasses should override to return respective type.
Definition: ODDecodeTask.h:60
Definition: ODTask.h:43
std::vector< std::weak_ptr< ODDecodeBlockFile > > mBlockFiles
Definition: ODDecodeTask.h:92
A class representing a modular task to be used with the On-Demand structures.
Definition: ODDecodeTask.h:41
std::vector< movable_ptr< ODFileDecoder > > mDecoders
Definition: ODDecodeTask.h:93
const wxChar * GetTip() override
Definition: ODDecodeTask.h:57
virtual bool ReadHeader()=0
const char * GetTaskName() override
Return the task name.
Definition: ODDecodeTask.h:55
virtual ~ODDecodeTask()
Definition: ODDecodeTask.h:45
virtual ODFileDecoder * CreateFileDecoder(const wxString &fileName)=0
Creates an ODFileDecoder that decodes a file of filetype the subclass handles.