CLAM-Development  1.4.0
SDIFFileReader.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 #ifndef _SDIFFileReader_
23 #define _SDIFFileReader_
24 
25 #include "IndexArray.hxx"
26 #include "Processing.hxx"
27 #include "Err.hxx"
28 #include "OutPort.hxx"
29 #include "Filename.hxx"
30 #include "OutPort.hxx"
31 #include "SDIFInConfig.hxx"
32 #include "SDIFFrame.hxx"
33 #include "Fundamental.hxx"
34 #include "SpectralPeakArray.hxx"
35 #include "Spectrum.hxx"
36 
37 namespace SDIF { class File; } //forward declaration
38 
39 namespace CLAM
40 {
41 
43 {
44 public:
45 
46  //TODO maybe a normal constructor?
47  SDIFFileReader(const SDIFInConfig& c);
49 
50  virtual ~SDIFFileReader();
51 
52  bool GetEnableResidual() { return mConfig.GetEnableResidual(); }
53  bool GetEnablePeakArray() { return mConfig.GetEnablePeakArray(); }
54  bool GetEnableFundFreq() { return mConfig.GetEnableFundFreq(); }
55 
56  bool ReadFrame( CLAM::Fundamental& argFundamental,
57  CLAM::SpectralPeakArray& argSpectralPeaks,
58  CLAM::Spectrum& argResidual);
59 
60  bool ReadFrame( CLAM::Fundamental& argFundamental,
61  CLAM::SpectralPeakArray& argSpectralPeaks,
62  CLAM::Spectrum& argResidual,
63  TTime& argFrameCenterTime);
64 
65  int GetReadPosition();
66  void SetReadPosition(int readPosition);
67 
68  int GetSamplingRate();
69 
70  int GetFrameCenterTime();
71 
72  const ProcessingConfig &GetConfig() const;
73 
74  bool Configure(const SDIFInConfig& c);
75 
77 
78 private:
79  bool OpenFile();
80 
81  void CopyFramesDataObjects( SDIF::Frame& tmpSDIFFrame,
82  CLAM::Fundamental& argFundamental,
83  CLAM::SpectralPeakArray& argSpectralPeaks,
84  CLAM::Spectrum& argResidual);
85 
86  SDIFInConfig mConfig;
87 
88 // member variables
89  TTime mLastCenterTime;
90  int mSamplingRate;
91  IndexArray mPrevIndexArray;
92  bool isFileOpen;
93 };
94 
95 
96 };//CLAM
97 #endif
98