]> git.sesse.net Git - kdenlive/blobdiff - src/mainwindow.cpp
Audio Spectrum: Moved FFT calculation to FFTTools for re-use
[kdenlive] / src / mainwindow.cpp
index eb4a2f315158b42a1cfe84c11a3dae678afa7aa8..517acdc30282dc8034f44acd75fa2f46f89eb0d2 100644 (file)
 #include "kdenlive-config.h"
 #include "cliptranscode.h"
 #include "ui_templateclip_ui.h"
-#include "vectorscope.h"
-#include "waveform.h"
-#include "rgbparade.h"
-#include "histogram.h"
+#include "colorscopes/vectorscope.h"
+#include "colorscopes/waveform.h"
+#include "colorscopes/rgbparade.h"
+#include "colorscopes/histogram.h"
 #include "audiospectrum.h"
+#include "spectrogram.h"
 
 #include <KApplication>
 #include <KAction>
@@ -135,7 +136,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
     m_findActivated(false),
     m_stopmotion(NULL)
 {
-       qRegisterMetaType<QVector<int16_t> > ();
+    qRegisterMetaType<QVector<int16_t> > ();
     // Create DBus interface
     new MainWindowAdaptor(this);
     QDBusConnection dbus = QDBusConnection::sessionBus();
@@ -286,28 +287,39 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
         connect(m_clipMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
     }*/
 
-    m_audioSpectrum = new AudioSpectrum(m_projectMonitor, m_clipMonitor);
+    m_audioSpectrum = new AudioSpectrum();
     m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
     m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
     m_audioSpectrumDock->setWidget(m_audioSpectrum);
     addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
+
+    m_spectrogram = new Spectrogram();
+    m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
+    m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
+    m_spectrogramDock->setWidget(m_spectrogram);
+    addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
+
+    // Connect the audio signal to the audio scope slots
     bool b = true;
     if (m_projectMonitor) {
         qDebug() << "project monitor connected";
-        b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&,const int&,const int&, const int&)),
-                m_audioSpectrum, SLOT(slotReceiveAudio(const QVector<int16_t>&,const int&,const int&,const int&)));
-        b &= connect(m_projectMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)),
-                     m_audioSpectrum, SLOT(slotReceiveAudioTemp(const QByteArray&)));
-        connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&,const int&,const int&, const int&)),
-                     m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&,const int&,const int&,const int&)));
+        b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
+                     m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
+        b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
+                     m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
+        b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
+                     m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
     }
     if (m_clipMonitor) {
         qDebug() << "clip monitor connected";
-        b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&,int,int,int)),
-                m_audioSpectrum, SLOT(slotReceiveAudio(const QVector<int16_t>&,int,int,int)));
-        b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&,int,int,int)),
-                m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&,int,int,int)));
-    }
+        b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
+                     m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
+        b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
+                     m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
+        b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
+                     m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
+    }
+    // Ensure connections were set up correctly
     Q_ASSERT(b);
 
     m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
@@ -3098,6 +3110,13 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip)
                 // duration changed, we need to update duration
                 newprops.insert("out", QString::number(dia_ui->outPoint()));
             }
+            if (!path.isEmpty()) {
+                // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
+                if (KMessageBox::questionYesNo(this, i18n("You are editing an external title clip (%1). Do you want to save your changes to the title file or save the changes for this project only?", path), i18n("Save Title"), KGuiItem(i18n("Save to title file")), KGuiItem(i18n("Save in project only"))) == KMessageBox::Yes) {
+                    // save to external file
+                    dia_ui->saveTitle(path);
+                } else newprops.insert("resource", QString());
+            }
             EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
             m_activeDocument->commandStack()->push(command);
             //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
@@ -3961,7 +3980,7 @@ void MainWindow::slotMonitorRequestRenderFrame(bool request)
         return;
     } else {
         for (int i = 0; i < m_scopesList.count(); i++) {
-            if (m_scopesList.at(i)->isVisible() && tabifiedDockWidgets(m_scopesList.at(i)).isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
+            if (m_scopesList.at(i)->isVisible() && tabifiedDockWidgets(m_scopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
                 request = true;
                 break;
             }
@@ -3983,8 +4002,8 @@ void MainWindow::slotDoUpdateScopeFrameRequest()
     // Check scopes
     bool request = false;
     for (int i = 0; i < m_scopesList.count(); i++) {
-        if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
-            kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->widgetName();
+        if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
+            kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->widgetName();
             request = true;
             break;
         }
@@ -4004,8 +4023,8 @@ void MainWindow::slotUpdateColorScopes()
     bool request = false;
     for (int i = 0; i < m_scopesList.count(); i++) {
         // Check if we need the renderer to send a new frame for update
-        if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
-        static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
+        if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
+        static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
     }
     if (request) {
         if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
@@ -4018,12 +4037,12 @@ void MainWindow::slotOpenStopmotion()
     if (m_stopmotion == NULL) {
         m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
         connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
-       for (int i = 0; i < m_scopesList.count(); i++) {
-           // Check if we need the renderer to send a new frame for update
-           /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
-           connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
-           //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
-       }
+        for (int i = 0; i < m_scopesList.count(); i++) {
+            // Check if we need the renderer to send a new frame for update
+            /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
+            connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
+            //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
+        }
     }
     m_stopmotion->show();
 }