summaryrefslogtreecommitdiff
path: root/muse2/muse/midiedit/drummap.h
blob: f8633b2ff89c15ceb4368cf3252ed7f15fb7b77d (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
//=========================================================
//  MusE
//  Linux Music Editor
//  $Id: drummap.h,v 1.3.2.3 2009/10/29 02:14:37 terminator356 Exp $
//
//  (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; version 2 of
//  the License, or (at your option) any later version.
//
//  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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//
//=========================================================

#ifndef __DRUMMAP_H__
#define __DRUMMAP_H__

#include <QString>
#include <QList>

namespace MusECore {

class Xml;

//---------------------------------------------------------
//   DrumMap
//---------------------------------------------------------

struct DrumMap {
      QString name;
      unsigned char vol;            // playback volume, percent.
      int quant;
      int len;                      // len of event in ticks

      // Default to track port if -1 and track channel if -1.
      int channel;                  // midi channel
      int port;                     // midi port

      char lv1, lv2, lv3, lv4;      // velocities
      char enote, anote;            // input note - output note
      bool mute;

      bool operator==(const DrumMap& map) const;
      bool operator!=(const DrumMap& map) const { return !operator==(map); }
      bool almost_equals(const DrumMap& map) const;
      };

// please let this at "128". idrumMap should have length 128 (see drummap.cpp for details)
#define DRUM_MAPSIZE  128

extern DrumMap iNewDrumMap[128];
extern void initNewDrumMap();

extern void clearDrumMap();  // One-time only early init
extern void initDrumMap();
extern void writeDrumMap(int level, Xml& xml, bool external);
extern void readDrumMap(Xml& xml, bool external);
extern void resetGMDrumMap();

class MidiTrack;
} // namespace MusECore

namespace MusEGlobal {
extern char drumOutmap[DRUM_MAPSIZE];
extern char drumInmap[DRUM_MAPSIZE];
extern MusECore::DrumMap drumMap[DRUM_MAPSIZE];


class global_drum_ordering_t : public QList< std::pair<MusECore::MidiTrack*,int> >
{
  public:
    void cleanup();
    void write(int level, MusECore::Xml& xml);
    void read(MusECore::Xml& xml);
  
  private:
    typedef std::pair<MusECore::MidiTrack*,int> entry_t;
    
    void write_single(int level, MusECore::Xml& xml, const entry_t& entry);
    entry_t read_single(MusECore::Xml& xml);
};

extern global_drum_ordering_t global_drum_ordering;

}

#endif