summaryrefslogtreecommitdiff
path: root/muse2/muse/waveedit/waveview.h
blob: c79929529991917311c40b8970e2d40a4f09878a (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//=========================================================
//  MusE
//  Linux Music Editor
//    $Id: waveview.h,v 1.3.2.6 2009/02/02 21:38:01 terminator356 Exp $
//  (C) Copyright 2000 Werner Schweer (ws@seh.de)
//=========================================================

#ifndef WAVE_VIEW_H
#define WAVE_VIEW_H

#include "view.h"
#include <QWidget>
#include <QMouseEvent>
#include "wave.h"

class PartList;
class QPainter;
class QRect;
class WavePart;
class MidiEditor;
class SndFileR;

struct WaveEventSelection {
      SndFileR file;
      unsigned startframe;
      unsigned endframe;
      };

typedef std::list<WaveEventSelection> WaveSelectionList;
typedef std::list<WaveEventSelection>::iterator iWaveSelection;

//---------------------------------------------------------
//   WaveView
//---------------------------------------------------------

class WaveView : public View {
      MidiEditor* editor;
      unsigned pos[3];
      int yScale;
      int button;
      int startSample;
      int endSample;

      WavePart* curPart;
      QString copiedPart;
      int curPartId;

      enum { NORMAL, DRAG } mode;
      enum { MUTE = 0, NORMALIZE, FADE_IN, FADE_OUT, REVERSE, GAIN, EDIT_EXTERNAL, CUT, COPY, PASTE }; //!< Modify operations

      unsigned selectionStart, selectionStop, dragstartx;

      Q_OBJECT
      virtual void pdraw(QPainter&, const QRect&);
      virtual void draw(QPainter&, const QRect&);
      virtual void viewMousePressEvent(QMouseEvent*);
      virtual void viewMouseMoveEvent(QMouseEvent*);
      virtual void viewMouseReleaseEvent(QMouseEvent*);
      virtual void wheelEvent(QWheelEvent*);

      //bool getUniqueTmpfileName(QString& newFilename); //!< Generates unique filename for temporary SndFile
      WaveSelectionList getSelection(unsigned startpos, unsigned stoppos);

      int lastGainvalue; //!< Stores the last used gainvalue when specifiying gain value in the editgain dialog
      void modifySelection(int operation, unsigned startpos, unsigned stoppos, double paramA); //!< Modifies selection

      void muteSelection(unsigned channels, float** data, unsigned length); //!< Mutes selection
      void normalizeSelection(unsigned channels, float** data, unsigned length); //!< Normalizes selection
      void fadeInSelection(unsigned channels, float** data, unsigned length); //!< Linear fade in of selection
      void fadeOutSelection(unsigned channels, float** data, unsigned length); //!< Linear fade out of selection
      void reverseSelection(unsigned channels, float** data, unsigned length); //!< Reverse selection
      void applyGain(unsigned channels, float** data, unsigned length, double gain); //!< Apply gain to selection
      void copySelection(unsigned file_channels, float** tmpdata, unsigned tmpdatalen, bool blankData, unsigned format, unsigned sampleRate);

      void editExternal(unsigned file_format, unsigned file_samplerate, unsigned channels, float** data, unsigned length);

      //void applyLadspa(unsigned channels, float** data, unsigned length); //!< Apply LADSPA plugin on selection


   private slots:
      void setPos(int idx, unsigned val, bool adjustScrollbar);

   public slots:
      void setYScale(int);
      void songChanged(int type);

   signals:
      void followEvent(int);
      void timeChanged(unsigned);
      void mouseWheelMoved(int);
      void horizontalScroll(unsigned);
      void horizontalZoomIn();
      void horizontalZoomOut();

   public:
      WaveView(MidiEditor*, QWidget* parent, int xscale, int yscale);
      QString getCaption() const;
      void range(int*, int*);
      void cmd(int n);
      WavePart* part() { return curPart; }
      };

#endif