kwave  18.07.70
Kwave::Signal Class Reference

#include <Signal.h>

Inheritance diagram for Kwave::Signal:
Inheritance graph
Collaboration diagram for Kwave::Signal:
Collaboration graph

Signals

void sigTrackInserted (unsigned int index, Kwave::Track *track)
 
void sigTrackDeleted (unsigned int index, Kwave::Track *track)
 
void sigTrackSelectionChanged (bool enabled)
 
void sigSamplesInserted (unsigned int track, sample_index_t offset, sample_index_t length)
 
void sigSamplesDeleted (unsigned int track, sample_index_t offset, sample_index_t length)
 
void sigSamplesModified (unsigned int track, sample_index_t offset, sample_index_t length)
 

Public Member Functions

 Signal ()
 
 Signal (unsigned int tracks, sample_index_t length)
 
virtual ~Signal ()
 
void close ()
 
Kwave::TrackinsertTrack (unsigned int index, sample_index_t length, QUuid *uuid)
 
Kwave::TrackappendTrack (sample_index_t length, QUuid *uuid)
 
void deleteTrack (unsigned int index)
 
QList< unsigned int > allTracks ()
 
Kwave::WriteropenWriter (Kwave::InsertMode mode, unsigned int track, sample_index_t left=0, sample_index_t right=0)
 
Kwave::SampleReaderopenReader (Kwave::ReaderMode mode, unsigned int track, sample_index_t left=0, sample_index_t right=SAMPLE_INDEX_MAX)
 
Kwave::Stripe::List stripes (unsigned int track, sample_index_t left=0, sample_index_t right=SAMPLE_INDEX_MAX)
 
bool mergeStripes (const Kwave::Stripe::List &stripes, unsigned int track)
 
unsigned int tracks ()
 
void deleteRange (unsigned int track, sample_index_t offset, sample_index_t length)
 
void insertSpace (unsigned int track, sample_index_t offset, sample_index_t length)
 
sample_index_t length ()
 
bool trackSelected (unsigned int track)
 
void selectTrack (unsigned int track, bool select)
 
QUuid uuidOfTrack (unsigned int track)
 

Private Slots

void slotSamplesInserted (Kwave::Track *src, sample_index_t offset, sample_index_t length)
 
void slotSamplesDeleted (Kwave::Track *src, sample_index_t offset, sample_index_t length)
 
void slotSamplesModified (Kwave::Track *src, sample_index_t offset, sample_index_t length)
 

Private Member Functions

unsigned int trackIndex (const Kwave::Track *track)
 

Private Attributes

QList< Kwave::Track * > m_tracks
 
QReadWriteLock m_lock_tracks
 

Detailed Description

Definition at line 46 of file Signal.h.

Constructor & Destructor Documentation

◆ Signal() [1/2]

Kwave::Signal::Signal ( )

Default Constructor. Creates an empty signal with zero-length and no tracks

Definition at line 40 of file Signal.cpp.

42 {
43 }
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316

◆ Signal() [2/2]

Kwave::Signal::Signal ( unsigned int  tracks,
sample_index_t  length 
)

Constructor. Creates an empty signal with a specified number of tracks and length. Each track will contain only one stripe.

Definition at line 46 of file Signal.cpp.

References appendTrack().

48 {
49  while (tracks--) {
50  appendTrack(length, Q_NULLPTR);
51  }
52 }
sample_index_t length()
Definition: Signal.cpp:258
Kwave::Track * appendTrack(sample_index_t length, QUuid *uuid)
Definition: Signal.cpp:113
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316
unsigned int tracks()
Definition: Signal.cpp:251
Here is the call graph for this function:

◆ ~Signal()

Kwave::Signal::~Signal ( )
virtual

Destructor.

Definition at line 55 of file Signal.cpp.

References close().

56 {
57  close();
58 }
void close()
Definition: Signal.cpp:61
Here is the call graph for this function:

