traverso-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Traverso-commit] traverso/src/traverso dialogs/AudioClipEditDial...


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src/traverso dialogs/AudioClipEditDial...
Date: Fri, 29 Jun 2007 11:41:28 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       07/06/29 11:41:28

Modified files:
        src/traverso/dialogs: AudioClipEditDialog.cpp 
        src/traverso/ui: AudioClipEditWidget.ui 

Log message:
        basic functionality should work now

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/dialogs/AudioClipEditDialog.cpp?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/ui/AudioClipEditWidget.ui?cvsroot=traverso&r1=1.1&r2=1.2

Patches:
Index: dialogs/AudioClipEditDialog.cpp
===================================================================
RCS file: 
/sources/traverso/traverso/src/traverso/dialogs/AudioClipEditDialog.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- dialogs/AudioClipEditDialog.cpp     28 Jun 2007 15:03:56 -0000      1.1
+++ dialogs/AudioClipEditDialog.cpp     29 Jun 2007 11:41:28 -0000      1.2
@@ -26,11 +26,15 @@
 #include "ui_AudioClipEditWidget.h"
 
 #include "AudioClip.h"
+#include "FadeCurve.h"
+#include "ProjectManager.h"
+#include "Project.h"
 #include "Utils.h"
 #include "defines.h"
 #include "Mixer.h"
 #include "Command.h"
 #include "AudioClipExternalProcessing.h"
+#include "InputEngine.h"
 
 class AudioClipEditWidget : public QWidget, protected Ui::AudioClipEditWidget
 {
@@ -41,14 +45,26 @@
        {
                setupUi(this);
                
+               // Used to set gain and name
                clip_state_changed();
-               clip_start_value_changed(m_clip->get_track_start_frame() / 
m_clip->get_rate());
+               
+               // used for length, track start position
+               clip_position_changed();
+               
+               // detect and set fade params
+               fade_curve_added();
                
                connect(clip, SIGNAL(stateChanged()), this, 
SLOT(clip_state_changed()));
                connect(clip, SIGNAL(positionChanged(Snappable*)), this, 
SLOT(clip_position_changed()));
+               connect(clip, SIGNAL(fadeAdded(FadeCurve*)), this, 
SLOT(fade_curve_added()));
                
                connect(clipGainSpinBox, SIGNAL(valueChanged(double)), this, 
SLOT(gain_spinbox_value_changed(double)));
-               connect(clipStartSpinBox, SIGNAL(valueChanged(double)), this, 
SLOT(clip_start_value_changed(double)));
+               
+               connect(clipStartEdit, SIGNAL(timeChanged(const QTime&)), this, 
SLOT(clip_start_edit_changed(const QTime&)));
+               connect(clipLengthEdit, SIGNAL(timeChanged(const QTime&)), 
this, SLOT(clip_length_edit_changed(const QTime&)));
+               
+               connect(fadeInEdit, SIGNAL(timeChanged(const QTime&)), this, 
SLOT(fadein_edit_changed(const QTime&)));
+               connect(fadeOutEdit, SIGNAL(timeChanged(const QTime&)), this, 
SLOT(fadeout_edit_changed(const QTime&)));
                
                connect(externalProcessingButton, SIGNAL(clicked()), this, 
SLOT(external_processing()));
                connect(buttonBox, SIGNAL(accepted()), this, 
SLOT(save_changes()));
@@ -60,17 +76,27 @@
        AudioClip* m_clip;
        friend class AudioClipEditDialog;
        
+       nframes_t qtime_to_nframes(const QTime& time, uint rate);
+       
 private slots:
        void external_processing();
        void clip_state_changed();
        void save_changes();
        void clip_position_changed();
        void gain_spinbox_value_changed(double value);
-       void clip_start_value_changed(double value);
+       void fadein_length_changed();
+       void fadein_edit_changed(const QTime& time);
+       void fadeout_edit_changed(const QTime& time);
+       void fadeout_length_changed();
+       void clip_start_edit_changed(const QTime& time);
+       void clip_length_edit_changed(const QTime& time);
+       
+       void fade_curve_added();
 };
 
 
 AudioClipEditDialog::AudioClipEditDialog(AudioClip* clip, QWidget* parent)
+       : QDialog(parent)
 {
        m_edit = new AudioClipEditWidget(clip, this);
        
@@ -116,20 +142,91 @@
        m_clip->set_gain(gain);
 }
 
-void AudioClipEditWidget::clip_start_value_changed(double value)
+void AudioClipEditWidget::clip_position_changed()
 {
-       clipStartSpinBox->setValue(value);
+       QString clipLength = frame_to_ms(m_clip->get_length(), 
m_clip->get_rate());
+       QTime clipLengthTime = QTime::fromString(clipLength, "mm:ss");
+       clipLengthEdit->setTime(clipLengthTime);
        
-       nframes_t startframe = (nframes_t)(value * m_clip->get_rate());
+       QString clipStart = frame_to_ms(m_clip->get_track_start_frame(), 
m_clip->get_rate());
+       QTime clipStartTime = QTime::fromString(clipStart, "mm:ss");
+       clipStartEdit->setTime(clipStartTime);
+}
        
-       if (m_clip->get_track_start_frame() != startframe) {
-               m_clip->set_track_start_frame(startframe);
+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");
+       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");
+       fadeOutEdit->setTime(fadeTime);
+}
+
+void AudioClipEditWidget::fadein_edit_changed(const QTime& time)
+{
+       // Hmm, we can't distinguish between hand editing the time edit
+       // or moving the clip with the mouse! In the latter case this function
+       // causes trouble when moving the right edge with the mouse! 
+       // This 'fixes' it .....
+       if (ie().is_holding()) return;
+       
+       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);
        }
 }
 
