[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src/traverso dialogs/AudioClipEditDial...
From: |
Nicola Doebelin |
Subject: |
[Traverso-commit] traverso/src/traverso dialogs/AudioClipEditDial... |
Date: |
Sat, 30 Jun 2007 13:05:28 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Nicola Doebelin <n_doebelin> 07/06/30 13:05:28
Modified files:
src/traverso/dialogs: AudioClipEditDialog.cpp
src/traverso/ui: AudioClipEditWidget.ui
Log message:
Increased precision of Spin boxes to milliseconds, added field "end" to
the clip editor
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/dialogs/AudioClipEditDialog.cpp?cvsroot=traverso&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/ui/AudioClipEditWidget.ui?cvsroot=traverso&r1=1.2&r2=1.3
Patches:
Index: dialogs/AudioClipEditDialog.cpp
===================================================================
RCS file:
/sources/traverso/traverso/src/traverso/dialogs/AudioClipEditDialog.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- dialogs/AudioClipEditDialog.cpp 29 Jun 2007 11:41:28 -0000 1.2
+++ dialogs/AudioClipEditDialog.cpp 30 Jun 2007 13:05:28 -0000 1.3
@@ -36,6 +36,8 @@
#include "AudioClipExternalProcessing.h"
#include "InputEngine.h"
+#define TIME_FORMAT "hh:mm:ss.zzz"
+
class AudioClipEditWidget : public QWidget, protected Ui::AudioClipEditWidget
{
Q_OBJECT
@@ -45,6 +47,13 @@
{
setupUi(this);
+ locked = false;
+
+ clipStartEdit->setDisplayFormat(TIME_FORMAT);
+ clipLengthEdit->setDisplayFormat(TIME_FORMAT);
+ fadeInEdit->setDisplayFormat(TIME_FORMAT);
+ fadeOutEdit->setDisplayFormat(TIME_FORMAT);
+
// Used to set gain and name
clip_state_changed();
@@ -77,6 +86,8 @@
friend class AudioClipEditDialog;
nframes_t qtime_to_nframes(const QTime& time, uint rate);
+ QTime nframes_to_qtime(nframes_t nframes, uint rate);
+ bool locked;
private slots:
void external_processing();
@@ -90,6 +101,7 @@
void fadeout_length_changed();
void clip_start_edit_changed(const QTime& time);
void clip_length_edit_changed(const QTime& time);
+ void update_clip_end();
void fade_curve_added();
};
@@ -144,27 +156,31 @@
void AudioClipEditWidget::clip_position_changed()
{
- QString clipLength = frame_to_ms(m_clip->get_length(),
m_clip->get_rate());
- QTime clipLengthTime = QTime::fromString(clipLength, "mm:ss");
+ if (locked) return;
+
+ QTime clipLengthTime = nframes_to_qtime(m_clip->get_length(),
m_clip->get_rate());
clipLengthEdit->setTime(clipLengthTime);
- QString clipStart = frame_to_ms(m_clip->get_track_start_frame(),
m_clip->get_rate());
- QTime clipStartTime = QTime::fromString(clipStart, "mm:ss");
+ QTime clipStartTime = nframes_to_qtime(m_clip->get_track_start_frame(),
m_clip->get_rate());
clipStartEdit->setTime(clipStartTime);
+
+ update_clip_end();
}
void AudioClipEditWidget::fadein_length_changed()
{
if (ie().is_holding()) return;
- QString length = frame_to_ms(m_clip->get_fade_in()->get_range(),
m_clip->get_rate());
- QTime fadeTime = QTime::fromString(length, "mm:ss");
+ if (locked) return;
+
+ QTime fadeTime = nframes_to_qtime(m_clip->get_fade_in()->get_range(),
m_clip->get_rate());
fadeInEdit->setTime(fadeTime);
}
void AudioClipEditWidget::fadeout_length_changed()
{
- QString length = frame_to_ms(m_clip->get_fade_out()->get_range(),
m_clip->get_rate());
- QTime fadeTime = QTime::fromString(length, "mm:ss");
+ if (locked) return;
+
+ QTime fadeTime = nframes_to_qtime(m_clip->get_fade_out()->get_range(),
m_clip->get_rate());
fadeOutEdit->setTime(fadeTime);
}
@@ -176,43 +192,80 @@
// This 'fixes' it .....
if (ie().is_holding()) return;
+ locked = true;
nframes_t frames = qtime_to_nframes(time, m_clip->get_rate());
if (frames == 0) {
m_clip->set_fade_in(1);
} else {
m_clip->set_fade_in(frames);
}
+ locked = false;
}
void AudioClipEditWidget::fadeout_edit_changed(const QTime& time)
{
if (ie().is_holding()) return;
+
+ locked = true;
nframes_t frames = qtime_to_nframes(time, m_clip->get_rate());
if (frames == 0) {
m_clip->set_fade_out(1);
} else {
m_clip->set_fade_out(frames);
}
+ locked = false;
}
void AudioClipEditWidget::clip_length_edit_changed(const QTime& time)
{
if (ie().is_holding()) return;
+ locked = true;
uint rate = m_clip->get_rate();
uint frames = qtime_to_nframes(time, rate);
- m_clip->set_right_edge(frames);
+
+ if (frames >= m_clip->get_source_length()) {
+ frames = m_clip->get_source_length();
+ QTime clipLengthTime = nframes_to_qtime(frames,
m_clip->get_rate());
+ clipLengthEdit->setTime(clipLengthTime);
+ }
+
+ m_clip->set_right_edge(frames + m_clip->get_track_start_frame());
+ update_clip_end();
+ locked = false;
}
void AudioClipEditWidget::clip_start_edit_changed(const QTime& time)
{
if (ie().is_holding()) return;
+
+ locked = true;
m_clip->set_track_start_frame(qtime_to_nframes(time,
m_clip->get_rate()));
+ update_clip_end();
+ locked = false;
}
nframes_t AudioClipEditWidget::qtime_to_nframes(const QTime & time, uint rate)
{
- return time.hour() * 3600 * rate + time.minute() * 60 * rate +
time.second() * rate;
+ return time.hour() * 3600 * rate + time.minute() * 60 * rate +
time.second() * rate + (time.msec() * rate) / 1000;
+}
+
+QTime AudioClipEditWidget::nframes_to_qtime(nframes_t nframes, uint rate)
+{
+ long unsigned int remainder;
+ int hours, mins, secs, msec;
+
+ remainder = nframes;
+ hours = remainder / (3600 * rate);
+ remainder -= ( hours * 3600 * rate );
+ mins = remainder / ( 60 * rate );
+ remainder -= ( mins * 60 * rate );
+ secs = remainder / rate;
+ remainder -= secs * rate;
+ msec = remainder * 1000 / rate;
+
+ QTime time(hours, mins, secs, msec);
+ return time;
}
void AudioClipEditWidget::fade_curve_added()
@@ -225,8 +278,13 @@
fadeout_length_changed();
connect(m_clip->get_fade_out(), SIGNAL(rangeChanged()), this,
SLOT(fadeout_length_changed()));
}
-
}
+void AudioClipEditWidget::update_clip_end()
+{
+ nframes_t clipEndFrame = m_clip->get_track_start_frame() +
m_clip->get_length();
+ QTime clipEndTime = nframes_to_qtime(clipEndFrame, m_clip->get_rate());
+ clipEndLineEdit->setText(clipEndTime.toString(TIME_FORMAT));
+}
#include "AudioClipEditDialog.moc"
Index: ui/AudioClipEditWidget.ui
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/ui/AudioClipEditWidget.ui,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- ui/AudioClipEditWidget.ui 29 Jun 2007 11:41:28 -0000 1.2
+++ ui/AudioClipEditWidget.ui 30 Jun 2007 13:05:28 -0000 1.3
@@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>523</width>
- <height>286</height>
+ <height>313</height>
</rect>
</property>
<property name="minimumSize" >
@@ -30,79 +30,82 @@
<property name="title" >
<string>Clip parameters</string>
</property>
- <layout class="QHBoxLayout" >
+ <layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
- <item>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>0</number>
+ <item rowspan="3" row="2" column="2" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
</property>
- <property name="spacing" >
- <number>6</number>
+ <property name="sizeHint" >
+ <size>
+ <width>197</width>
+ <height>81</height>
+ </size>
</property>
- <item>
- <widget class="QLabel" name="label" >
+ </spacer>
+ </item>
+ <item row="4" column="1" >
+ <widget class="QLineEdit" name="clipEndLineEdit" >
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" >
+ <widget class="QLabel" name="label_6" >
<property name="text" >
- <string>Name</string>
+ <string>End</string>
</property>
</widget>
</item>
- <item>
- <widget class="QLabel" name="label_4" >
+ <item row="3" column="1" >
+ <widget class="QTimeEdit" name="clipLengthEdit" />
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="label_3" >
<property name="text" >
- <string>Gain</string>
+ <string>Track start</string>
</property>
</widget>
</item>
- <item>
+ <item row="3" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Length</string>
</property>
</widget>
</item>
- <item>
- <widget class="QLabel" name="label_3" >
+ <item row="2" column="1" >
+ <widget class="QTimeEdit" name="clipStartEdit" />
+ </item>
+ <item row="1" column="2" >
+ <widget class="QPushButton" name="externalProcessingButton" >
<property name="text" >
- <string>Track start</string>
+ <string>External Processing</string>
</property>
</widget>
</item>
- </layout>
- </item>
- <item>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="label_4" >
+ <property name="text" >
+ <string>Gain</string>
</property>
- <item>
- <widget class="QLineEdit" name="clipNameLineEdit" />
+ </widget>
</item>
- <item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>Name</string>
</property>
- <item>
+ </widget>
+ </item>
+ <item row="1" column="1" >
<widget class="QDoubleSpinBox" name="clipGainSpinBox" >
<property name="maximum" >
<double>30.000000000000000</double>
@@ -115,61 +118,8 @@
</property>
</widget>
</item>
- <item>
- <widget class="QTimeEdit" name="clipLengthEdit" >
- <property name="currentSection" >
- <enum>QDateTimeEdit::SecondSection</enum>
- </property>
- <property name="displayFormat" >
- <string>h:mm:ss</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QTimeEdit" name="clipStartEdit" >
- <property name="currentSection" >
- <enum>QDateTimeEdit::SecondSection</enum>
- </property>
- <property name="displayFormat" >
- <string>h:mm:ss</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <widget class="QPushButton" name="externalProcessingButton" >
- <property name="text" >
- <string>External Processing</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
+ <item row="0" column="1" colspan="2" >
+ <widget class="QLineEdit" name="clipNameLineEdit" />
</item>
</layout>
</widget>
@@ -210,12 +160,6 @@
<second>0</second>
</time>
</property>
- <property name="currentSection" >
- <enum>QDateTimeEdit::SecondSection</enum>
- </property>
- <property name="displayFormat" >
- <string>h:mm:ss</string>
- </property>
</widget>
</item>
</layout>
@@ -241,14 +185,7 @@
</widget>
</item>
<item>
- <widget class="QTimeEdit" name="fadeOutEdit" >
- <property name="currentSection" >
- <enum>QDateTimeEdit::SecondSection</enum>
- </property>
- <property name="displayFormat" >
- <string>h:mm:ss</string>
- </property>
- </widget>
+ <widget class="QTimeEdit" name="fadeOutEdit" />
</item>
</layout>
</widget>