Member Function Documentation

◆ allTracks()

QList< unsigned int > Kwave::Signal::allTracks ( )

Returns an array of indices of all present tracks.

Definition at line 206 of file Signal.cpp.

References tracks().

Referenced by Kwave::SignalManager::allTracks().

207 {
208  unsigned int track;
209  unsigned int tracks = this->tracks();
210  QList<unsigned int> list;
211 
212  for (track=0; track < tracks; track++) {
213  list.append(track);
214  }
215 
216  return list;
217 }
unsigned int tracks()
Definition: Signal.cpp:251
Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendTrack()

Kwave::Track * Kwave::Signal::appendTrack ( sample_index_t  length,
QUuid *  uuid 
)

Appends a new track to the end of the tracks list, shortcut for insertTrack(tracks()-1, length)

See also
insertTrack
Parameters
lengthnumber of samples of the new track (zero is allowed)
uuidpointer to a unique ID (optional, can be null)

Definition at line 113 of file Signal.cpp.

References insertTrack(), and tracks().

Referenced by Kwave::SignalManager::insertTrack(), Kwave::SignalManager::loadFile(), Kwave::SignalManager::newSignal(), and Signal().

114 {
115  return insertTrack(tracks(), length, uuid);
116 }
sample_index_t length()
Definition: Signal.cpp:258
Kwave::Track * insertTrack(unsigned int index, sample_index_t length, QUuid *uuid)
Definition: Signal.cpp:69
unsigned int tracks()
Definition: Signal.cpp:251
Here is the call graph for this function:
Here is the caller graph for this function:

◆ close()

void Kwave::Signal::close ( )

Closes the signal by removing all tracks.

Definition at line 61 of file Signal.cpp.

References deleteTrack(), and tracks().

Referenced by Kwave::SignalManager::close(), Kwave::SignalManager::loadFile(), and ~Signal().

62 {
63  unsigned int count;
64  while ((count = tracks()))
65  deleteTrack(count - 1);
66 }
void deleteTrack(unsigned int index)
Definition: Signal.cpp:119
unsigned int tracks()
Definition: Signal.cpp:251
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteRange()

void Kwave::Signal::deleteRange ( unsigned int  track,
sample_index_t  offset,
sample_index_t  length 
)

Deletes a range of samples

Parameters
trackindex of the track
offsetindex of the first sample
lengthnumber of samples

Definition at line 220 of file Signal.cpp.

References Kwave::Track::deleteRange(), m_lock_tracks, m_tracks, and Kwave::toInt().

Referenced by Kwave::SignalManager::deleteRange(), and Kwave::SignalManager::executeCommand().

223 {
224  QReadLocker lock(&m_lock_tracks);
225 
226  Q_ASSERT(Kwave::toInt(track) < m_tracks.count());
227  if (Kwave::toInt(track) >= m_tracks.count())
228  return; // track does not exist !
229 
230  Kwave::Track *t = m_tracks.at(track);
231  Q_ASSERT(t);
232  if (t) t->deleteRange(offset, length);
233 }
sample_index_t length()
Definition: Signal.cpp:258
void deleteRange(sample_index_t offset, sample_index_t length, bool make_gap=false)
Definition: Track.cpp:293
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316
int toInt(T x)
Definition: Utils.h:127
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteTrack()

void Kwave::Signal::deleteTrack ( unsigned int  index)

Deletes a track.

Parameters
indexthe index of the track to be deleted [0...tracks()-1]

Definition at line 119 of file Signal.cpp.

References m_lock_tracks, m_tracks, sigTrackDeleted(), and Kwave::toInt().

Referenced by close(), Kwave::SignalManager::deleteTrack(), and Kwave::UndoInsertTrack::undo().

