summaryrefslogtreecommitdiff
path: root/attic/muse_qt4_evolution/muse/waveedit/waveview.h
blob: 462ce26d871f9d324ea7a67b1bc194deeadd45b9 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//=============================================================================
//  MusE
//  Linux Music Editor
//  $Id:$
//
//  Copyright (C) 2002-2006 by Werner Schweer and others
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License version 2.
//
//  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, write to the Free Software
//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================

#ifndef WAVE_VIEW_H
#define WAVE_VIEW_H

#include "al/pos.h"
#include "wave.h"
#include "awl/tcanvas.h"
#include "ctrl/ctrledit.h"

class PartList;
class QPainter;
class QRect;
class Part;
class WaveEdit;
class GraphMidiEditor;

//---------------------------------------------------------
//   WaveEventSelection
//---------------------------------------------------------

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

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

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

class WaveView : public TimeCanvas {
      Q_OBJECT

      WaveEdit* editor;
      CtrlEditList ctrlEditList;

      int startFrame;
      int endFrame;

      Part* curPart;

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

      unsigned selectionStart, selectionStop, dragstartx;
      int curSplitter;  // -1 mouse not in splitter
      bool dragSplitter;
      int splitterY;

      virtual void paint(QPainter&, QRect);
      virtual void mousePress(QMouseEvent*);
      virtual void mouseMove(QPoint);
      virtual void enterB();
      virtual void leaveB();
      virtual void mouseRelease(QMouseEvent*);

      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 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

      void drawWavePart(QPainter& p, Part* wp, int y0, int th, int from, int to);
      virtual void addController();
      virtual void layout();
      void layoutPanelB(CtrlEdit*);
      void updatePartControllerList();

      virtual void paintControllerCanvas(QPainter&, QRect);
      virtual void paintControllerPanel(QPainter&, QRect);

      void setCursor();

   private slots:
      void removeController(QAction*);

   public slots:
      void songChanged(int type);

   signals:
      void yChanged(int);  // emitted from mouseMove in controller canvas

   public:
      WaveView(WaveEdit*);
      QString getCaption() const;
      void cmd(const QString&);
      void range(AL::Pos&, AL::Pos&) const;
      void addController(int id, int h);
      void layout1();
      const CtrlEditList* getCtrlEditors() const { return &ctrlEditList; }
      };

#endif