00001 #ifndef WAVEFORMWIDGET_H
00002 #define WAVEFORMWIDGET_H
00003
00004 #include "AudioUtil.h"
00005 #include "MathUtil.h"
00006
00007 #include <stdio.h>
00008 #include <stdlib.h>
00009 #include <math.h>
00010 #include <vector>
00011
00012 #include <sndfile.h>
00013
00014 #include <QSize>
00015 #include <QColor>
00016 #include <QWidget>
00017 #include <QPainter>
00018 #include <QPaintEvent>
00019 #include <QDebug>
00020 #include <QPoint>
00021 #include <QResizeEvent>
00022
00023
00024
00025
00026
00027
00028 using namespace std;
00029
00030
00031
00032
00033
00034
00035 class WaveformWidget : public QWidget
00036 {
00037 public:
00038 WaveformWidget(string filePath);
00039 ~WaveformWidget();
00040 void resetFile(string fileName);
00041 enum FileHandlingMode {FULL_CACHE, DISK_MODE};
00042 void setColor(QColor color);
00043 void setFileHandlingMode(FileHandlingMode mode);
00044 FileHandlingMode getFileHandlingMode();
00045
00046 protected:
00047 virtual void resizeEvent(QResizeEvent *);
00048 virtual void paintEvent( QPaintEvent * event );
00049
00050 private:
00051 AudioUtil *srcAudioFile;
00052 enum DrawingMode {OVERVIEW, MACRO, NO_MODE};
00053 DrawingMode currentDrawingMode;
00054 FileHandlingMode currentFileHandlingMode;
00055 vector<double> peakVector;
00056 vector<double> dataVector;
00057 string audioFilePath;
00058 double max_peak;
00059 double padding;
00060 QSize lastSize;
00061 QColor waveformColor;
00062
00063 double scaleFactor;
00064 void recalculatePeaks();
00065 void establishDrawingMode();
00066 void macroDraw(QPaintEvent* event);
00067 void overviewDraw(QPaintEvent* event);
00068 };
00069
00070 #endif // WAVEFORMWIDGET_H