120 {
121  // remove the track from the list but do not delete it
122  Kwave::Track *t = Q_NULLPTR;
123  {
124  QWriteLocker lock(&m_lock_tracks);
125  if (Kwave::toInt(index) > m_tracks.count())
126  return; // bail out if not in range
127 
128  t = m_tracks.at(index);
129  m_tracks.removeAt(index);
130  }
131 
132  // now emit a signal that the track has been deleted. Maybe
133  // someone is still using a reference to it, so we have not
134  // deleted it yet - still only unlinked from the track list!
135  emit sigTrackDeleted(index, t);
136 
137  // as everybody now knows that the track is gone, we can safely
138  // delete it now.
139  if (t) delete t;
140 }
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316
int toInt(T x)
Definition: Utils.h:127
void sigTrackDeleted(unsigned int index, Kwave::Track *track)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertSpace()

void Kwave::Signal::insertSpace ( unsigned int  track,
sample_index_t  offset,
sample_index_t  length 
)

Inserts some space at a given position

Parameters
trackindex of the track
offsetindex of the first sample
lengthnumber of samples

Definition at line 236 of file Signal.cpp.

References Kwave::Track::insertSpace(), m_lock_tracks, m_tracks, and Kwave::toInt().

Referenced by Kwave::SignalManager::insertSpace().

238 {
239  QReadLocker lock(&m_lock_tracks);
240 
241  Q_ASSERT(Kwave::toInt(track) < m_tracks.count());
242  if (Kwave::toInt(track) >= m_tracks.count())
243  return; // track does not exist !
244 
245  Kwave::Track *t = m_tracks.at(track);
246  Q_ASSERT(t);
247  if (t) t->insertSpace(offset, length);
248 }
sample_index_t length()
Definition: Signal.cpp:258
bool insertSpace(sample_index_t offset, sample_index_t shift)
Definition: Track.cpp:314
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316
int toInt(T x)
Definition: Utils.h:127
Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertTrack()

Kwave::Track * Kwave::Signal::insertTrack ( unsigned int  index,
sample_index_t  length,
QUuid *  uuid 
)

Inserts a new track to into the track list or appends it to the end.

Parameters
indexthe 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.
lengthnumber of samples of the new track (zero is allowed)
uuidpointer to a unique ID (optional, can be null)
Returns
pointer to the created track. If the length is omitted or zero, the track will have zero length.

Definition at line 69 of file Signal.cpp.

References Kwave::connect(), m_lock_tracks, m_tracks, sigSamplesDeleted(), sigSamplesInserted(), sigSamplesModified(), sigTrackInserted(), sigTrackSelectionChanged(), slotSamplesDeleted(), slotSamplesInserted(), slotSamplesModified(), and Kwave::toInt().

Referenced by appendTrack(), Kwave::SignalManager::insertTrack(), and Kwave::UndoDeleteTrack::undo().

72 {
73  Kwave::Track *t = Q_NULLPTR;
74  {
75  QWriteLocker lock(&m_lock_tracks);
76 
77  t = new(std::nothrow) Kwave::Track(length, uuid);
78  Q_ASSERT(t);
79  if (!t) return Q_NULLPTR;
80 
81  // clip the track index
82  if (Kwave::toInt(index) > m_tracks.count())
83  index = m_tracks.count();
84 
85  // insert / append to the list
86  m_tracks.insert(index, t);
87 
88  // connect to the new track's signals
92  sample_index_t)));
96  sample_index_t)));
100  sample_index_t)));
101 
102  connect(t, SIGNAL(sigSelectionChanged(bool)),
103  this, SIGNAL(sigTrackSelectionChanged(bool)));
104  }
105 
106  // track has been inserted
107  emit sigTrackInserted(index, t);
108  return t;
109 }
void sigTrackSelectionChanged(bool enabled)
sample_index_t length()
Definition: Signal.cpp:258
void slotSamplesModified(Kwave::Track *src, sample_index_t offset, sample_index_t length)
Definition: Signal.cpp:594
void sigTrackInserted(unsigned int index, Kwave::Track *track)
quint64 sample_index_t
Definition: Sample.h:28
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
void sigSamplesDeleted(unsigned int track, sample_index_t offset, sample_index_t length)
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316
void slotSamplesDeleted(Kwave::Track *src, sample_index_t offset, sample_index_t length)
Definition: Signal.cpp:585
int toInt(T x)
Definition: Utils.h:127
void sigSamplesModified(unsigned int track, sample_index_t offset, sample_index_t length)
void slotSamplesInserted(Kwave::Track *src, sample_index_t offset, sample_index_t length)
Definition: Signal.cpp:576
void sigSamplesInserted(unsigned int track, sample_index_t offset, sample_index_t length)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ length()

