view editor/edwaveform.h @ 2576:812b16ee49db

I had been living under apparent false impression that "realfft.c" on which the FFT implementation in DMLIB was basically copied from was released in public domain at some point, but it could very well be that it never was. Correct license is (or seems to be) GNU GPL. Thus I removing the code from DMLIB, and profusely apologize to the author, Philip Van Baren. It was never my intention to distribute code based on his original work under a more liberal license than originally intended.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 11 Mar 2022 16:32:50 +0200
parents e2ac08228a0f
children
line wrap: on
line source

#ifndef EDWAVEFORM_H
#define EDWAVEFORM_H

#include <QWidget>
#include <QLabel>
#include "dmengine.h"

class QEDWaveTrackDisplay : public QWidget
{
    Q_OBJECT

public:
    QEDWaveTrackDisplay(QWidget *parent = 0);

    void setWaveform(void *mdata, int msize, int mformat, int mchannels, int mfreq);
    float getScaledWidth();
    void setScale(const float mscale);
    int getBps();
    float getDuration();
    float getTimeScale(float value);
    float getTimeFromCoord(float value);
    float getTime();
    float getOffset();

    QSize minimumSizeHint() const
    {
        return QSize(100, 60);
    }

    QSize sizeHint() const
    {
        return QSize(600, 60);
    }

public slots:
    void setTime(const float mtime);
    void setOffset(const float moffs);
    void setSelection(const float mstart, const float mend);
    void clearSelection();

signals:
    void selectionChanged(float mstart, float mduration);
    void timeChanged(float value);
    void offsetChanged(float value);

protected:
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);

    void paintEvent(QPaintEvent *event);

private:
    float scale, time, offs, duration; // in milliseconds
    int size, channels, format, freq, sduration;
    void *data;

    bool selectionValid;
    float selectionStart, selectionDuration;

    QPoint selectionPoint, dragPoint;
    bool selecting, dragging;
    float selectionOffs, dragOffs;
};


class QEDWaveTrackView : public QWidget
{
    Q_OBJECT

private:
    QEDWaveTrackDisplay *wave;
    QLabel *infoName, *infoData;

public:

    QEDWaveTrackView(QWidget *parent = 0);
    void setWaveform(void *mdata, int mlen, int mformat, int mchannels, int mfreq);
    void setName(QString name);
    void setTime(const float mtime);
    void setOffset(const float moffs);
    float getScaledWidth();
    void setScale(const float mscale);
    float getDuration();
    float getTime();
    float getOffset();

private slots:
    void slotTimeChanged(float value);
    void slotOffsetChanged(float value);

signals:
    void timeChanged(float value);
    void offsetChanged(float value);
};

#endif