audiographspectrum.h 2.96 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/***************************************************************************
 *   Copyright (C) 2016 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
 *   This file is part of Kdenlive. See www.kdenlive.org.                  *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU General Public License as        *
 *   published by the Free Software Foundation; either version 2 of        *
 *   the License or (at your option) version 3 or any later version        *
 *   accepted by the membership of KDE e.V. (or its successor approved     *
 *   by the membership of KDE e.V.), which shall act as a proxy            *
 *   defined in Section 14 of version 3 of the license.                    *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 ***************************************************************************/

/*!
* @class AudioGraphSpectrum
* @brief An audio spectrum allowing to edit audio level / equalize clips or tracks
* @author Jean-Baptiste Mardelle
*/

#ifndef AUDIOGRAPHSPECTRUM_H
#define AUDIOGRAPHSPECTRUM_H

31
#include "../monitor/scopes/sharedframe.h"
32 33 34

#include <QWidget>
#include <QVector>
35
#include <QPixmap>
36 37 38 39 40 41 42

namespace Mlt {
class Filter;
}

class MonitorManager;

43 44 45 46
class EqualizerWidget : public QWidget
{
    Q_OBJECT
public:
47
    explicit EqualizerWidget(QWidget *parent = 0);
48 49 50

};

51 52 53 54
class AudioGraphWidget : public QWidget
{
    Q_OBJECT
public:
55
    explicit AudioGraphWidget(QWidget *parent = 0);
56
    void drawBackground();
57 58 59 60 61 62

public slots:
    void showAudio(const QVector<double>&bands);

protected:
    void paintEvent(QPaintEvent *pe);
63
    void resizeEvent(QResizeEvent * event);
64 65 66 67 68

private:
    QVector<double> m_levels;
    QVector<int> m_dbLabels;
    QStringList m_freqLabels;
69 70
    QPixmap m_pixmap;
    QRect m_rect;
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
    int m_maxDb;
    void drawDbLabels(QPainter& p, const QRect &rect);
    void drawChanLabels(QPainter& p, const QRect &rect, int barWidth);
};


class AudioGraphSpectrum : public QWidget
{
    Q_OBJECT
public:
    AudioGraphSpectrum(MonitorManager *manager, QWidget *parent = 0);
    virtual ~AudioGraphSpectrum();
private:
    MonitorManager *m_manager;
    Mlt::Filter* m_filter;
    AudioGraphWidget *m_graphWidget;
87
    EqualizerWidget *m_equalizer;
88 89 90

public slots:
    void processSpectrum(const SharedFrame&frame);
91
    void refreshPixmap();
92 93 94 95

};

#endif