sample_index_t Kwave::Signal::length ( )

Returns the length of the signal. This is determined by searching for the highest sample position of all tracks.

Definition at line 258 of file Signal.cpp.

References Kwave::Track::length(), m_lock_tracks, and m_tracks.

Referenced by Kwave::UndoInsertTrack::redoSize(), Kwave::SignalManager::slotSamplesDeleted(), and Kwave::SignalManager::slotSamplesInserted().

259 {
260  QReadLocker lock(&m_lock_tracks);
261 
262  sample_index_t max = 0;
263  foreach (Kwave::Track *track, m_tracks) {
264  if (!track) continue;
265  sample_index_t len = track->length();
266  if (len > max) max = len;
267  }
268  return max;
269 }
quint64 sample_index_t
Definition: Sample.h:28
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316
sample_index_t length()
Definition: Track.cpp:173
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mergeStripes()

bool Kwave::Signal::mergeStripes ( const Kwave::Stripe::List stripes,
unsigned int  track 
)

Merge a list of stripes into the signal.

Parameters
stripeslist of stripes
trackindex of the track
Returns
true if succeeded, false if failed

Definition at line 190 of file Signal.cpp.

References m_lock_tracks, m_tracks, Kwave::Track::mergeStripes(), and Kwave::toInt().

Referenced by Kwave::SignalManager::mergeStripes().

192 {
193  QReadLocker lock(&m_lock_tracks);
194 
195  if (Kwave::toInt(track) >= m_tracks.count())
196  return false;
197 
198  Kwave::Track *t = m_tracks.at(track);
199  Q_ASSERT(t);
200  if (!t) return false;
201 
202  return t->mergeStripes(stripes);
203 }
bool mergeStripes(const Kwave::Stripe::List &stripes)
Definition: Track.cpp:251
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316
int toInt(T x)
Definition: Utils.h:127
Here is the call graph for this function:
Here is the caller graph for this function:

◆ openReader()

Kwave::SampleReader * Kwave::Signal::openReader ( Kwave::ReaderMode  mode,
unsigned int  track,
sample_index_t  left = 0,
sample_index_t  right = SAMPLE_INDEX_MAX 
)

Opens a stream for reading samples. If the last position is omitted, the value UINT_MAX will be used.

Parameters
modea reader mode, see Kwave::ReaderMode
trackindex of the track
leftfirst offset to be read (default = 0)
rightlast position to read (default = UINT_MAX)
Returns
a SampleReader or null if the track does not exist

Definition at line 159 of file Signal.cpp.

References m_lock_tracks, m_tracks, Kwave::Track::openReader(), and Kwave::toInt().

163 {
164  QReadLocker lock(&m_lock_tracks);
165 
166  if (Kwave::toInt(track) >= m_tracks.count())
167  return Q_NULLPTR; // track does not exist !
168 
169  Kwave::Track *t = m_tracks.at(track);
170  Q_ASSERT(t);
171  return (t) ? t->openReader(mode, left, right) : Q_NULLPTR;
172 }
Kwave::SampleReader * openReader(Kwave::ReaderMode mode, sample_index_t left=0, sample_index_t right=SAMPLE_INDEX_MAX)
Definition: Track.cpp:274
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316
int toInt(T x)
Definition: Utils.h:127
Here is the call graph for this function:

