annotate edwaveform.cpp @ 393:5137db55f00b

More work towards the editor ..
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 19 Oct 2012 05:50:11 +0300
parents 28a74940f2b6
children 8660c6005032
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 #include <QtGui>
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
2 #include <SDL_audio.h>
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 #include "edwaveform.h"
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
6 QWaveTrackDisplay::QWaveTrackDisplay(QWidget *parent) : QWidget(parent)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 {
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
8 data = NULL;
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
9 size = 0;
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
10 format = AUDIO_S16SYS;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
11 channels = 1;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
12 freq = 1;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
13 scale = 1.0f;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
14 time = offs = 0;
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
15 duration = 0;
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
16
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
17 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
21 void QWaveTrackDisplay::setWaveform(void *mdata, int msize, int mformat, int mchannels, int mfreq)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 {
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
23 data = mdata;
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
24 size = msize;
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
25 format = mformat;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
26 channels = mchannels;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
27 freq = mfreq;
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
28
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
29 int bps = getBps();
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
30 if (bps != 0)
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
31 duration = ((float) (size / bps) / (float) freq) * 1000.0f;
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
32 else
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
33 duration = 0;
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
34
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 update();
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
39 int QWaveTrackDisplay::getBps()
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 {
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
41 int bps = channels;
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
42 switch (format)
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
43 {
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
44 case AUDIO_S16SYS:
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
45 case AUDIO_U16SYS:
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
46 bps *= sizeof(quint16);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
47 break;
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
48 case AUDIO_S8:
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
49 case AUDIO_U8:
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
50 bps *= sizeof(quint8);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
51 break;
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
52 }
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
53 return bps;
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
54 }
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
55
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
56
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
57 float QWaveTrackDisplay::getDuration()
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
58 {
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
59 return duration;
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
60 }
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
61
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
62
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
63 float QWaveTrackDisplay::getTimeScale(float value)
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
64 {
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
65 return (value * scale * (float) freq) / 1000.0f;
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
69 float QWaveTrackDisplay::getTimeFromCoord(float value)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 {
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
71 return value * scale;
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
75 void QWaveTrackDisplay::setTime(const float mtime)
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
76 {
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
77 if (time != mtime && mtime >= 0 && mtime < duration)
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
78 {
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
79 time = mtime;
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
80 update();
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
81 emit timeChanged(time);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
82 }
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
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
85
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
86 void QWaveTrackDisplay::setOffset(const float moffs)
391
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 if (offs != moffs && moffs >= 0 && moffs < getDuration())
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
89 {
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
90 offs = moffs;
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
91 update();
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
92 emit offsetChanged(offs);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
93 }
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
94 }
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
95
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
96
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
97 void QWaveTrackDisplay::setScale(const float mscale)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 if (mscale > 0.05)
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 scale = mscale;
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 update();
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
105 float QWaveTrackDisplay::getScaledWidth()
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
106 {
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
107 return getTimeScale(width());
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
108 }
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
109
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
110
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
111 float QWaveTrackDisplay::getTime()
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
112 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
113 return time;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
114 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
115
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
116
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
117 float QWaveTrackDisplay::getOffset()
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
118 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
119 return offs;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
120 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
121
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
122
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
123 void QWaveTrackDisplay::paintEvent(QPaintEvent *)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 QColor waveColor(0, 150, 0);
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
126 QColor waveCenterLine(0, 0, 0);
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
127 QColor markerColor(255,255,255);
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
128 QColor bgColor(0, 0, 0);//255, 255, 255);
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 QPainter painter(this);
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 painter.setRenderHint(QPainter::Antialiasing);
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
132 painter.fillRect(QRect(0, 0, width(), height()), bgColor);
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
134 if (data != NULL)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 {
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
136 int voffs = 0;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
137
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
138 painter.save();
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
139 painter.translate(0, height() / 2);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
140
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
141 painter.setPen(waveCenterLine);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
142 painter.drawLine(0, 0, width(), 0);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
143
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
144 switch (format)
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
145 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
146 case AUDIO_S16SYS:
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
147 painter.scale(1.0f, (float) height() / 32768.0f);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
148 break;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
149 case AUDIO_U16SYS:
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
150 voffs = -32768;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
151 painter.scale(1.0f, height() / 32768.0f);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
152 break;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
153
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
154 case AUDIO_S8:
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
155 painter.scale(1.0f, height() / 128.0f);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
156 break;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
157 case AUDIO_U8:
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
158 voffs = -128;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
159 painter.scale(1.0f, height() / 128.0f);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
160 break;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
161 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
162
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
163 painter.scale(1.0f, 0.5f);
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
164 painter.setPen(waveColor);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
165
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
166 float mscale = (scale * (float)freq) / 1000.0f;
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
167 int prevY = 0, prevX = 0;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
168 if (format == AUDIO_S16SYS || format == AUDIO_U16SYS)
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
169 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
170 qint16 *buf = (qint16 *) data;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
171 for (int xc = 0; xc < width(); xc++)
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
172 {
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
173 int value = buf[(int) (((offs + xc) * mscale)) * channels] + voffs;
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
174 painter.drawLine(prevX, prevY, xc, value);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
175 prevY = value;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
176 prevX = xc;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
177 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
178 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
179 else
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
180 if (format == AUDIO_S8 || format == AUDIO_U8)
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
181 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
182 qint8 *buf = (qint8 *) data;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
183 for (int xc = 0; xc < width(); xc++)
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
184 {
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
185 int value = buf[((int) ((offs + xc) * mscale)) * channels] + voffs;
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
186 painter.drawLine(prevX, prevY, xc, value);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
187 prevY = value;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
188 prevX = xc;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
189 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
190 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
191
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
192 painter.restore();
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
195 float xc = getTimeScale(time - offs), wd = getTimeScale(width());
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
196 if (xc >= 0 && xc <= wd)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 {
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
198 xc = time - offs;
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
199 painter.scale(scale, 1.0f);
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 painter.setPen(markerColor);
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 painter.drawLine(xc, 0, xc, height());
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
206 void QWaveTrackDisplay::mousePressEvent(QMouseEvent *ev)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 {
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 if (ev->button() == Qt::LeftButton)
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 {
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
210 dragPoint = ev->pos();
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
211 dragOffs = offs;
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
212 dragging = false;
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
217 void QWaveTrackDisplay::mouseMoveEvent(QMouseEvent *ev)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218 {
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
219 if ((ev->buttons() & Qt::LeftButton) && ev->pos().x() != dragPoint.x())
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
220 {
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
221 dragging = true;
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
222 setOffset(dragOffs - (ev->pos().x() - dragPoint.x()) / scale);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
223 }
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 }
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
227 void QWaveTrackDisplay::mouseReleaseEvent(QMouseEvent *ev)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 {
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
229 if (ev->button() == Qt::LeftButton)
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 {
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
231 dragging = false;
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 }
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
233 else
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
234 if (ev->button() == Qt::RightButton && !dragging)
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
235 {
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
236 setTime(offs + getTimeFromCoord(ev->pos().x()));
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
237 }
357
1b8362a26692 Work towards Qt based editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 }
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
239
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
240
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
241 QWaveTrackView::QWaveTrackView(QWidget *parent) : QWidget(parent)
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
242 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
243 QHBoxLayout *mainLayout = new QHBoxLayout(this);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
244 mainLayout->setMargin(0);
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
245 wave = new QWaveTrackDisplay(this);
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
246
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
247 QFrame *infoLayoutContainer = new QFrame(this);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
248 infoLayoutContainer->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
249 infoLayoutContainer->setLineWidth(2);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
250 // infoLayoutContainer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
251 // infoLayoutContainer->resize(250, 60);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
252
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
253 QVBoxLayout *infoLayout = new QVBoxLayout(infoLayoutContainer);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
254 infoLayout->setMargin(0);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
255 // QVBoxLayout *infoLayout = new QVBoxLayout();
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
256 infoName = new QLabel("Audio");
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
257 infoName->setStyleSheet("QLabel { background-color: black; color: white; padding: 2px; }");
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
258 infoLayout->addWidget(infoName);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
259
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
260 infoData = new QLabel();
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
261 infoData->setStyleSheet("QLabel { padding: 2px; }");
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
262 infoLayout->addWidget(infoData);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
263
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
264 mainLayout->addWidget(infoLayoutContainer);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
265 // mainLayout->addLayout(infoLayout);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
266 mainLayout->addWidget(wave);
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
267
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
268 connect(wave, SIGNAL(timeChanged(float)), this, SLOT(slotTimeChanged(float)));
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
269 connect(wave, SIGNAL(offsetChanged(float)), this, SLOT(slotOffsetChanged(float)));
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
270 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
271
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
272
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
273 void QWaveTrackView::setWaveform(void *mdata, int msize, int mformat, int mchannels, int mfreq)
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
274 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
275 QString fmt;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
276 switch (mformat)
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
277 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
278 case AUDIO_S16SYS: fmt = "16bit (S)"; break;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
279 case AUDIO_U16SYS: fmt = "16bit (U)"; break;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
280 case AUDIO_S8: fmt = "8bit (S)"; break;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
281 case AUDIO_U8: fmt = "8bit (U)"; break;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
282 default: fmt = "?"; break;
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
283 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
284 infoData->setText(QString("<b>%1</b>, <b>%2</b> ch, <b>%3</b> Hz").arg(fmt).arg(mchannels).arg(mfreq));
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
285 wave->setWaveform(mdata, msize, mformat, mchannels, mfreq);
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
286 update();
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
287 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
288
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
289
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
290 void QWaveTrackView::setName(QString name)
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
291 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
292 infoName->setText(name);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
293 update();
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
294 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
295
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
296
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
297 void QWaveTrackView::setTime(const float mtime)
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
298 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
299 wave->setTime(mtime);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
300 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
301
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
302
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
303 void QWaveTrackView::setOffset(const float moffs)
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
304 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
305 wave->setOffset(moffs);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
306 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
307
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
308
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
309 void QWaveTrackView::setScale(const float mscale)
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
310 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
311 wave->setScale(mscale);
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
312 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
313
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
314
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
315 float QWaveTrackView::getTime()
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
316 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
317 return wave->getTime();
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
318 }
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
319
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
320
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
321 float QWaveTrackView::getOffset()
384
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
322 {
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
323 return wave->getOffset();
e5220ff48bc8 Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 376
diff changeset
324 }
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
325
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
326
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
327 float QWaveTrackView::getScaledWidth()
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
328 {
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
329 return wave->getScaledWidth();
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
330 }
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
331
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
332
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
333 void QWaveTrackView::slotTimeChanged(float value)
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
334 {
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
335 emit timeChanged(value);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
336 }
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
337
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
338
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
339 void QWaveTrackView::slotOffsetChanged(float value)
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
340 {
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
341 emit offsetChanged(value);
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
342 }
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
343
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
344
393
5137db55f00b More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents: 391
diff changeset
345 float QWaveTrackView::getDuration()
391
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
346 {
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
347 return wave->getDuration();
28a74940f2b6 More work on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents: 384
diff changeset
348 }