Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 412007
Collapse All | Expand All

(-)a/kwave/MainWidget.cpp (-3 / +5 lines)
Lines 172-179 MainWidget::MainWidget(QWidget *parent, Kwave::ApplicationContext &context) Link Here
172
172
173
    // -- connect all signals from/to the signal manager --
173
    // -- connect all signals from/to the signal manager --
174
174
175
    connect(signal_manager, SIGNAL(sigTrackInserted(unsigned int, Track *)),
175
    connect(signal_manager,
176
	    this,           SLOT(slotTrackInserted(unsigned int, Track *)));
176
	    SIGNAL(sigTrackInserted(unsigned int, Kwave::Track *)),
177
	    this,
178
	    SLOT(slotTrackInserted(unsigned int, Kwave::Track *)));
177
    connect(signal_manager, SIGNAL(sigTrackDeleted(unsigned int)),
179
    connect(signal_manager, SIGNAL(sigTrackDeleted(unsigned int)),
178
	    this,           SLOT(slotTrackDeleted(unsigned int)));
180
	    this,           SLOT(slotTrackDeleted(unsigned int)));
179
    connect(signal_manager, 
181
    connect(signal_manager, 
Lines 319-325 void MainWidget::verticalScrollBarMoved(int newval) Link Here
319
}
321
}
320
322
321
//***************************************************************************
323
//***************************************************************************
322
void MainWidget::slotTrackInserted(unsigned int index, Track *track)
324
void MainWidget::slotTrackInserted(unsigned int index, Kwave::Track *track)
323
{
325
{
324
//     qDebug("MainWidget::slotTrackInserted(%u, %p)",
326
//     qDebug("MainWidget::slotTrackInserted(%u, %p)",
325
// 	   index, static_cast<void *>(track));
327
// 	   index, static_cast<void *>(track));
(-)a/kwave/MainWidget.h (-1 / +1 lines)
Lines 193-199 private slots: Link Here
193
     * @see SignalManager::sigTrackInserted
193
     * @see SignalManager::sigTrackInserted
194
     * @internal
194
     * @internal
195
     */
195
     */
196
    void slotTrackInserted(unsigned int index, Track *track);
196
    void slotTrackInserted(unsigned int index, Kwave::Track *track);
197
197
198
    /**
198
    /**
199
     * Called if a track has been deleted. Updates the display by
199
     * Called if a track has been deleted. Updates the display by
(-)a/libgui/OverViewCache.cpp (-3 / +3 lines)
Lines 43-50 OverViewCache::OverViewCache(SignalManager &signal, sample_index_t src_offset, Link Here
43
    // connect to the signal manager
43
    // connect to the signal manager
44
    SignalManager *sig = &signal;
44
    SignalManager *sig = &signal;
45
    Q_ASSERT(sig);
45
    Q_ASSERT(sig);
46
    connect(sig, SIGNAL(sigTrackInserted(unsigned int, Track *)),
46
    connect(sig, SIGNAL(sigTrackInserted(unsigned int, Kwave::Track *)),
47
            this, SLOT(slotTrackInserted(unsigned int, Track *)));
47
            this, SLOT(slotTrackInserted(unsigned int, Kwave::Track *)));
48
    connect(sig, SIGNAL(sigTrackDeleted(unsigned int)),
48
    connect(sig, SIGNAL(sigTrackDeleted(unsigned int)),
49
            this, SLOT(slotTrackDeleted(unsigned int)));
49
            this, SLOT(slotTrackDeleted(unsigned int)));
50
    connect(sig, SIGNAL(sigSamplesDeleted(unsigned int, sample_index_t,
50
    connect(sig, SIGNAL(sigSamplesDeleted(unsigned int, sample_index_t,
Lines 208-214 void OverViewCache::invalidateCache(unsigned int track, unsigned int first, Link Here
208
}
208
}
209
209
210
//***************************************************************************
210
//***************************************************************************
211
void OverViewCache::slotTrackInserted(unsigned int index, Track *)
211
void OverViewCache::slotTrackInserted(unsigned int index, Kwave::Track *)
212
{
212
{
213
    QMutexLocker lock(&m_lock);
213
    QMutexLocker lock(&m_lock);
214
214
(-)a/libgui/OverViewCache.h (-2 / +2 lines)
Lines 32-38 Link Here
32
32
33
class QColor;
33
class QColor;
34
class SignalManager;
34
class SignalManager;
35
class Track;
35
namespace Kwave { class Track; }
36
36
37
/**
37
/**
38
 * @class OverViewCache
38
 * @class OverViewCache
Lines 87-93 protected slots: Link Here
87
     * @see Signal::sigTrackInserted
87
     * @see Signal::sigTrackInserted
88
     * @internal
88
     * @internal
89
     */
89
     */
90
    void slotTrackInserted(unsigned int index, Track *);
90
    void slotTrackInserted(unsigned int index, Kwave::Track *);
91
91
92
    /**
92
    /**
93
     * Connected to the signal's sigTrackInserted.
93
     * Connected to the signal's sigTrackInserted.
(-)a/libgui/OverViewWidget.h (-1 / +1 lines)
Lines 39-45 class QMouseEvent; Link Here
39
class QPainter;
39
class QPainter;
40
class QResizeEvent;
40
class QResizeEvent;
41
class SignalManager;
41
class SignalManager;
42
class Track;
42
namespace Kwave { class Track; }
43
43
44
class KDE_EXPORT OverViewWidget : public ImageView
44
class KDE_EXPORT OverViewWidget : public ImageView
45
{
45
{
(-)a/libgui/SignalWidget.cpp (-3 / +3 lines)
Lines 112-119 SignalWidget::SignalWidget(QWidget *parent, Kwave::ApplicationContext &context, Link Here
112
    // connect to the signal manager's signals
112
    // connect to the signal manager's signals
113
    SignalManager *sig = m_context.signalManager();
113
    SignalManager *sig = m_context.signalManager();
114
114
115
    connect(sig,  SIGNAL(sigTrackInserted(unsigned int, Track *)),
115
    connect(sig,  SIGNAL(sigTrackInserted(unsigned int, Kwave::Track *)),
116
            this, SLOT( slotTrackInserted(unsigned int, Track *)));
116
            this, SLOT( slotTrackInserted(unsigned int, Kwave::Track *)));
117
    connect(sig,  SIGNAL(sigTrackDeleted(unsigned int)),
117
    connect(sig,  SIGNAL(sigTrackDeleted(unsigned int)),
118
            this, SLOT( slotTrackDeleted(unsigned int)));
118
            this, SLOT( slotTrackDeleted(unsigned int)));
119
119
Lines 578-584 void SignalWidget::insertView(Kwave::SignalView *view, QWidget *controls) Link Here
578
}
578
}
579
579
580
//***************************************************************************
580
//***************************************************************************
581
void SignalWidget::slotTrackInserted(unsigned int index, Track *track)
581
void SignalWidget::slotTrackInserted(unsigned int index, Kwave::Track *track)
582
{
582
{
583
    Q_ASSERT(track);
583
    Q_ASSERT(track);
584
    if (!track) return;
584
    if (!track) return;
(-)a/libgui/SignalWidget.h (-2 / +2 lines)
Lines 62-68 class KUrl; Link Here
62
class LabelType;
62
class LabelType;
63
class SignalManager;
63
class SignalManager;
64
class TimeOperation;
64
class TimeOperation;
65
class Track;
65
namespace Kwave { class Track; }
66
class TrackPixmap;
66
class TrackPixmap;
67
67
68
namespace Kwave { class ApplicationContext; }
68
namespace Kwave { class ApplicationContext; }
Lines 154-160 private slots: Link Here
154
     * @see Signal::sigTrackInserted
154
     * @see Signal::sigTrackInserted
155
     * @internal
155
     * @internal
156
     */
156
     */
157
    void slotTrackInserted(unsigned int index, Track *track);
157
    void slotTrackInserted(unsigned int index, Kwave::Track *track);
158
158
159
    /**
159
    /**
160
     * Connected to the signal's sigTrackDeleted.
160
     * Connected to the signal's sigTrackDeleted.
(-)a/libgui/TrackPixmap.cpp (-10 / +15 lines)
Lines 63-69 static Kwave::TrackPixmap::color_set_t color_set_disabled = Link Here
63
};
63
};
64
64
65
//***************************************************************************
65
//***************************************************************************
66
Kwave::TrackPixmap::TrackPixmap(Track &track)
66
Kwave::TrackPixmap::TrackPixmap(Kwave::Track &track)
67
    :QObject(), m_pixmap(), m_track(track), m_offset(0), m_zoom(0.0),
67
    :QObject(), m_pixmap(), m_track(track), m_offset(0), m_zoom(0.0),
68
    m_vertical_zoom(1.0), m_minmax_mode(false),
68
    m_vertical_zoom(1.0), m_minmax_mode(false),
69
    m_sample_buffer(), m_min_buffer(), m_max_buffer(),
69
    m_sample_buffer(), m_min_buffer(), m_max_buffer(),
Lines 72-85 Kwave::TrackPixmap::TrackPixmap(Track &track) Link Here
72
    m_colors(color_set_normal)
72
    m_colors(color_set_normal)
73
{
73
{
74
    // connect all the notification signals of the track
74
    // connect all the notification signals of the track
75
    connect(&track, SIGNAL(sigSamplesInserted(Track *, sample_index_t,
75
    connect(&track,
76
	sample_index_t)), this, SLOT(slotSamplesInserted(Track *,
76
	SIGNAL(sigSamplesInserted(Kwave::Track *, sample_index_t,
77
	sample_index_t)), this,
78
	SLOT(slotSamplesInserted(Kwave::Track *,
77
	sample_index_t, sample_index_t)));
79
	sample_index_t, sample_index_t)));
78
    connect(&track, SIGNAL(sigSamplesDeleted(Track *, sample_index_t,
80
    connect(&track, SIGNAL(sigSamplesDeleted(Kwave::Track *, sample_index_t,
79
	sample_index_t)), this, SLOT(slotSamplesDeleted(Track *,
81
	sample_index_t)), this, SLOT(slotSamplesDeleted(Kwave::Track *,
80
	sample_index_t, sample_index_t)));
82
	sample_index_t, sample_index_t)));
81
    connect(&track, SIGNAL(sigSamplesModified(Track *, sample_index_t,
83
    connect(&track, SIGNAL(sigSamplesModified(Kwave::Track *, sample_index_t,
82
	sample_index_t)), this, SLOT(slotSamplesModified(Track *,
84
	sample_index_t)), this, SLOT(slotSamplesModified(Kwave::Track *,
83
	sample_index_t, sample_index_t)));
85
	sample_index_t, sample_index_t)));
84
    connect(&track, SIGNAL(sigSelectionChanged(bool)),
86
    connect(&track, SIGNAL(sigSelectionChanged(bool)),
85
            this, SLOT(selectionChanged()));
87
            this, SLOT(selectionChanged()));
Lines 701-707 void Kwave::TrackPixmap::drawPolyLineSignal(QPainter &p, int width, Link Here
701
}
703
}
702
704
703
//***************************************************************************
705
//***************************************************************************
704
void Kwave::TrackPixmap::slotSamplesInserted(Track *, sample_index_t offset,
706
void Kwave::TrackPixmap::slotSamplesInserted(Kwave::Track *,
707
                                             sample_index_t offset,
705
                                             sample_index_t length)
708
                                             sample_index_t length)
706
{
709
{
707
    {
710
    {
Lines 726-732 void Kwave::TrackPixmap::slotSamplesInserted(Track *, sample_index_t offset, Link Here
726
}
729
}
727
730
728
//***************************************************************************
731
//***************************************************************************
729
void Kwave::TrackPixmap::slotSamplesDeleted(Track *, sample_index_t offset,
732
void Kwave::TrackPixmap::slotSamplesDeleted(Kwave::Track *,
733
                                            sample_index_t offset,
730
                                            sample_index_t length)
734
                                            sample_index_t length)
731
{
735
{
732
    {
736
    {
Lines 751-757 void Kwave::TrackPixmap::slotSamplesDeleted(Track *, sample_index_t offset, Link Here
751
}
755
}
752
756
753
//***************************************************************************
757
//***************************************************************************
754
void Kwave::TrackPixmap::slotSamplesModified(Track *, sample_index_t offset,
758
void Kwave::TrackPixmap::slotSamplesModified(Kwave::Track *,
759
                                             sample_index_t offset,
755
                                             sample_index_t length)
760
                                             sample_index_t length)
756
{
761
{
757
    {
762
    {
(-)a/libgui/TrackPixmap.h (-7 / +7 lines)
Lines 34-41 Link Here
34
#include "libkwave/Sample.h"
34
#include "libkwave/Sample.h"
35
#include "libkwave/KwaveSampleArray.h"
35
#include "libkwave/KwaveSampleArray.h"
36
36
37
class Track;
38
39
/**
37
/**
40
 * The TrackPixmap is a graphical representation of a track's sample
38
 * The TrackPixmap is a graphical representation of a track's sample
41
 * data. It is connected directly to a Track object so that it is able
39
 * data. It is connected directly to a Track object so that it is able
Lines 62-67 class Track; Link Here
62
 */
60
 */
63
namespace Kwave
61
namespace Kwave
64
{
62
{
63
    class Track;
64
65
    class KDE_EXPORT TrackPixmap : public QObject
65
    class KDE_EXPORT TrackPixmap : public QObject
66
    {
66
    {
67
	Q_OBJECT
67
	Q_OBJECT
Lines 69-75 namespace Kwave Link Here
69
    public:
69
    public:
70
70
71
	/** Default constructor */
71
	/** Default constructor */
72
	TrackPixmap(Track &track);
72
	TrackPixmap(Kwave::Track &track);
73
73
74
	/** Destructor */
74
	/** Destructor */
75
	virtual ~TrackPixmap();
75
	virtual ~TrackPixmap();
Lines 153-159 namespace Kwave Link Here
153
	 * @see Track::sigSamplesInserted
153
	 * @see Track::sigSamplesInserted
154
	 * @internal
154
	 * @internal
155
	 */
155
	 */
156
	void slotSamplesInserted(Track *src, sample_index_t offset,
156
	void slotSamplesInserted(Kwave::Track *src, sample_index_t offset,
157
				sample_index_t length);
157
				sample_index_t length);
158
158
159
	/**
159
	/**
Lines 164-170 namespace Kwave Link Here
164
	 * @see Track::sigSamplesDeleted
164
	 * @see Track::sigSamplesDeleted
165
	 * @internal
165
	 * @internal
166
	 */
166
	 */
167
	void slotSamplesDeleted(Track *src, sample_index_t offset,
167
	void slotSamplesDeleted(Kwave::Track *src, sample_index_t offset,
168
				sample_index_t length);
168
				sample_index_t length);
169
169
170
	/**
170
	/**
Lines 175-181 namespace Kwave Link Here
175
	 * @see Track::sigSamplesModified
175
	 * @see Track::sigSamplesModified
176
	 * @internal
176
	 * @internal
177
	 */
177
	 */
178
	void slotSamplesModified(Track *src, sample_index_t offset,
178
	void slotSamplesModified(Kwave::Track *src, sample_index_t offset,
179
				sample_index_t length);
179
				sample_index_t length);
180
180
181
	/**
181
	/**
Lines 311-317 namespace Kwave Link Here
311
	/**
311
	/**
312
	 * Reference to the track with our sample data.
312
	 * Reference to the track with our sample data.
313
	 */
313
	 */
314
	Track &m_track;
314
	Kwave::Track &m_track;
315
315
316
	/**
316
	/**
317
	 * Index of the first sample. Needed for converting pixel
317
	 * Index of the first sample. Needed for converting pixel
(-)a/libgui/TrackView.cpp (-1 / +2 lines)
Lines 29-34 Link Here
29
#include "libkwave/Label.h"
29
#include "libkwave/Label.h"
30
#include "libkwave/LabelList.h"
30
#include "libkwave/LabelList.h"
31
#include "libkwave/SignalManager.h"
31
#include "libkwave/SignalManager.h"
32
#include "libkwave/Track.h"
32
33
33
#include "LabelItem.h"
34
#include "LabelItem.h"
34
#include "MultiStateWidget.h"
35
#include "MultiStateWidget.h"
Lines 41-47 Link Here
41
//***************************************************************************
42
//***************************************************************************
42
Kwave::TrackView::TrackView(QWidget *parent, QWidget *controls,
43
Kwave::TrackView::TrackView(QWidget *parent, QWidget *controls,
43
                            SignalManager *signal_manager,
44
                            SignalManager *signal_manager,
44
                            Track *track)
45
                            Kwave::Track *track)
45
    :Kwave::SignalView(parent, controls, signal_manager,
46
    :Kwave::SignalView(parent, controls, signal_manager,
46
                       Kwave::SignalView::AboveTrackTop),
47
                       Kwave::SignalView::AboveTrackTop),
47
     m_signal_manager(signal_manager),
48
     m_signal_manager(signal_manager),
(-)a/libgui/TrackView.h (-2 / +3 lines)
Lines 29-35 Link Here
29
#include "kdemacros.h"
29
#include "kdemacros.h"
30
30
31
#include "libkwave/Sample.h"
31
#include "libkwave/Sample.h"
32
#include "libkwave/Track.h"
33
32
34
#include "libgui/SignalView.h"
33
#include "libgui/SignalView.h"
35
#include "libgui/TrackPixmap.h"
34
#include "libgui/TrackPixmap.h"
Lines 40-45 class SignalManager; // forward declaration Link Here
40
39
41
namespace Kwave {
40
namespace Kwave {
42
41
42
    class Track;
43
43
    class KDE_EXPORT TrackView: public SignalView
44
    class KDE_EXPORT TrackView: public SignalView
44
    {
45
    {
45
	Q_OBJECT
46
	Q_OBJECT
Lines 53-59 namespace Kwave { Link Here
53
	 */
54
	 */
54
	TrackView(QWidget *parent, QWidget *controls,
55
	TrackView(QWidget *parent, QWidget *controls,
55
	          SignalManager *signal_manager,
56
	          SignalManager *signal_manager,
56
	          Track *track);
57
	          Kwave::Track *track);
57
58
58
	/** Destructor */
59
	/** Destructor */
59
	virtual ~TrackView();
60
	virtual ~TrackView();
(-)a/libkwave/ClipBoard.h (-1 lines)
Lines 30-36 Link Here
30
30
31
class QWidget;
31
class QWidget;
32
class SignalManager;
32
class SignalManager;
33
class Track;
34
33
35
/**
34
/**
36
 * Implements a global clipboard for Kwave. It supports only the three
35
 * Implements a global clipboard for Kwave. It supports only the three
(-)a/libkwave/KwavePlugin.cpp (-1 lines)
Lines 37-43 Link Here
37
#include "libkwave/Sample.h"
37
#include "libkwave/Sample.h"
38
#include "libkwave/SampleReader.h"
38
#include "libkwave/SampleReader.h"
39
#include "libkwave/Signal.h"
39
#include "libkwave/Signal.h"
40
#include "libkwave/Track.h"
41
#include "libkwave/PluginContext.h"
40
#include "libkwave/PluginContext.h"
42
#include "libkwave/PluginManager.h"
41
#include "libkwave/PluginManager.h"
43
#include "libkwave/PluginWorkerThread.h"
42
#include "libkwave/PluginWorkerThread.h"
(-)a/libkwave/SampleReader.cpp (-1 lines)
Lines 23-29 Link Here
23
#include "libkwave/Sample.h"
23
#include "libkwave/Sample.h"
24
#include "libkwave/SampleReader.h"
24
#include "libkwave/SampleReader.h"
25
#include "libkwave/Stripe.h"
25
#include "libkwave/Stripe.h"
26
#include "libkwave/Track.h"
27
26
28
// define this for using only slow Qt array functions
27
// define this for using only slow Qt array functions
29
// #define STRICTLY_QT
28
// #define STRICTLY_QT
(-)a/libkwave/Signal.cpp (-21 / +21 lines)
Lines 70-82 void Signal::close() Link Here
70
}
70
}
71
71
72
//***************************************************************************
72
//***************************************************************************
73
Track *Signal::insertTrack(unsigned int index, sample_index_t length)
73
Kwave::Track *Signal::insertTrack(unsigned int index, sample_index_t length)
74
{
74
{
75
    Track *t = 0;
75
    Kwave::Track *t = 0;
76
    {
76
    {
77
	QWriteLocker lock(&m_lock_tracks);
77
	QWriteLocker lock(&m_lock_tracks);
78
78
79
	t = new Track(length);
79
	t = new Kwave::Track(length);
80
	Q_ASSERT(t);
80
	Q_ASSERT(t);
81
	if (!t) return 0;
81
	if (!t) return 0;
82
82
Lines 88-104 Track *Signal::insertTrack(unsigned int index, sample_index_t length) Link Here
88
	m_tracks.insert(index, t);
88
	m_tracks.insert(index, t);
89
89
90
	// connect to the new track's signals
90
	// connect to the new track's signals
91
	connect(t, SIGNAL(sigSamplesDeleted(Track *, sample_index_t,
91
	connect(t, SIGNAL(sigSamplesDeleted(Kwave::Track *, sample_index_t,
92
	    sample_index_t)),
92
	    sample_index_t)),
93
	    this, SLOT(slotSamplesDeleted(Track *, sample_index_t,
93
	    this, SLOT(slotSamplesDeleted(Kwave::Track *, sample_index_t,
94
	    sample_index_t)));
94
	    sample_index_t)));
95
	connect(t, SIGNAL(sigSamplesInserted(Track *, sample_index_t,
95
	connect(t, SIGNAL(sigSamplesInserted(Kwave::Track *, sample_index_t,
96
	    sample_index_t)),
96
	    sample_index_t)),
97
	    this, SLOT(slotSamplesInserted(Track *, sample_index_t,
97
	    this, SLOT(slotSamplesInserted(Kwave::Track *, sample_index_t,
98
	    sample_index_t)));
98
	    sample_index_t)));
99
	connect(t, SIGNAL(sigSamplesModified(Track *, sample_index_t,
99
	connect(t, SIGNAL(sigSamplesModified(Kwave::Track *, sample_index_t,
100
	    sample_index_t)),
100
	    sample_index_t)),
101
	    this, SLOT(slotSamplesModified(Track *, sample_index_t,
101
	    this, SLOT(slotSamplesModified(Kwave::Track *, sample_index_t,
102
	    sample_index_t)));
102
	    sample_index_t)));
103
    }
103
    }
104
104
Lines 109-115 Track *Signal::insertTrack(unsigned int index, sample_index_t length) Link Here
109
109
110
110
111
//***************************************************************************
111
//***************************************************************************
112
Track *Signal::appendTrack(sample_index_t length)
112
Kwave::Track *Signal::appendTrack(sample_index_t length)
113
{
113
{
114
    return insertTrack(tracks(), length);
114
    return insertTrack(tracks(), length);
115
}
115
}
Lines 118-124 Track *Signal::appendTrack(sample_index_t length) Link Here
118
void Signal::deleteTrack(unsigned int index)
118
void Signal::deleteTrack(unsigned int index)
119
{
119
{
120
    // remove the track from the list but do not delete it
120
    // remove the track from the list but do not delete it
121
    Track *t = 0;
121
    Kwave::Track *t = 0;
122
    {
122
    {
123
	QWriteLocker lock(&m_lock_tracks);
123
	QWriteLocker lock(&m_lock_tracks);
124
	if (static_cast<int>(index) > m_tracks.count())
124
	if (static_cast<int>(index) > m_tracks.count())
Lines 149-155 Kwave::Writer *Signal::openWriter(unsigned int track, Link Here
149
	return 0; // track does not exist !
149
	return 0; // track does not exist !
150
    }
150
    }
151
151
152
    Track *t = m_tracks.at(track);
152
    Kwave::Track *t = m_tracks.at(track);
153
    Q_ASSERT(t);
153
    Q_ASSERT(t);
154
    return (t) ? t->openWriter(mode, left, right) : 0;
154
    return (t) ? t->openWriter(mode, left, right) : 0;
155
}
155
}
Lines 163-169 SampleReader *Signal::openSampleReader(Kwave::ReaderMode mode, Link Here
163
    if (static_cast<int>(track) >= m_tracks.count())
163
    if (static_cast<int>(track) >= m_tracks.count())
164
	return 0; // track does not exist !
164
	return 0; // track does not exist !
165
165
166
    Track *t = m_tracks.at(track);
166
    Kwave::Track *t = m_tracks.at(track);
167
    Q_ASSERT(t);
167
    Q_ASSERT(t);
168
    return (t) ? t->openSampleReader(mode, left, right) : 0;
168
    return (t) ? t->openSampleReader(mode, left, right) : 0;
169
}
169
}
Lines 192-198 void Signal::deleteRange(unsigned int track, sample_index_t offset, Link Here
192
    if (static_cast<int>(track) >= m_tracks.count())
192
    if (static_cast<int>(track) >= m_tracks.count())
193
	return; // track does not exist !
193
	return; // track does not exist !
194
194
195
    Track *t = m_tracks.at(track);
195
    Kwave::Track *t = m_tracks.at(track);
196
    Q_ASSERT(t);
196
    Q_ASSERT(t);
197
    if (t) t->deleteRange(offset, length);
197
    if (t) t->deleteRange(offset, length);
198
}
198
}
Lines 207-213 void Signal::insertSpace(unsigned int track, sample_index_t offset, Link Here
207
    if (static_cast<int>(track) >= m_tracks.count())
207
    if (static_cast<int>(track) >= m_tracks.count())
208
	return; // track does not exist !
208
	return; // track does not exist !
209
209
210
    Track *t = m_tracks.at(track);
210
    Kwave::Track *t = m_tracks.at(track);
211
    Q_ASSERT(t);
211
    Q_ASSERT(t);
212
    if (t) t->insertSpace(offset, length);
212
    if (t) t->insertSpace(offset, length);
213
}
213
}
Lines 225-231 sample_index_t Signal::length() Link Here
225
    QReadLocker lock(&m_lock_tracks);
225
    QReadLocker lock(&m_lock_tracks);
226
226
227
    sample_index_t max = 0;
227
    sample_index_t max = 0;
228
    foreach (Track *track, m_tracks) {
228
    foreach (Kwave::Track *track, m_tracks) {
229
	if (!track) continue;
229
	if (!track) continue;
230
	sample_index_t len = track->length();
230
	sample_index_t len = track->length();
231
	if (len > max) max = len;
231
	if (len > max) max = len;
Lines 516-531 void Signal::selectTrack(unsigned int track, bool select) Link Here
516
//    }
516
//    }
517
517
518
//***************************************************************************
518
//***************************************************************************
519
unsigned int Signal::trackIndex(const Track *track)
519
unsigned int Signal::trackIndex(const Kwave::Track *track)
520
{
520
{
521
    QReadLocker lock(&m_lock_tracks);
521
    QReadLocker lock(&m_lock_tracks);
522
522
523
    int index = m_tracks.indexOf(const_cast<Track *>(track));
523
    int index = m_tracks.indexOf(const_cast<Kwave::Track *>(track));
524
    return (index >= 0) ? index : m_tracks.count();
524
    return (index >= 0) ? index : m_tracks.count();
525
}
525
}
526
526
527
//***************************************************************************
527
//***************************************************************************
528
void Signal::slotSamplesInserted(Track *src, sample_index_t offset,
528
void Signal::slotSamplesInserted(Kwave::Track *src, sample_index_t offset,
529
                                 sample_index_t length)
529
                                 sample_index_t length)
530
{
530
{
531
    unsigned int track = trackIndex(src);
531
    unsigned int track = trackIndex(src);
Lines 533-539 void Signal::slotSamplesInserted(Track *src, sample_index_t offset, Link Here
533
}
533
}
534
534
535
//***************************************************************************
535
//***************************************************************************
536
void Signal::slotSamplesDeleted(Track *src, sample_index_t offset,
536
void Signal::slotSamplesDeleted(Kwave::Track *src, sample_index_t offset,
537
                                sample_index_t length)
537
                                sample_index_t length)
538
{
538
{
539
    unsigned int track = trackIndex(src);
539
    unsigned int track = trackIndex(src);
Lines 541-547 void Signal::slotSamplesDeleted(Track *src, sample_index_t offset, Link Here
541
}
541
}
542
542
543
//***************************************************************************
543
//***************************************************************************
544
void Signal::slotSamplesModified(Track *src, sample_index_t offset,
544
void Signal::slotSamplesModified(Kwave::Track *src, sample_index_t offset,
545
                                 sample_index_t length)
545
                                 sample_index_t length)
546
{
546
{
547
    unsigned int track = trackIndex(src);
547
    unsigned int track = trackIndex(src);
(-)a/libkwave/Signal.h (-9 / +9 lines)
Lines 35-41 Link Here
35
35
36
class MultiTrackReader;
36
class MultiTrackReader;
37
class SampleReader;
37
class SampleReader;
38
class Track;
38
namespace Kwave { class Track; }
39
namespace Kwave { class Writer; }
39
namespace Kwave { class Writer; }
40
40
41
//**********************************************************************
41
//**********************************************************************
Lines 78-91 public: Link Here
78
     * @return pointer to the created track. If the length is
78
     * @return pointer to the created track. If the length is
79
     *         omitted or zero, the track will have zero length.
79
     *         omitted or zero, the track will have zero length.
80
     */
80
     */
81
    Track *insertTrack(unsigned int index, sample_index_t length = 0);
81
    Kwave::Track *insertTrack(unsigned int index, sample_index_t length = 0);
82
82
83
    /**
83
    /**
84
     * Appends a new track to the end of the tracks list, shortcut for
84
     * Appends a new track to the end of the tracks list, shortcut for
85
     * insertTrack(tracks()-1, length)
85
     * insertTrack(tracks()-1, length)
86
     * @see insertTrack
86
     * @see insertTrack
87
     */
87
     */
88
    Track *appendTrack(sample_index_t length);
88
    Kwave::Track *appendTrack(sample_index_t length);
89
89
90
    /**
90
    /**
91
     * Deletes a track.
91
     * Deletes a track.
Lines 175-181 signals: Link Here
175
     * @param index position of the new track [0...tracks()-1]
175
     * @param index position of the new track [0...tracks()-1]
176
     * @param track reference to the new track
176
     * @param track reference to the new track
177
     */
177
     */
178
    void sigTrackInserted(unsigned int index, Track *track);
178
    void sigTrackInserted(unsigned int index, Kwave::Track *track);
179
179
180
    /**
180
    /**
181
     * Signals that a track has been deleted.
181
     * Signals that a track has been deleted.
Lines 223-229 private slots: Link Here
223
     * @see Track::sigSamplesInserted
223
     * @see Track::sigSamplesInserted
224
     * @internal
224
     * @internal
225
     */
225
     */
226
    void slotSamplesInserted(Track *src, sample_index_t offset,
226
    void slotSamplesInserted(Kwave::Track *src, sample_index_t offset,
227
                             sample_index_t length);
227
                             sample_index_t length);
228
228
229
    /**
229
    /**
Lines 234-240 private slots: Link Here
234
     * @see Track::sigSamplesDeleted
234
     * @see Track::sigSamplesDeleted
235
     * @internal
235
     * @internal
236
     */
236
     */
237
    void slotSamplesDeleted(Track *src, sample_index_t offset,
237
    void slotSamplesDeleted(Kwave::Track *src, sample_index_t offset,
238
                            sample_index_t length);
238
                            sample_index_t length);
239
239
240
    /**
240
    /**
Lines 245-251 private slots: Link Here
245
     * @see Track::sigSamplesModified
245
     * @see Track::sigSamplesModified
246
     * @internal
246
     * @internal
247
     */
247
     */
248
    void slotSamplesModified(Track *src, sample_index_t offset,
248
    void slotSamplesModified(Kwave::Track *src, sample_index_t offset,
249
                             sample_index_t length);
249
                             sample_index_t length);
250
250
251
private:
251
private:
Lines 255-261 private: Link Here
255
     * @param track reference to the trac to be looked up
255
     * @param track reference to the trac to be looked up
256
     * @returns index of the track [0...tracks()-1] or tracks() if not found
256
     * @returns index of the track [0...tracks()-1] or tracks() if not found
257
     */
257
     */
258
    unsigned int trackIndex(const Track *track);
258
    unsigned int trackIndex(const Kwave::Track *track);
259
259
260
//    //signal modifying functions
260
//    //signal modifying functions
261
//    void replaceStutter (int, int);
261
//    void replaceStutter (int, int);
Lines 269-275 private: Link Here
269
//    void averageFFT (int points, window_function_t windowtype);
269
//    void averageFFT (int points, window_function_t windowtype);
270
270
271
    /** list of tracks */
271
    /** list of tracks */
272
    QList<Track *> m_tracks;
272
    QList<Kwave::Track *> m_tracks;
273
273
274
    /** mutex for access to the track list */
274
    /** mutex for access to the track list */
275
    QReadWriteLock m_lock_tracks;
275
    QReadWriteLock m_lock_tracks;
(-)a/libkwave/SignalManager.cpp (-4 / +4 lines)
Lines 92-99 SignalManager::SignalManager(QWidget *parent) Link Here
92
{
92
{
93
    // connect to the track's signals
93
    // connect to the track's signals
94
    Signal *sig = &m_signal;
94
    Signal *sig = &m_signal;
95
    connect(sig, SIGNAL(sigTrackInserted(unsigned int, Track *)),
95
    connect(sig, SIGNAL(sigTrackInserted(unsigned int, Kwave::Track *)),
96
            this, SLOT(slotTrackInserted(unsigned int, Track *)));
96
            this, SLOT(slotTrackInserted(unsigned int, Kwave::Track *)));
97
    connect(sig, SIGNAL(sigTrackDeleted(unsigned int)),
97
    connect(sig, SIGNAL(sigTrackDeleted(unsigned int)),
98
            this, SLOT(slotTrackDeleted(unsigned int)));
98
            this, SLOT(slotTrackDeleted(unsigned int)));
99
    connect(sig, SIGNAL(sigSamplesDeleted(unsigned int, sample_index_t,
99
    connect(sig, SIGNAL(sigSamplesDeleted(unsigned int, sample_index_t,
Lines 169-175 int SignalManager::loadFile(const KUrl &url) Link Here
169
	if (!tracks) break;
169
	if (!tracks) break;
170
170
171
	for (track = 0; track < tracks; ++track) {
171
	for (track = 0; track < tracks; ++track) {
172
	    Track *t = m_signal.appendTrack(length);
172
	    Kwave::Track *t = m_signal.appendTrack(length);
173
	    Q_ASSERT(t);
173
	    Q_ASSERT(t);
174
	    if (!t || (t->length() != length)) {
174
	    if (!t || (t->length() != length)) {
175
		qWarning("out of memory");
175
		qWarning("out of memory");
Lines 927-933 void SignalManager::deleteTrack(unsigned int index) Link Here
927
927
928
//***************************************************************************
928
//***************************************************************************
929
void SignalManager::slotTrackInserted(unsigned int index,
929
void SignalManager::slotTrackInserted(unsigned int index,
930
	Track *track)
930
                                      Kwave::Track *track)
931
{
931
{
932
    setModified(true);
932
    setModified(true);
933
933
(-)a/libkwave/SignalManager.h (-3 / +3 lines)
Lines 46-56 class KUrl; Link Here
46
class MultiTrackReader;
46
class MultiTrackReader;
47
class SampleReader;
47
class SampleReader;
48
class SignalWidget;
48
class SignalWidget;
49
class Track;
50
class UndoAction;
49
class UndoAction;
51
class UndoTransaction;
50
class UndoTransaction;
52
class UndoTransactionGuard;
51
class UndoTransactionGuard;
53
namespace Kwave { class MultiTrackWriter; }
52
namespace Kwave { class MultiTrackWriter; }
53
namespace Kwave { class Track; }
54
namespace Kwave { class Writer; }
54
namespace Kwave { class Writer; }
55
55
56
#define NEW_FILENAME i18n("New File")
56
#define NEW_FILENAME i18n("New File")
Lines 369-375 signals: Link Here
369
     * @param index position of the new track [0...tracks()-1]
369
     * @param index position of the new track [0...tracks()-1]
370
     * @param track reference to the new track
370
     * @param track reference to the new track
371
     */
371
     */
372
    void sigTrackInserted(unsigned int index, Track *track);
372
    void sigTrackInserted(unsigned int index, Kwave::Track *track);
373
373
374
    /**
374
    /**
375
     * Signals that a track has been deleted.
375
     * Signals that a track has been deleted.
Lines 448-454 private slots: Link Here
448
     * @see Signal::sigTrackInserted
448
     * @see Signal::sigTrackInserted
449
     * @internal
449
     * @internal
450
     */
450
     */
451
    void slotTrackInserted(unsigned int index, Track *track);
451
    void slotTrackInserted(unsigned int index, Kwave::Track *track);
452
452
453
    /**
453
    /**
454
     * Connected to the signal's sigTrackInserted.
454
     * Connected to the signal's sigTrackInserted.
(-)a/libkwave/StreamWriter.h (-2 / +1 lines)
Lines 27-37 Link Here
27
27
28
#include "libkwave/Writer.h"
28
#include "libkwave/Writer.h"
29
29
30
class Track;
31
32
namespace Kwave {
30
namespace Kwave {
33
31
34
    class SampleArray;
32
    class SampleArray;
33
    class Track;
35
34
36
    /**
35
    /**
37
     * @class StreamWriter
36
     * @class StreamWriter
(-)a/libkwave/Track.cpp (-40 / +40 lines)
Lines 52-64 Link Here
52
#define STRIPE_LENGTH_MINIMUM (STRIPE_LENGTH_OPTIMAL / 2)
52
#define STRIPE_LENGTH_MINIMUM (STRIPE_LENGTH_OPTIMAL / 2)
53
53
54
//***************************************************************************
54
//***************************************************************************
55
Track::Track()
55
Kwave::Track::Track()
56
    :m_lock(), m_lock_usage(), m_stripes(), m_selected(true)
56
    :m_lock(), m_lock_usage(), m_stripes(), m_selected(true)
57
{
57
{
58
}
58
}
59
59
60
//***************************************************************************
60
//***************************************************************************
61
Track::Track(sample_index_t length)
61
Kwave::Track::Track(sample_index_t length)
62
    :m_lock(), m_lock_usage(), m_stripes(), m_selected(true)
62
    :m_lock(), m_lock_usage(), m_stripes(), m_selected(true)
63
{
63
{
64
    if (length < 2*STRIPE_LENGTH_OPTIMAL) {
64
    if (length < 2*STRIPE_LENGTH_OPTIMAL) {
Lines 71-77 Track::Track(sample_index_t length) Link Here
71
}
71
}
72
72
73
//***************************************************************************
73
//***************************************************************************
74
Track::~Track()
74
Kwave::Track::~Track()
75
{
75
{
76
    // wait until all readers are finished
76
    // wait until all readers are finished
77
    QWriteLocker lock_usage(&m_lock_usage);
77
    QWriteLocker lock_usage(&m_lock_usage);
Lines 84-90 Track::~Track() Link Here
84
}
84
}
85
85
86
//***************************************************************************
86
//***************************************************************************
87
void Track::appendStripe(sample_index_t length)
87
void Kwave::Track::appendStripe(sample_index_t length)
88
{
88
{
89
//     SharedLockGuard lock(m_lock, true);
89
//     SharedLockGuard lock(m_lock, true);
90
    sample_index_t start = unlockedLength();
90
    sample_index_t start = unlockedLength();
Lines 107-113 void Track::appendStripe(sample_index_t length) Link Here
107
}
107
}
108
108
109
//***************************************************************************
109
//***************************************************************************
110
Stripe Track::splitStripe(Stripe &stripe, unsigned int offset)
110
Stripe Kwave::Track::splitStripe(Stripe &stripe, unsigned int offset)
111
{
111
{
112
    Q_ASSERT(offset < stripe.length());
112
    Q_ASSERT(offset < stripe.length());
113
    Q_ASSERT(offset);
113
    Q_ASSERT(offset);
Lines 121-141 Stripe Track::splitStripe(Stripe &stripe, unsigned int offset) Link Here
121
    // shrink the old stripe
121
    // shrink the old stripe
122
    stripe.resize(offset);
122
    stripe.resize(offset);
123
123
124
//     qDebug("Track::splitStripe(%p, %u): new stripe at [%u ... %u] (%u)",
124
//     qDebug("Kwave::Track::splitStripe(%p, %u): new stripe at [%u ... %u] (%u)",
125
//            stripe, offset, s->start(), s->end(), s->length());
125
//            stripe, offset, s->start(), s->end(), s->length());
126
126
127
    return s;
127
    return s;
128
}
128
}
129
129
130
//***************************************************************************
130
//***************************************************************************
131
sample_index_t Track::length()
131
sample_index_t Kwave::Track::length()
132
{
132
{
133
    QReadLocker lock(&m_lock);
133
    QReadLocker lock(&m_lock);
134
    return unlockedLength();
134
    return unlockedLength();
135
}
135
}
136
136
137
//***************************************************************************
137
//***************************************************************************
138
sample_index_t Track::unlockedLength()
138
sample_index_t Kwave::Track::unlockedLength()
139
{
139
{
140
    if (m_stripes.isEmpty()) return 0;
140
    if (m_stripes.isEmpty()) return 0;
141
    const Stripe &s = m_stripes.last();
141
    const Stripe &s = m_stripes.last();
Lines 143-149 sample_index_t Track::unlockedLength() Link Here
143
}
143
}
144
144
145
//***************************************************************************
145
//***************************************************************************
146
Kwave::Writer *Track::openWriter(InsertMode mode,
146
Kwave::Writer *Kwave::Track::openWriter(InsertMode mode,
147
	sample_index_t left, sample_index_t right)
147
	sample_index_t left, sample_index_t right)
148
{
148
{
149
    // create the input stream
149
    // create the input stream
Lines 154-160 Kwave::Writer *Track::openWriter(InsertMode mode, Link Here
154
}
154
}
155
155
156
//***************************************************************************
156
//***************************************************************************
157
SampleReader *Track::openSampleReader(Kwave::ReaderMode mode,
157
SampleReader *Kwave::Track::openSampleReader(Kwave::ReaderMode mode,
158
	sample_index_t left, sample_index_t right)
158
	sample_index_t left, sample_index_t right)
159
{
159
{
160
    QReadLocker lock(&m_lock);
160
    QReadLocker lock(&m_lock);
Lines 182-193 SampleReader *Track::openSampleReader(Kwave::ReaderMode mode, Link Here
182
}
182
}
183
183
184
//***************************************************************************
184
//***************************************************************************
185
void Track::deleteRange(sample_index_t offset, sample_index_t length,
185
void Kwave::Track::deleteRange(sample_index_t offset, sample_index_t length,
186
                        bool make_gap)
186
                               bool make_gap)
187
{
187
{
188
    if (!length) return;
188
    if (!length) return;
189
189
190
//     qDebug("Track::deleteRange() [%u ... %u] (%u)",
190
//     qDebug("Kwave::Track::deleteRange() [%u ... %u] (%u)",
191
// 	offset, offset + length - 1, length);
191
// 	offset, offset + length - 1, length);
192
192
193
    {
193
    {
Lines 199-207 void Track::deleteRange(sample_index_t offset, sample_index_t length, Link Here
199
}
199
}
200
200
201
//***************************************************************************
201
//***************************************************************************
202
bool Track::insertSpace(sample_index_t offset, sample_index_t shift)
202
bool Kwave::Track::insertSpace(sample_index_t offset, sample_index_t shift)
203
{
203
{
204
//     qDebug("Track::insertSpace(offset=%u,shift=%u)",offset, shift);
204
//     qDebug("Kwave::Track::insertSpace(offset=%u,shift=%u)",offset, shift);
205
    if (!shift) return true;
205
    if (!shift) return true;
206
206
207
    {
207
    {
Lines 219-225 bool Track::insertSpace(sample_index_t offset, sample_index_t shift) Link Here
219
		sample_index_t start  = s.start();
219
		sample_index_t start  = s.start();
220
		if (start >= offset) break; // not "within" the stripe
220
		if (start >= offset) break; // not "within" the stripe
221
221
222
// 		qDebug("Track::insertSpace => splitting [%u...%u]",start,end);
222
// 		qDebug("Kwave::Track::insertSpace => splitting [%u...%u]",start,end);
223
		Stripe new_stripe = splitStripe(s, offset - start);
223
		Stripe new_stripe = splitStripe(s, offset - start);
224
		if (!new_stripe.length()) return false; // OOM ?
224
		if (!new_stripe.length()) return false; // OOM ?
225
		it.insert(new_stripe);
225
		it.insert(new_stripe);
Lines 227-236 bool Track::insertSpace(sample_index_t offset, sample_index_t shift) Link Here
227
	    }
227
	    }
228
228
229
	    // move all stripes that are after the offset right
229
	    // move all stripes that are after the offset right
230
// 	    qDebug("Track::insertSpace => moving right");
230
// 	    qDebug("Kwave::Track::insertSpace => moving right");
231
	    moveRight(offset, shift);
231
	    moveRight(offset, shift);
232
	} else {
232
	} else {
233
// 	    qDebug("Track::insertSpace => appending stripe at %u", offset + shift - 1);
233
// 	    qDebug("Kwave::Track::insertSpace => appending stripe at %u", offset + shift - 1);
234
	    Stripe s(offset + shift - 1);
234
	    Stripe s(offset + shift - 1);
235
	    s.resize(1);
235
	    s.resize(1);
236
	    if (s.length()) m_stripes.append(s);
236
	    if (s.length()) m_stripes.append(s);
Lines 243-250 bool Track::insertSpace(sample_index_t offset, sample_index_t shift) Link Here
243
}
243
}
244
244
245
//***************************************************************************
245
//***************************************************************************
246
void Track::unlockedDelete(sample_index_t offset, sample_index_t length,
246
void Kwave::Track::unlockedDelete(sample_index_t offset, sample_index_t length,
247
                           bool make_gap)
247
                                  bool make_gap)
248
{
248
{
249
    if (!length) return;
249
    if (!length) return;
250
250
Lines 343-349 void Track::unlockedDelete(sample_index_t offset, sample_index_t length, Link Here
343
}
343
}
344
344
345
//***************************************************************************
345
//***************************************************************************
346
void Track::select(bool selected)
346
void Kwave::Track::select(bool selected)
347
{
347
{
348
    if (m_selected == selected) return;
348
    if (m_selected == selected) return;
349
    m_selected = selected;
349
    m_selected = selected;
Lines 351-365 void Track::select(bool selected) Link Here
351
}
351
}
352
352
353
//***************************************************************************
353
//***************************************************************************
354
void Track::toggleSelection()
354
void Kwave::Track::toggleSelection()
355
{
355
{
356
    select(!selected());
356
    select(!selected());
357
}
357
}
358
358
359
//***************************************************************************
359
//***************************************************************************
360
bool Track::appendAfter(Stripe *stripe,  sample_index_t offset,
360
bool Kwave::Track::appendAfter(Stripe *stripe,  sample_index_t offset,
361
                        const Kwave::SampleArray &buffer,
361
                               const Kwave::SampleArray &buffer,
362
                        unsigned int buf_offset, unsigned int length)
362
                               unsigned int buf_offset, unsigned int length)
363
{
363
{
364
    Q_ASSERT(buf_offset + length <= buffer.size());
364
    Q_ASSERT(buf_offset + length <= buffer.size());
365
    if (buf_offset + length > buffer.size()) return false;
365
    if (buf_offset + length > buffer.size()) return false;
Lines 373-379 bool Track::appendAfter(Stripe *stripe, sample_index_t offset, Link Here
373
	if (len + stripe->length() > STRIPE_LENGTH_MAXIMUM)
373
	if (len + stripe->length() > STRIPE_LENGTH_MAXIMUM)
374
	    len = STRIPE_LENGTH_MAXIMUM - stripe->length();
374
	    len = STRIPE_LENGTH_MAXIMUM - stripe->length();
375
375
376
// 	qDebug("Track::appendAfter(): appending %u samples to %p",
376
// 	qDebug("Kwave::Track::appendAfter(): appending %u samples to %p",
377
// 	       len, stripe);
377
// 	       len, stripe);
378
	if (!stripe->append(buffer, buf_offset, len))
378
	if (!stripe->append(buffer, buf_offset, len))
379
	    return false; // out of memory
379
	    return false; // out of memory
Lines 391-403 bool Track::appendAfter(Stripe *stripe, sample_index_t offset, Link Here
391
	if (len > STRIPE_LENGTH_MAXIMUM)
391
	if (len > STRIPE_LENGTH_MAXIMUM)
392
	    len = STRIPE_LENGTH_MAXIMUM;
392
	    len = STRIPE_LENGTH_MAXIMUM;
393
393
394
// 	qDebug("Track::appendAfter: new stripe, ofs=%u, len=%u",
394
// 	qDebug("Kwave::Track::appendAfter: new stripe, ofs=%u, len=%u",
395
// 	       offset, len);
395
// 	       offset, len);
396
	Stripe new_stripe(offset);
396
	Stripe new_stripe(offset);
397
397
398
	// append to the new stripe
398
	// append to the new stripe
399
	if (!new_stripe.append(buffer, buf_offset, len)) {
399
	if (!new_stripe.append(buffer, buf_offset, len)) {
400
	    qWarning("Track::appendAfter FAILED / OOM");
400
	    qWarning("Kwave::Track::appendAfter FAILED / OOM");
401
	    return false; /* out of memory */
401
	    return false; /* out of memory */
402
	}
402
	}
403
	Q_ASSERT(new_stripe.length() == len);
403
	Q_ASSERT(new_stripe.length() == len);
Lines 408-419 bool Track::appendAfter(Stripe *stripe, sample_index_t offset, Link Here
408
	if (index_before >= 0) {
408
	if (index_before >= 0) {
409
	    // insert after the last one
409
	    // insert after the last one
410
	    index_before++;
410
	    index_before++;
411
// 	    qDebug("Track::appendAfter: insert after %p [%10u - %10u]",
411
// 	    qDebug("Kwave::Track::appendAfter: insert after %p [%10u - %10u]",
412
// 		stripe, stripe->start(), stripe->end());
412
// 		stripe, stripe->start(), stripe->end());
413
	    m_stripes.insert(index_before, new_stripe);
413
	    m_stripes.insert(index_before, new_stripe);
414
	} else {
414
	} else {
415
	    // the one and only or insert before all others
415
	    // the one and only or insert before all others
416
// 	    qDebug("Track::appendAfter: prepending");
416
// 	    qDebug("Kwave::Track::appendAfter: prepending");
417
	    m_stripes.prepend(new_stripe);
417
	    m_stripes.prepend(new_stripe);
418
	    index_before = 0;
418
	    index_before = 0;
419
	}
419
	}
Lines 426-432 bool Track::appendAfter(Stripe *stripe, sample_index_t offset, Link Here
426
}
426
}
427
427
428
//***************************************************************************
428
//***************************************************************************
429
void Track::moveRight(sample_index_t offset, sample_index_t shift)
429
void Kwave::Track::moveRight(sample_index_t offset, sample_index_t shift)
430
{
430
{
431
    if (m_stripes.isEmpty()) return;
431
    if (m_stripes.isEmpty()) return;
432
    QMutableListIterator<Stripe> it(m_stripes);
432
    QMutableListIterator<Stripe> it(m_stripes);
Lines 441-451 void Track::moveRight(sample_index_t offset, sample_index_t shift) Link Here
441
}
441
}
442
442
443
//***************************************************************************
443
//***************************************************************************
444
bool Track::writeSamples(InsertMode mode,
444
bool Kwave::Track::writeSamples(InsertMode mode,
445
                         sample_index_t offset,
445
                                sample_index_t offset,
446
                         const Kwave::SampleArray &buffer,
446
                                const Kwave::SampleArray &buffer,
447
                         unsigned int buf_offset,
447
                                unsigned int buf_offset,
448
                         unsigned int length)
448
                                unsigned int length)
449
{
449
{
450
    Q_ASSERT(length);
450
    Q_ASSERT(length);
451
    if (!length) return true; // nothing to do !?
451
    if (!length) return true; // nothing to do !?
Lines 470-476 bool Track::writeSamples(InsertMode mode, Link Here
470
	case Insert: {
470
	case Insert: {
471
	    m_lock.lockForWrite();
471
	    m_lock.lockForWrite();
472
472
473
// 	    qDebug("Track::writeSamples() - Insert @ %u, length=%u",
473
// 	    qDebug("Kwave::Track::writeSamples() - Insert @ %u, length=%u",
474
// 		   offset, length);
474
// 		   offset, length);
475
475
476
	    // find the stripe into which we insert
476
	    // find the stripe into which we insert
Lines 577-595 bool Track::writeSamples(InsertMode mode, Link Here
577
}
577
}
578
578
579
//***************************************************************************
579
//***************************************************************************
580
void Track::use()
580
void Kwave::Track::use()
581
{
581
{
582
    m_lock_usage.lockForRead();
582
    m_lock_usage.lockForRead();
583
}
583
}
584
584
585
//***************************************************************************
585
//***************************************************************************
586
void Track::release()
586
void Kwave::Track::release()
587
{
587
{
588
    m_lock_usage.unlock();
588
    m_lock_usage.unlock();
589
}
589
}
590
590
591
//***************************************************************************
591
//***************************************************************************
592
void Track::dump()
592
void Kwave::Track::dump()
593
{
593
{
594
    qDebug("------------------------------------");
594
    qDebug("------------------------------------");
595
    unsigned int index = 0;
595
    unsigned int index = 0;
(-)a/libkwave/Track.h (-242 / +247 lines)
Lines 1-5 Link Here
1
/***************************************************************************
1
/***************************************************************************
2
                Track.h  -  collects one or more stripes in one track
2
                 Track.h -  collects one or more stripes in one track
3
			     -------------------
3
			     -------------------
4
    begin                : Feb 09 2001
4
    begin                : Feb 09 2001
5
    copyright            : (C) 2001 by Thomas Eschenbacher
5
    copyright            : (C) 2001 by Thomas Eschenbacher
Lines 33-280 Link Here
33
#include "libkwave/Stripe.h"
33
#include "libkwave/Stripe.h"
34
34
35
class SampleReader;
35
class SampleReader;
36
namespace Kwave { class TrackWriter; }
37
namespace Kwave { class Writer; }
38
36
39
//***************************************************************************
37
//***************************************************************************
40
class KDE_EXPORT Track: public QObject
38
namespace Kwave {
41
{
39
42
    Q_OBJECT
40
    class TrackWriter;
43
public:
41
    class Writer;
44
    /**
42
45
     * Default constructor. Creates a new and empty track with
43
    class KDE_EXPORT Track: public QObject
46
     * zero-length and no stripes
44
    {
47
     */
45
	Q_OBJECT
48
    Track();
46
    public:
49
47
	/**
50
    /**
48
	 * Default constructor. Creates a new and empty track with
51
     * Constructor. Creates an empty track with one stripe
49
	 * zero-length and no stripes
52
     * with specified length.
50
	 */
53
     */
51
	Track();
54
    Track(sample_index_t length);
52
55
53
	/**
56
    /**
54
	 * Constructor. Creates an empty track with one stripe
57
     * Destructor.
55
	 * with specified length.
58
     */
56
	 */
59
    virtual ~Track();
57
	Track(sample_index_t length);
60
58
61
    /**
59
	/**
62
     * Returns the length of the track. This is equivalent
60
	 * Destructor.
63
     * to the position of the last sample of the last Stripe.
61
	 */
64
     */
62
	virtual ~Track();
65
    sample_index_t length();
63
66
64
	/**
67
    /**
65
	 * Returns the length of the track. This is equivalent
68
     * Opens a stream for writing samples, starting at a
66
	 * to the position of the last sample of the last Stripe.
69
     * sample position.
67
	 */
70
     * @param mode specifies where and how to insert
68
	sample_index_t length();
71
     * @param left start of the input (only useful in insert and
69
72
     *             overwrite mode)
70
	/**
73
     * @param right end of the input (only useful with overwrite mode)
71
	 * Opens a stream for writing samples, starting at a
74
     * @see InsertMode
72
	 * sample position.
75
     */
73
	 * @param mode specifies where and how to insert
76
    Kwave::Writer *openWriter(InsertMode mode,
74
	 * @param left start of the input (only useful in insert and
77
	sample_index_t left = 0, sample_index_t right = 0);
75
	 *             overwrite mode)
78
76
	 * @param right end of the input (only useful with overwrite mode)
79
    /**
77
	 * @see InsertMode
80
     * Opens a stream for reading samples. If the the last position
78
	 */
81
     * is omitted, the value UINT_MAX will be used.
79
	Kwave::Writer *openWriter(InsertMode mode,
82
     * @param mode read mode, see Kwave::ReaderMode
80
	                          sample_index_t left = 0,
83
     * @param left first offset to be read (default = 0)
81
	                          sample_index_t right = 0);
84
     * @param right last position to read (default = UINT_MAX)
82
85
     */
83
	/**
86
    SampleReader *openSampleReader(Kwave::ReaderMode mode,
84
	 * Opens a stream for reading samples. If the the last position
87
	sample_index_t left = 0,
85
	 * is omitted, the value UINT_MAX will be used.
88
	sample_index_t right = SAMPLE_INDEX_MAX);
86
	 * @param mode read mode, see Kwave::ReaderMode
89
87
	 * @param left first offset to be read (default = 0)
90
    /**
88
	 * @param right last position to read (default = UINT_MAX)
91
     * Deletes a range of samples
89
	 */
92
     * @param offset index of the first sample
90
	SampleReader *openSampleReader(Kwave::ReaderMode mode,
93
     * @param length number of samples
91
	                               sample_index_t left = 0,
94
     * @param make_gap if true, make a gap into the list of stripes
92
	                               sample_index_t right = SAMPLE_INDEX_MAX);
95
     *                 instead of moving the stuff from right to left
93
96
     */
94
	/**
97
    void deleteRange(sample_index_t offset, sample_index_t length,
95
	 * Deletes a range of samples
98
                     bool make_gap = false);
96
	 * @param offset index of the first sample
99
97
	 * @param length number of samples
100
    /**
98
	 * @param make_gap if true, make a gap into the list of stripes
101
     * Inserts space at a given offset by moving all stripes that are
99
	 *                 instead of moving the stuff from right to left
102
     * are starting at or after the given offset right.
100
	 */
103
     *
101
	void deleteRange(sample_index_t offset, sample_index_t length,
104
     * @param offset position after which everything is moved right
102
	                 bool make_gap = false);
105
     * @param shift distance of the shift [samples]
103
106
     * @return true if succeeded, false if failed (OOM?)
104
	/**
107
     */
105
	 * Inserts space at a given offset by moving all stripes that are
108
    bool insertSpace(sample_index_t offset, sample_index_t shift);
106
	 * are starting at or after the given offset right.
109
107
	 *
110
    /** Returns the "selected" flag. */
108
	 * @param offset position after which everything is moved right
111
    inline bool selected() const { return m_selected; }
109
	 * @param shift distance of the shift [samples]
112
110
	 * @return true if succeeded, false if failed (OOM?)
113
    /** Sets the "selected" flag. */
111
	 */
114
    void select(bool select);
112
	bool insertSpace(sample_index_t offset, sample_index_t shift);
115
113
116
public slots:
114
	/** Returns the "selected" flag. */
117
115
	inline bool selected() const { return m_selected; }
118
    /** toggles the selection of the slot on/off */
116
119
    void toggleSelection();
117
	/** Sets the "selected" flag. */
120
118
	void select(bool select);
121
signals:
119
122
120
    public slots:
123
    /**
121
124
     * Emitted if the track has grown. This implies a modification of
122
	/** toggles the selection of the slot on/off */
125
     * the inserted data, so no extra sigSamplesModified is emitted.
123
	void toggleSelection();
126
     * @param src source track of the signal (*this)
124
127
     * @param offset position from which the data was inserted
125
    signals:
128
     * @param length number of samples inserted
126
129
     * @see sigSamplesModified
127
	/**
130
     */
128
	 * Emitted if the track has grown. This implies a modification of
131
    void sigSamplesInserted(Track *src, sample_index_t offset,
129
	 * the inserted data, so no extra sigSamplesModified is emitted.
132
                            sample_index_t length);
130
	 * @param src source track of the signal (*this)
133
131
	 * @param offset position from which the data was inserted
134
    /**
132
	 * @param length number of samples inserted
135
     * Emitted if data has been removed from the track.
133
	 * @see sigSamplesModified
136
     * @param src source track of the signal (*this)
134
	 */
137
     * @param offset position from which the data was removed
135
	void sigSamplesInserted(Kwave::Track *src, sample_index_t offset,
138
     * @param length number of samples deleted
136
	                        sample_index_t length);
139
     */
137
140
    void sigSamplesDeleted(Track *src, sample_index_t offset,
138
	/**
141
                           sample_index_t length);
139
	 * Emitted if data has been removed from the track.
142
140
	 * @param src source track of the signal (*this)
143
    /**
141
	 * @param offset position from which the data was removed
144
     * Emitted if some data within the track has been modified.
142
	 * @param length number of samples deleted
145
     * @param src source track of the signal (*this)
143
	 */
146
     * @param offset position from which the data was modified
144
	void sigSamplesDeleted(Kwave::Track *src, sample_index_t offset,
147
     * @param length number of samples modified
145
                               sample_index_t length);
148
     */
146
149
    void sigSamplesModified(Track *src, sample_index_t offset,
147
	/**
150
                            sample_index_t length);
148
	 * Emitted if some data within the track has been modified.
151
149
	 * @param src source track of the signal (*this)
152
    /**
150
	 * @param offset position from which the data was modified
153
     * Emitted whenever the selection of the track has changed.
151
	 * @param length number of samples modified
154
     * @param selected true if selected, false if unselected
152
	 */
155
     */
153
	void sigSamplesModified(Kwave::Track *src, sample_index_t offset,
156
     void sigSelectionChanged(bool selected);
154
	                        sample_index_t length);
157
155
158
private:
156
	/**
159
    /**
157
	 * Emitted whenever the selection of the track has changed.
160
     * Returns the current length of the stripe in samples. This
158
	 * @param selected true if selected, false if unselected
161
     * function uses no locks and is therefore reserved for internal
159
	 */
162
     * usage from within locked functions.
160
	void sigSelectionChanged(bool selected);
163
     * @note this must be private, it does no locking !
161
164
     */
162
    private:
165
    sample_index_t unlockedLength();
163
	/**
166
164
	 * Returns the current length of the stripe in samples. This
167
    /**
165
	 * function uses no locks and is therefore reserved for internal
168
     * Deletes a range of samples, used internally by deleteRange()
166
	 * usage from within locked functions.
169
     * @param offset index of the first sample
167
	 * @note this must be private, it does no locking !
170
     * @param length number of samples
168
	 */
171
     * @param make_gap if true, make a gap into the list of stripes
169
	sample_index_t unlockedLength();
172
     *                 instead of moving the stuff from right to left
170
173
     */
171
	/**
174
    void unlockedDelete(sample_index_t offset, sample_index_t length,
172
	 * Deletes a range of samples, used internally by deleteRange()
175
                        bool make_gap = false);
173
	 * @param offset index of the first sample
176
174
	 * @param length number of samples
177
    /**
175
	 * @param make_gap if true, make a gap into the list of stripes
178
     * Append samples after a given stripe.
176
	 *                 instead of moving the stuff from right to left
179
     *
177
	 */
180
     * @param stripe the stripe after which to instert. Null pointer is
178
	void unlockedDelete(sample_index_t offset, sample_index_t length,
181
     *               allowed, in this case a new stripe is created
179
	                    bool make_gap = false);
182
     * @param offset position where the new data should start
180
183
     * @param buffer array with samples
181
	/**
184
     * @param buf_offset offset within the buffer
182
	 * Append samples after a given stripe.
185
     * @param length number of samples to write
183
	 *
186
     * @return true if successful, false if failed (e.g. out of memory)
184
	 * @param stripe the stripe after which to instert. Null pointer is
187
     */
185
	 *               allowed, in this case a new stripe is created
188
    bool appendAfter(Stripe *stripe, sample_index_t offset,
186
	 * @param offset position where the new data should start
189
                     const Kwave::SampleArray &buffer,
187
	 * @param buffer array with samples
190
                     unsigned int buf_offset, unsigned int length);
188
	 * @param buf_offset offset within the buffer
191
189
	 * @param length number of samples to write
192
    /**
190
	 * @return true if successful, false if failed (e.g. out of memory)
193
     * Move all stripes after an offset to the right. Only looks at the
191
	 */
194
     * start position of the stripes, comparing with ">=", if the start
192
	bool appendAfter(Stripe *stripe, sample_index_t offset,
195
     * of a stripe is at the given offset, it will not be moved!
193
	                 const Kwave::SampleArray &buffer,
196
     *
194
	                 unsigned int buf_offset, unsigned int length);
197
     * @param offset position after which everything is moved right
195
198
     * @param shift distance of the shift [samples]
196
	/**
199
     */
197
	 * Move all stripes after an offset to the right. Only looks at the
200
    void moveRight(sample_index_t offset, sample_index_t shift);
198
	 * start position of the stripes, comparing with ">=", if the start
201
199
	 * of a stripe is at the given offset, it will not be moved!
202
    /**
200
	 *
203
     * Append a new stripe with a given length.
201
	 * @param offset position after which everything is moved right
204
     *
202
	 * @param shift distance of the shift [samples]
205
     * @param length number of samples, zero is allowed
203
	 */
206
     */
204
	void moveRight(sample_index_t offset, sample_index_t shift);
207
    void appendStripe(sample_index_t length);
205
208
206
	/**
209
    /**
207
	 * Append a new stripe with a given length.
210
     * Split a stripe into two stripes. The new stripe will be created
208
	 *
211
     * from the right portion of the given stripe and the original
209
	 * @param length number of samples, zero is allowed
212
     * stripe will be shrinked to it's new size. The newly created stripe
210
	 */
213
     * will be inserted into m_stripes after the old one.
211
	void appendStripe(sample_index_t length);
214
     *
212
215
     * @param stripe the stripe to be split
213
	/**
216
     * @param offset the offset within the stripe, which becomes the first
214
	 * Split a stripe into two stripes. The new stripe will be created
217
     *               sample in the new stripe
215
	 * from the right portion of the given stripe and the original
218
     * @return the new created stripe
216
	 * stripe will be shrinked to it's new size. The newly created stripe
219
     */
217
	 * will be inserted into m_stripes after the old one.
220
    Stripe splitStripe(Stripe &stripe, unsigned int offset);
218
	 *
221
219
	 * @param stripe the stripe to be split
222
    /**
220
	 * @param offset the offset within the stripe, which becomes the first
223
     * dump the list of stripes, for debugging
221
	 *               sample in the new stripe
224
     * @internal for debugging only
222
	 * @return the new created stripe
225
     */
223
	 */
226
    void dump();
224
	Stripe splitStripe(Stripe &stripe, unsigned int offset);
227
225
228
protected:
226
	/**
229
227
	 * dump the list of stripes, for debugging
230
    friend class Kwave::TrackWriter;
228
	 * @internal for debugging only
231
229
	 */
232
    /**
230
	void dump();
233
     * Write a block of samples. If necessary it starts, appends to,
231
234
     * or splits a stripe.
232
    protected:
235
     *
233
236
     * @param mode a InsertMode (append/overwrite/insert)
234
	friend class Kwave::TrackWriter;
237
     * @param offset position where to start the write operation
235
238
     * @param buffer array with samples
236
	/**
239
     * @param buf_offset offset within the buffer
237
	 * Write a block of samples. If necessary it starts, appends to,
240
     * @param length number of samples to write
238
	 * or splits a stripe.
241
     * @return true if successful, false if failed (e.g. out of memory)
239
	 *
242
     */
240
	 * @param mode a InsertMode (append/overwrite/insert)
243
    bool writeSamples(InsertMode mode,
241
	 * @param offset position where to start the write operation
244
                      sample_index_t offset,
242
	 * @param buffer array with samples
245
                      const Kwave::SampleArray &buffer,
243
	 * @param buf_offset offset within the buffer
246
                      unsigned int buf_offset,
244
	 * @param length number of samples to write
247
                      unsigned int length);
245
	 * @return true if successful, false if failed (e.g. out of memory)
248
246
	 */
249
    /** increments the usage counter (read lock to m_lock_usage) */
247
	bool writeSamples(InsertMode mode,
250
    void use();
248
	                  sample_index_t offset,
251
249
	                  const Kwave::SampleArray &buffer,
252
    /** decrements the usage counter (read lock to m_lock_usage) */
250
	                  unsigned int buf_offset,
253
    void release();
251
	                  unsigned int length);
254
252
255
private:
253
	/** increments the usage counter (read lock to m_lock_usage) */
256
254
	void use();
257
    /**
255
258
     * Creates a new stripe with a start position and a length.
256
	/** decrements the usage counter (read lock to m_lock_usage) */
259
     * @param start offset of the first sample
257
	void release();
260
     * @param length number of samples, zero is allowed
258
261
     * @note this must be private, it does no locking !
259
    private:
262
     */
260
263
    Stripe *newStripe(sample_index_t start, unsigned int length);
261
	/**
264
262
	 * Creates a new stripe with a start position and a length.
265
private:
263
	 * @param start offset of the first sample
266
    /** read/write lock for access to the whole track */
264
	 * @param length number of samples, zero is allowed
267
    QReadWriteLock m_lock;
265
	 * @note this must be private, it does no locking !
268
266
	 */
269
    /** lock to protect against deletion while the track is in use */
267
	Stripe *newStripe(sample_index_t start, unsigned int length);
270
    QReadWriteLock m_lock_usage;
268
271
269
    private:
272
    /** list of stripes (a track actually is a container for stripes) */
270
	/** read/write lock for access to the whole track */
273
    QList<Stripe> m_stripes;
271
	QReadWriteLock m_lock;
274
272
275
    /** True if the track is selected */
273
	/** lock to protect against deletion while the track is in use */
276
    bool m_selected;
274
	QReadWriteLock m_lock_usage;
277
275
278
};
276
	/** list of stripes (a track actually is a container for stripes) */
277
	QList<Stripe> m_stripes;
278
279
	/** True if the track is selected */
280
	bool m_selected;
281
282
    };
283
}
279
284
280
#endif /* _TRACK_H_ */
285
#endif /* _TRACK_H_ */
(-)a/libkwave/TrackWriter.cpp (-1 / +1 lines)
Lines 28-34 Link Here
28
#define MIN_PROGRESS_INTERVAL 500
28
#define MIN_PROGRESS_INTERVAL 500
29
29
30
//***************************************************************************
30
//***************************************************************************
31
Kwave::TrackWriter::TrackWriter(Track &track, InsertMode mode,
31
Kwave::TrackWriter::TrackWriter(Kwave::Track &track, InsertMode mode,
32
    sample_index_t left, sample_index_t right)
32
    sample_index_t left, sample_index_t right)
33
    :Kwave::Writer(mode, left, right),
33
    :Kwave::Writer(mode, left, right),
34
     m_track(track), m_progress_time()
34
     m_track(track), m_progress_time()
(-)a/libkwave/TrackWriter.h (-4 / +3 lines)
Lines 27-37 Link Here
27
27
28
#include "libkwave/Writer.h"
28
#include "libkwave/Writer.h"
29
29
30
class Track;
31
32
namespace Kwave {
30
namespace Kwave {
33
31
34
    class SampleArray;
32
    class SampleArray;
33
    class Track;
35
34
36
    /**
35
    /**
37
     * @class TrackWriter
36
     * @class TrackWriter
Lines 54-60 namespace Kwave { Link Here
54
	 * @param right end of the input (only useful with overwrite mode)
53
	 * @param right end of the input (only useful with overwrite mode)
55
	 * @see InsertMode
54
	 * @see InsertMode
56
	 */
55
	 */
57
	TrackWriter(Track &track, InsertMode mode,
56
	TrackWriter(Kwave::Track &track, InsertMode mode,
58
	    sample_index_t left = 0, sample_index_t right = 0);
57
	    sample_index_t left = 0, sample_index_t right = 0);
59
58
60
	/**
59
	/**
Lines 78-84 namespace Kwave { Link Here
78
    private:
77
    private:
79
78
80
	/** the track that receives our data */
79
	/** the track that receives our data */
81
	Track &m_track;
80
	Kwave::Track &m_track;
82
81
83
	/** timer for limiting the number of progress signals per second */
82
	/** timer for limiting the number of progress signals per second */
84
	QTime m_progress_time;
83
	QTime m_progress_time;
(-)a/libkwave/undo/UndoDeleteTrack.h (-1 / +1 lines)
Lines 75-81 protected: Link Here
75
    sample_index_t m_length;
75
    sample_index_t m_length;
76
76
77
    /** track that serves as buffer with undo data */
77
    /** track that serves as buffer with undo data */
78
    Track m_buffer_track;
78
    Kwave::Track m_buffer_track;
79
79
80
};
80
};
81
81
(-)a/libkwave/undo/UndoModifyAction.h (-1 / +1 lines)
Lines 77-83 protected: Link Here
77
    sample_index_t m_length;
77
    sample_index_t m_length;
78
78
79
    /** track that serves as buffer with undo data */
79
    /** track that serves as buffer with undo data */
80
    Track m_buffer_track;
80
    Kwave::Track m_buffer_track;
81
81
82
};
82
};
83
83
(-)a/plugins/fileinfo/KeywordWidget.cpp (-2 / +1 lines)
Lines 113-119 void KeywordWidget::update() Link Here
113
    btAdd->setEnabled(edit.length() && !contained(edit));
113
    btAdd->setEnabled(edit.length() && !contained(edit));
114
114
115
    // "Remove" is only enabled if something out of the list has been selected
115
    // "Remove" is only enabled if something out of the list has been selected
116
    btRemove->setEnabled((lstKeywords->currentItem() >= 0) &&
116
    btRemove->setEnabled((lstKeywords->currentItem() != 0) &&
117
                         (contained(edit) || !edit.length()));
117
                         (contained(edit) || !edit.length()));
118
118
119
    // the list is only enabled if it is not empty
119
    // the list is only enabled if it is not empty
120
- 

Return to bug 412007