annotate edwaveform.h @ 400:f44a89a25c97

Fix waveform display from going over buffer limit.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 19 Oct 2012 15:56:59 +0300
parents 5137db55f00b
children d34922e6a244
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 #ifndef EDWAVEFORM_H
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 #define EDWAVEFORM_H
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 #include <QWidget>
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
5 #include <QLabel>
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 #include "dmengine.h"
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
8 class QWaveTrackDisplay : public QWidget
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 Q_OBJECT
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 public:
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
13 QWaveTrackDisplay(QWidget *parent = 0);
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
15 void setWaveform(void *mdata, int msize, int mformat, int mchannels, int mfreq);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
16 float getScaledWidth();
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 void setScale(const float mscale);
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
18 int getBps();
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
19 float getDuration();
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
20 float getTimeScale(float value);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
21 float getTimeFromCoord(float value);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
22 float getTime();
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
23 float getOffset();
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
24
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
25 QSize minimumSizeHint() const
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
26 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
27 return QSize(100, 60);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
28 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
29
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
30 QSize sizeHint() const
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
31 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
32 return QSize(600, 60);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
33 }
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
35 public slots:
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
36 void setTime(const float mtime);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
37 void setOffset(const float moffs);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
38
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
39 signals:
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
40 void timeChanged(float value);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
41 void offsetChanged(float value);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
42
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 protected:
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 void mousePressEvent(QMouseEvent *event);
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 void mouseMoveEvent(QMouseEvent *event);
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 void mouseReleaseEvent(QMouseEvent *event);
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 void paintEvent(QPaintEvent *event);
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 private:
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
51 bool dragging;
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
52 QPoint dragPoint;
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
53 float dragOffs; // milliseconds
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
54
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 float scale;
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
56 float time, offs, duration; // in milliseconds
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
57
400
f44a89a25c97 Fix waveform display from going over buffer limit.
Matti Hamalainen <ccr@tnsp.org>
parents: 393
diff changeset
58 int size, channels, format, freq, sduration;
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
59 void *data;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
60 };
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
61
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
62
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
63 class QWaveTrackView : public QWidget
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
64 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
65 Q_OBJECT
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
66
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
67 private:
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
68 QWaveTrackDisplay *wave;
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
69 QLabel *infoName, *infoData;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
70
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
71 public:
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
72
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
73 QWaveTrackView(QWidget *parent = 0);
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
74 void setWaveform(void *mdata, int mlen, int mformat, int mchannels, int mfreq);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
75 void setName(QString name);
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
76 void setTime(const float mtime);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
77 void setOffset(const float moffs);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
78 float getScaledWidth();
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
79 void setScale(const float mscale);
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
80 float getDuration();
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
81 float getTime();
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
82 float getOffset();
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
83
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
84 private slots:
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
85 void slotTimeChanged(float value);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
86 void slotOffsetChanged(float value);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
87
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
88 signals:
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
89 void timeChanged(float value);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
90 void offsetChanged(float value);
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 };
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 #endif