[3e4acc]: libkwave / Signal.h Maximize Restore History

Download this file

Signal.h    291 lines (245 with data), 9.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/***************************************************************************
Signal.h - representation of a Kwave signal with multiple tracks
-------------------
begin : Sat Feb 03 2001
copyright : (C) 2001 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef _SIGNAL_H_
#define _SIGNAL_H_
#define PROGRESS_SIZE (512 * 3 * 5)
#include "config.h"
#include <limits.h>
#include <pthread.h>
#include <QReadWriteLock>
#include <QList>
#include <kdemacros.h>
#include "libkwave/InsertMode.h"
#include "libkwave/ReaderMode.h"
#include "libkwave/Sample.h"
#include "libkwave/WindowFunction.h"
class MultiTrackReader;
class SampleReader;
namespace Kwave { class Track; }
namespace Kwave { class Writer; }
//**********************************************************************
namespace Kwave {
class KDE_EXPORT Signal: public QObject
{
Q_OBJECT
public:
/**
* Default Constructor. Creates an empty signal with
* zero-length and no tracks
*/
Signal();
/**
* Constructor. Creates an empty signal with a specified
* number of tracks and length. Each track will contain
* only one stripe.
*/
Signal(unsigned int tracks, sample_index_t length);
/**
* Destructor.
*/
virtual ~Signal();
/**
* Closes the signal by removing all tracks.
*/
void close();
/**
* Inserts a new track to into the track list or appends it to the end.
* @param index the position where to insert [0...tracks()]. If the
* position is at or after the last track, the new track will
* be appended to the end.
* @param length number of samples of the new track. Optional, if omitted
* the track will be zero-length.
* @return pointer to the created track. If the length is
* omitted or zero, the track will have zero length.
*/
Kwave::Track *insertTrack(unsigned int index, sample_index_t length = 0);
/**
* Appends a new track to the end of the tracks list, shortcut for
* insertTrack(tracks()-1, length)
* @see insertTrack
*/
Kwave::Track *appendTrack(sample_index_t length);
/**
* Deletes a track.
* @param index the index of the track to be deleted [0...tracks()-1]
*/
void deleteTrack(unsigned int index);
/**
* Returns an array of indices of all present tracks.
*/
QList<unsigned int> allTracks();
/**
* Opens an input stream for a track, starting at a specified sample
* position.
* @param track index of the track. If the track does not exist, this
* function will fail and return 0
* @param mode specifies where and how to insert
* @param left start of the input (only useful in insert and
* overwrite mode)
* @param right end of the input (only useful with overwrite mode)
* @see InsertMode
*/
Kwave::Writer *openWriter(unsigned int track, InsertMode mode,
sample_index_t left = 0, sample_index_t right = 0);
/**
* Opens a stream for reading samples. If the the last position
* is omitted, the value UINT_MAX will be used.
* @param mode a reader mode, see Kwave::ReaderMode
* @param track index of the track. If the track does not exist, this
* function will fail and return 0
* @param left first offset to be read (default = 0)
* @param right last position to read (default = UINT_MAX)
*/
SampleReader *openSampleReader(Kwave::ReaderMode mode,
unsigned int track, sample_index_t left = 0,
sample_index_t right = SAMPLE_INDEX_MAX);
/**
* Returns the number of tracks.
*/
unsigned int tracks();
/**
* Deletes a range of samples
* @param track index of the track
* @param offset index of the first sample
* @param length number of samples
*/
void deleteRange(unsigned int track, sample_index_t offset,
sample_index_t length);
/**
* Inserts some space at a given position
* @param track index of the track
* @param offset index of the first sample
* @param length number of samples
*/
void insertSpace(unsigned int track, sample_index_t offset,
sample_index_t length);
/**
* Returns the length of the signal. This is determined by
* searching for the highest sample position of all tracks.
*/
sample_index_t length();
/**
* Queries if a track is selected. If the index of the track is
* out of range, the return value will be false.
*/
bool trackSelected(unsigned int track);
/**
* Sets the "selected" flag of a track.
* @param track index of the track [0...tracks-1]
* @param select true if the track should be selected,
* false for de-selecting
*/
void selectTrack(unsigned int track, bool select);
signals:
/**
* Signals that a track has been inserted.
* @param index position of the new track [0...tracks()-1]
* @param track reference to the new track
*/
void sigTrackInserted(unsigned int index, Kwave::Track *track);
/**
* Signals that a track has been deleted.
* @param index position of the deleted track [0...tracks()-1]
*/
void sigTrackDeleted(unsigned int index);
/**
* Signals that the selection of one of the tracks has changed
* @param enabled state of the track, true=selected
*/
void sigTrackSelectionChanged(bool enabled);
/**
* Emitted if samples have been inserted into a track. This implies
* a modification of the inserted data, so no extra sigSamplesModified
* is emitted.
* @param track index of the track
* @param offset position from which the data was inserted
* @param length number of samples inserted
* @see sigSamplesModified
*/
void sigSamplesInserted(unsigned int track, sample_index_t offset,
sample_index_t length);
/**
* Emitted if samples have been removed from a track.
* @param track index of the track
* @param offset position from which the data was removed
* @param length number of samples deleted
*/
void sigSamplesDeleted(unsigned int track, sample_index_t offset,
sample_index_t length);
/**
* Emitted if samples within a track have been modified.
* @param track index of the track
* @param offset position from which the data was modified
* @param length number of samples modified
*/
void sigSamplesModified(unsigned int track, sample_index_t offset,
sample_index_t length);
private slots:
/**
* Connected to each track's sigSamplesInserted.
* @param src source track
* @param offset position from which the data was inserted
* @param length number of samples inserted
* @see Track::sigSamplesInserted
* @internal
*/
void slotSamplesInserted(Kwave::Track *src, sample_index_t offset,
sample_index_t length);
/**
* Connected to each track's sigSamplesDeleted.
* @param src source track
* @param offset position from which the data was removed
* @param length number of samples deleted
* @see Track::sigSamplesDeleted
* @internal
*/
void slotSamplesDeleted(Kwave::Track *src, sample_index_t offset,
sample_index_t length);
/**
* Connected to each track's sigSamplesModified
* @param src source track
* @param offset position from which the data was modified
* @param length number of samples modified
* @see Track::sigSamplesModified
* @internal
*/
void slotSamplesModified(Kwave::Track *src, sample_index_t offset,
sample_index_t length);
private:
/**
* Looks up the index of a trackin the track list
* @param track reference to the trac to be looked up
* @returns index of the track [0...tracks()-1] or tracks() if not found
*/
unsigned int trackIndex(const Kwave::Track *track);
// //signal modifying functions
// void replaceStutter (int, int);
// void delayRecursive (int, int);
// void delay (int, int);
// void movingFilter (Filter *filter, int tap, Curve *points, int low, int high);
//
// //functions creating a new Object
//
// void fft (int, bool);
// void averageFFT (int points, window_function_t windowtype);
/** list of tracks */
QList<Kwave::Track *> m_tracks;
/** mutex for access to the track list */
QReadWriteLock m_lock_tracks;
};
}
//**********************************************************************
#endif /* _SIGNAL_H_ */