-void AudioClipEditWidget::clip_position_changed()
+void AudioClipEditWidget::fadeout_edit_changed(const QTime& time)
 {
-       clip_start_value_changed((double)m_clip->get_track_start_frame() / 
m_clip->get_rate());
+       if (ie().is_holding()) return;
+       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);
+       }
+}
+
+void AudioClipEditWidget::clip_length_edit_changed(const QTime& time)
+{
+       if (ie().is_holding()) return;
+       
+       uint rate = m_clip->get_rate();
+       uint frames = qtime_to_nframes(time, rate);
+       m_clip->set_right_edge(frames);
+}
+
+void AudioClipEditWidget::clip_start_edit_changed(const QTime& time)
+{
+       if (ie().is_holding()) return;
+       m_clip->set_track_start_frame(qtime_to_nframes(time, 
m_clip->get_rate()));
+}
+
+nframes_t AudioClipEditWidget::qtime_to_nframes(const QTime & time, uint rate)
+{
+       return time.hour() * 3600 * rate + time.minute() * 60 * rate + 
time.second() * rate;
 }
 
+void AudioClipEditWidget::fade_curve_added()
+{
+       if (m_clip->get_fade_in()) {
+               fadein_length_changed();
+               connect(m_clip->get_fade_in(), SIGNAL(rangeChanged()), this, 
SLOT(fadein_length_changed()));
+       }
+       if (m_clip->get_fade_out()) {
+               fadeout_length_changed();
+               connect(m_clip->get_fade_out(), SIGNAL(rangeChanged()), this, 
SLOT(fadeout_length_changed()));
+       }
+
+}
+
+
 #include "AudioClipEditDialog.moc"

Index: ui/AudioClipEditWidget.ui
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/ui/AudioClipEditWidget.ui,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- ui/AudioClipEditWidget.ui   28 Jun 2007 15:03:56 -0000      1.1
+++ ui/AudioClipEditWidget.ui   29 Jun 2007 11:41:28 -0000      1.2
@@ -5,7 +5,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>485</width>
+    <width>523</width>
     <height>286</height>
    </rect>
   </property>
@@ -111,33 +111,27 @@
                <double>-120.000000000000000</double>
               </property>
               <property name="singleStep" >
-               <double>0.100000000000000</double>
+               <double>0.200000000000000</double>
               </property>
              </widget>
             </item>
             <item>
-             <widget class="QDoubleSpinBox" name="clipLengthSpinBox" >
-              <property name="decimals" >
-               <number>3</number>
+             <widget class="QTimeEdit" name="clipLengthEdit" >
+              <property name="currentSection" >
+               <enum>QDateTimeEdit::SecondSection</enum>
               </property>
-              <property name="maximum" >
-               <double>1200.000000000000000</double>
+              <property name="displayFormat" >
+               <string>h:mm:ss</string>
               </property>
              </widget>
             </item>
             <item>
-             <widget class="QDoubleSpinBox" name="clipStartSpinBox" >
-              <property name="suffix" >
-               <string/>
-              </property>
-              <property name="decimals" >
-               <number>3</number>
-              </property>
-              <property name="maximum" >
-               <double>1200.000000000000000</double>
+             <widget class="QTimeEdit" name="clipStartEdit" >
+              <property name="currentSection" >
+               <enum>QDateTimeEdit::SecondSection</enum>
               </property>
-              <property name="singleStep" >
-               <double>1.000000000000000</double>
+              <property name="displayFormat" >
+               <string>h:mm:ss</string>
               </property>
              </widget>
             </item>
@@ -208,7 +202,21 @@
          </widget>
         </item>
         <item>
-         <widget class="QDoubleSpinBox" name="doubleSpinBox_4" />
+         <widget class="QTimeEdit" name="fadeInEdit" >
+          <property name="maximumTime" >
+           <time>
+            <hour>22</hour>
+            <minute>0</minute>
+            <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>
       </widget>
@@ -233,7 +241,14 @@
          </widget>
         </item>
         <item>
-         <widget class="QDoubleSpinBox" name="doubleSpinBox_5" />
+         <widget class="QTimeEdit" name="fadeOutEdit" >
+          <property name="currentSection" >
+           <enum>QDateTimeEdit::SecondSection</enum>
+          </property>
+          <property name="displayFormat" >
+           <string>h:mm:ss</string>
+          </property>
+         </widget>
         </item>
        </layout>
       </widget>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]