kwave  18.07.70
SampleReader.h
Go to the documentation of this file.
1 /***************************************************************************
2  SampleReader.h - stream for reading samples from a track
3  -------------------
4  begin : Apr 25 2001
5  copyright : (C) 2001 by Thomas Eschenbacher
6  email : Thomas Eschenbacher <thomas.eschenbacher@gmx.de>
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef SAMPLE_READER_H
20 #define SAMPLE_READER_H
21 
22 #include "config.h"
23 
24 #include <QtGlobal>
25 #include <QList>
26 #include <QObject>
27 #include <QTime>
28 
29 #include "libkwave/InsertMode.h"
30 #include "libkwave/ReaderMode.h"
31 #include "libkwave/Sample.h"
32 #include "libkwave/SampleArray.h"
33 #include "libkwave/SampleSource.h"
34 #include "libkwave/Stripe.h"
35 
36 namespace Kwave
37 {
38 
39  class Q_DECL_EXPORT SampleReader: public Kwave::SampleSource
40  {
41  Q_OBJECT
42  public:
43 
51 
53  virtual ~SampleReader() Q_DECL_OVERRIDE;
54 
56  void reset();
57 
63  virtual void goOn() Q_DECL_OVERRIDE;
64 
66  inline bool eof() const {
67  return (pos() > m_last);
68  }
69 
77  virtual bool done() const Q_DECL_OVERRIDE { return eof(); }
78 
86  unsigned int read(Kwave::SampleArray &buffer, unsigned int dstoff,
87  unsigned int length);
88 
99  void minMax(sample_index_t first, sample_index_t last,
100  sample_t &min, sample_t &max);
101 
103  void skip(sample_index_t count);
104 
106  void seek(sample_index_t pos);
107 
111  inline sample_index_t pos() const {
112  return (m_src_position + m_buffer_position - m_buffer_used);
113  }
114 
116  inline sample_index_t first() const {
117  return m_first;
118  }
119 
121  inline sample_index_t last() const {
122  return m_last;
123  }
124 
128  SampleReader& operator >> (sample_t &sample);
129 
135  SampleReader& operator >> (Kwave::SampleArray &sample);
136 
137  signals:
138 
140  void proceeded();
141 
146  void output(Kwave::SampleArray data);
147 
148  protected:
149 
151  void fillBuffer();
152 
162  unsigned int readSamples(sample_index_t offset,
163  Kwave::SampleArray &buffer,
164  unsigned int buf_offset,
165  unsigned int length);
166 
167  private:
168 
171 
173  QList<Kwave::Stripe> m_stripes;
174 
182 
185 
188 
191 
193  unsigned int m_buffer_used;
194 
196  unsigned int m_buffer_position;
197 
200 
203 
204  };
205 }
206 
207 #endif /* SAMPLE_READER_H */
208 
209 //***************************************************************************
210 //***************************************************************************
sample_index_t m_last
Definition: SampleReader.h:187
Definition: App.h:33
ReaderMode
Definition: ReaderMode.h:27
sample_index_t m_first
Definition: SampleReader.h:184
unsigned int m_buffer_position
Definition: SampleReader.h:196
virtual bool done() const Q_DECL_OVERRIDE
Definition: SampleReader.h:77
quint64 sample_index_t
Definition: Sample.h:28
sample_index_t m_src_position
Definition: SampleReader.h:181
bool eof() const
Definition: SampleReader.h:66
sample_index_t last() const
Definition: SampleReader.h:121
Kwave::SampleArray m_buffer
Definition: SampleReader.h:190
sample_index_t first() const
Definition: SampleReader.h:116
sample_index_t pos() const
Definition: SampleReader.h:111
QList< Kwave::Stripe > m_stripes
Definition: SampleReader.h:173
unsigned int m_buffer_used
Definition: SampleReader.h:193
qint32 sample_t
Definition: Sample.h:37
Kwave::ReaderMode m_mode
Definition: SampleReader.h:170
sample_index_t m_last_seek_pos
Definition: SampleReader.h:202