summaryrefslogtreecommitdiff
path: root/muse_qt4_evolution/muse/miditrack.h
blob: 994c3c92f7a05aa4968f4730f3db686f27b7572b (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 __MIDITRACK_H__
#define __MIDITRACK_H__

#include "miditrackbase.h"
#include "midififo.h"
#include "event.h"

class Part;
class EventList;
class MidiOut;
class SeqTime;

//---------------------------------------------------------
//   MidiTrack
//---------------------------------------------------------

class MidiTrack : public MidiTrackBase {
      Q_OBJECT

      EventList _events;         // tmp Events during midi import

      // recording:
      MidiFifo recordFifo;       // for event transfer from RT-thread to gui thread
      std::list<Event> keyDown;  // keep track of "note on" events
      Part* recordPart;          // part we are recording into
      int recordedEvents;
      bool partCreated;
      int hbank, lbank;
      int datah, datal;
      int rpnh, rpnl;
      int dataType;

      // channel data:
      DrumMap* _drumMap;
      bool _useDrumMap;

      // play parameter
      int _transposition;
      int _velocity;
      int _delay;
      int _len;
      int _compression;

      MidiEventList schedEvents;  // scheduled events by process()

   signals:
      void drumMapChanged() const;
      void useDrumMapChanged(bool);
      void channelChanged(int);

   public slots:
      void setChannel(int);

   public:
      MidiTrack();
      virtual ~MidiTrack();
      virtual TrackType type() const { return MIDI; }
      void clone(MidiTrack*);

      int transposition() const      { return _transposition; }
      int velocity() const           { return _velocity;     }
      int delay() const              { return _delay;        }
      int len() const                { return _len;          }
      int compression() const        { return  _compression; }
      void setTransposition(int val) { _transposition = val; }
      void setVelocity(int val)      { _velocity      = val; }
      void setDelay(int val)         { _delay         = val; }
      void setLen(int val)           { _len           = val; }
      void setCompression(int val)   { _compression   = val; }

      void startRecording();
      void recordBeat();
      void stopRecording();

      EventList* events()             { return &_events;   }

      virtual void read(QDomNode);
      virtual void write(Xml&) const;

      virtual Part* newPart(Part*p=0, bool clone=false);

      virtual bool isMute() const;
      virtual bool canRecord() const      { return true; }
      void playMidiEvent(MidiEvent*);

      virtual void processMidi(SeqTime*);
      virtual void getEvents(unsigned from, unsigned to, int channel, MidiEventList* dst);

      bool useDrumMap() const             { return _useDrumMap;    }
      DrumMap* drumMap() const            { return _drumMap; }
      void setUseDrumMap(bool val);

      int channelNo() const;
      virtual void emitControllerChanged(int id);

      virtual MidiOut* midiOut();
      virtual MidiInstrument* instrument();
      };

typedef QList<MidiTrack*> MidiTrackList;
typedef MidiTrackList::iterator iMidiTrack;
typedef MidiTrackList::const_iterator ciMidiTrack;

Q_DECLARE_METATYPE(class MidiTrack*);

#endif