◆ openWriter()

Kwave::Writer * Kwave::Signal::openWriter ( Kwave::InsertMode  mode,
unsigned int  track,
sample_index_t  left = 0,
sample_index_t  right = 0 
)

Opens an output stream for a track, starting at a specified sample position.

Parameters
modespecifies where and how to insert
trackindex of the track
leftstart of the input (only useful in insert and overwrite mode)
rightend of the input (only useful with overwrite mode)
Returns
a Writer or null pointer if the track does not exist
See also
InsertMode

Definition at line 143 of file Signal.cpp.

References m_lock_tracks, m_tracks, Kwave::Track::openWriter(), and Kwave::toInt().

145 {
146  QReadLocker lock(&m_lock_tracks);
147 
148  Q_ASSERT(Kwave::toInt(track) < m_tracks.count());
149  if (Kwave::toInt(track) >= m_tracks.count()) {
150  return Q_NULLPTR; // track does not exist !
151  }
152 
153  Kwave::Track *t = m_tracks.at(track);
154  Q_ASSERT(t);
155  return (t) ? t->openWriter(mode, left, right) : Q_NULLPTR;
156 }
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316
int toInt(T x)
Definition: Utils.h:127
Kwave::Writer * openWriter(Kwave::InsertMode mode, sample_index_t left=0, sample_index_t right=0)
Definition: Track.cpp:188
Here is the call graph for this function:

◆ selectTrack()

void Kwave::Signal::selectTrack ( unsigned int  track,
bool  select 
)

Sets the "selected" flag of a track.

Parameters
trackindex of the track [0...tracks-1]
selecttrue if the track should be selected, false for de-selecting

Definition at line 283 of file Signal.cpp.

References m_lock_tracks, m_tracks, and Kwave::toInt().

Referenced by Kwave::SignalManager::selectTrack(), and Kwave::SignalManager::selectTracks().

284 {
285  QReadLocker lock(&m_lock_tracks);
286 
287  Q_ASSERT(Kwave::toInt(track) < m_tracks.count());
288  if (Kwave::toInt(track) >= m_tracks.count()) return;
289  Q_ASSERT(m_tracks.at(track));
290  if (!m_tracks.at(track)) return;
291 
292  m_tracks.at(track)->select(select);
293 }
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316
int toInt(T x)
Definition: Utils.h:127
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sigSamplesDeleted

void Kwave::Signal::sigSamplesDeleted ( unsigned int  track,
sample_index_t  offset,
sample_index_t  length 
)
signal

Emitted if samples have been removed from a track.

Parameters
trackindex of the track
offsetposition from which the data was removed
lengthnumber of samples deleted

Referenced by insertTrack(), and slotSamplesDeleted().

Here is the caller graph for this function:

◆ sigSamplesInserted

void Kwave::Signal::sigSamplesInserted ( unsigned int  track,
sample_index_t  offset,
sample_index_t  length 
)
signal

Emitted if samples have been inserted into a track. This implies a modification of the inserted data, so no extra sigSamplesModified is emitted.

Parameters
trackindex of the track
offsetposition from which the data was inserted
lengthnumber of samples inserted
See also
sigSamplesModified

Referenced by insertTrack(), and slotSamplesInserted().

Here is the caller graph for this function:

◆ sigSamplesModified

void Kwave::Signal::sigSamplesModified ( unsigned int  track,
sample_index_t  offset,
sample_index_t  length 
)
signal

Emitted if samples within a track have been modified.

Parameters
trackindex of the track
offsetposition from which the data was modified
lengthnumber of samples modified

Referenced by insertTrack(), and slotSamplesModified().

Here is the caller graph for this function:

◆ sigTrackDeleted

void Kwave::Signal::sigTrackDeleted ( unsigned int  index,
Kwave::Track track 
)
signal

Signals that a track has been deleted.

Parameters
indexposition of the deleted track [0...tracks()-1]
trackreference to the deleted track

Referenced by deleteTrack().

Here is the caller graph for this function:

◆ sigTrackInserted

void Kwave::Signal::sigTrackInserted ( unsigned int  index,
Kwave::Track track 
)
signal

Signals that a track has been inserted.

Parameters
indexposition of the new track [0...tracks()-1]
trackreference to the new track

Referenced by insertTrack().

Here is the caller graph for this function:

◆ sigTrackSelectionChanged

void Kwave::Signal::sigTrackSelectionChanged ( bool  enabled)
signal

Signals that the selection of one of the tracks has changed

Parameters
enabledstate of the track, true=selected

Referenced by insertTrack().

Here is the caller graph for this function:

◆ slotSamplesDeleted

void Kwave::Signal::slotSamplesDeleted ( Kwave::Track src,
sample_index_t  offset,
sample_index_t  length 
)
privateslot

Connected to each track's sigSamplesDeleted.

Parameters
srcsource track
offsetposition from which the data was removed
lengthnumber of samples deleted
See also
Track::sigSamplesDeleted

Definition at line 585 of file Signal.cpp.

References sigSamplesDeleted(), and trackIndex().

Referenced by insertTrack().

588 {
589  unsigned int track = trackIndex(src);
590  emit sigSamplesDeleted(track, offset, length);
591 }
unsigned int trackIndex(const Kwave::Track *track)
Definition: Signal.cpp:567
sample_index_t length()
Definition: Signal.cpp:258
void sigSamplesDeleted(unsigned int track, sample_index_t offset, sample_index_t length)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ slotSamplesInserted

void Kwave::Signal::slotSamplesInserted ( Kwave::Track src,
sample_index_t  offset,
sample_index_t  length 
)
privateslot

Connected to each track's sigSamplesInserted.

Parameters
srcsource track
offsetposition from which the data was inserted
lengthnumber of samples inserted
See also
Track::sigSamplesInserted

Definition at line 576 of file Signal.cpp.

References sigSamplesInserted(), and trackIndex().

Referenced by insertTrack().

579 {
580  unsigned int track = trackIndex(src);
581  emit sigSamplesInserted(track, offset, length);
582 }
unsigned int trackIndex(const Kwave::Track *track)
Definition: Signal.cpp:567
sample_index_t length()
Definition: Signal.cpp:258
void sigSamplesInserted(unsigned int track, sample_index_t offset, sample_index_t length)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ slotSamplesModified

void Kwave::Signal::slotSamplesModified ( Kwave::Track src,
sample_index_t  offset,
sample_index_t  length 
)
privateslot

Connected to each track's sigSamplesModified

Parameters
srcsource track
offsetposition from which the data was modified
lengthnumber of samples modified
See also
Track::sigSamplesModified

Definition at line 594 of file Signal.cpp.

References sigSamplesModified(), and trackIndex().

Referenced by insertTrack().

597 {
598  unsigned int track = trackIndex(src);
599  emit sigSamplesModified(track, offset, length);
600 }
unsigned int trackIndex(const Kwave::Track *track)
Definition: Signal.cpp:567
sample_index_t length()
Definition: Signal.cpp:258
void sigSamplesModified(unsigned int track, sample_index_t offset, sample_index_t length)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stripes()

Kwave::Stripe::List Kwave::Signal::stripes ( unsigned int  track,
sample_index_t  left = 0,
sample_index_t  right = SAMPLE_INDEX_MAX 
)

Get a list of stripes that matches a given range of samples

Parameters
trackindex of the track
leftoffset of the first sample
rightoffset of the last sample
Returns
a list of stripes that cover the given range between left and right

Definition at line 175 of file Signal.cpp.

References m_lock_tracks, m_tracks, Kwave::Track::stripes(), and Kwave::toInt().

Referenced by Kwave::SignalManager::stripes().

178 {
179  QReadLocker lock(&m_lock_tracks);
180 
181  if (Kwave::toInt(track) < m_tracks.count()) {
182  Kwave::Track *t = m_tracks.at(track);
183  Q_ASSERT(t);
184  if (t) return t->stripes(left, right);
185  }
186  return Kwave::Stripe::List(); // track does not exist !
187 }
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316
int toInt(T x)
Definition: Utils.h:127
Kwave::Stripe::List stripes(sample_index_t left, sample_index_t right)
Definition: Track.cpp:209
Here is the call graph for this function:
Here is the caller graph for this function:

◆ trackIndex()

unsigned int Kwave::Signal::trackIndex ( const Kwave::Track track)
private

Looks up the index of a track in the track list

Parameters
trackreference to the trac to be looked up
Returns
index of the track [0...tracks()-1] or tracks() if not found
Todo:
needs to be ported to fftw, moved to a plugin and re-activated

Definition at line 567 of file Signal.cpp.

References m_lock_tracks, and m_tracks.

Referenced by slotSamplesDeleted(), slotSamplesInserted(), and slotSamplesModified().

568 {
569  QReadLocker lock(&m_lock_tracks);
570 
571  int index = m_tracks.indexOf(const_cast<Kwave::Track *>(track));
572  return (index >= 0) ? index : m_tracks.count();
573 }
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316
Here is the caller graph for this function:

◆ tracks()

unsigned int Kwave::Signal::tracks ( )

Returns the number of tracks.

Definition at line 251 of file Signal.cpp.

References m_lock_tracks, and m_tracks.

Referenced by allTracks(), appendTrack(), and close().

252 {
253  QReadLocker lock(&m_lock_tracks);
254  return m_tracks.count();
255 }
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316
Here is the caller graph for this function:

◆ trackSelected()

bool Kwave::Signal::trackSelected ( unsigned int  track)

Queries if a track is selected. If the index of the track is out of range, the return value will be false.

Definition at line 272 of file Signal.cpp.

References m_lock_tracks, m_tracks, and Kwave::toInt().

Referenced by Kwave::SignalManager::selectedTracks(), Kwave::SignalManager::selectTrack(), and Kwave::SignalManager::selectTracks().

273 {
274  QReadLocker lock(&m_lock_tracks);
275 
276  if (Kwave::toInt(track) >= m_tracks.count()) return false;
277  if (!m_tracks.at(track)) return false;
278 
279  return m_tracks.at(track)->selected();
280 }
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316
int toInt(T x)
Definition: Utils.h:127
Here is the call graph for this function:
Here is the caller graph for this function:

◆ uuidOfTrack()

QUuid Kwave::Signal::uuidOfTrack ( unsigned int  track)

Returns the uuid of a track

Parameters
trackindex of the track [0...tracks-1]
Returns
the QUuid of the track or a "null" uuid if the track does not exist

Definition at line 296 of file Signal.cpp.

References m_lock_tracks, m_tracks, and Kwave::toInt().

297 {
298  QReadLocker lock(&m_lock_tracks);
299 
300  if (Kwave::toInt(track) >= m_tracks.count()) return QUuid();
301  Q_ASSERT(m_tracks.at(track));
302  if (!m_tracks.at(track)) return QUuid();
303 
304  return m_tracks.at(track)->uuid();
305 }
QList< Kwave::Track * > m_tracks
Definition: Signal.h:313
QReadWriteLock m_lock_tracks
Definition: Signal.h:316
int toInt(T x)
Definition: Utils.h:127
Here is the call graph for this function:

Member Data Documentation

◆ m_lock_tracks

QReadWriteLock Kwave::Signal::m_lock_tracks
private

◆ m_tracks

QList<Kwave::Track *> Kwave::Signal::m_tracks
private

The documentation for this class was generated from the following files: