MuseScore  3.4
Music composition and notation
drumset.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2002-2011 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __DRUMSET_H__
14 #define __DRUMSET_H__
15 
16 #include "mscore.h"
17 #include "tremolo.h"
18 #include "note.h"
19 #include "sym.h"
20 
21 namespace Ms {
22 
23 class XmlWriter;
24 
26  int pitch;
30  pitch = INVALID_PITCH;
32  articulationName = "";
33  }
34 };
35 
36 //---------------------------------------------------------
37 // DrumInstrument
38 //---------------------------------------------------------
39 
41  QString name;
42 
43  // if notehead = HEAD_CUSTOM, custom, use noteheads
46 
47  int line;
49  int voice;
50  char shortcut;
51  QList<DrumInstrumentVariant> variants;
52 
54  DrumInstrument(const char* s, NoteHead::Group nh, int l, Direction d,
55  int v = 0, char sc = 0)
56  : name(s), notehead(nh), line(l), stemDirection(d), voice(v), shortcut(sc) {}
57  void addVariant(DrumInstrumentVariant v) { variants.append(v); }
58  };
59 
60 static const int DRUM_INSTRUMENTS = 128;
61 
62 //---------------------------------------------------------
63 // Drumset
64 // defines noteheads and line position for all
65 // possible midi notes in a drumset
66 //---------------------------------------------------------
67 
68 class Drumset {
69  DrumInstrument _drum[DRUM_INSTRUMENTS];
70 
71  public:
72  bool isValid(int pitch) const { return !_drum[pitch].name.isEmpty(); }
73  NoteHead::Group noteHead(int pitch) const { return _drum[pitch].notehead; }
74  SymId noteHeads(int pitch, NoteHead::Type t) const { return _drum[pitch].noteheads[int(t)]; }
75  int line(int pitch) const { return _drum[pitch].line; }
76  int voice(int pitch) const { return _drum[pitch].voice; }
77  Direction stemDirection(int pitch) const { return _drum[pitch].stemDirection; }
78  const QString& name(int pitch) const { return _drum[pitch].name; }
79  int shortcut(int pitch) const { return _drum[pitch].shortcut; }
80  QList<DrumInstrumentVariant> variants(int pitch) const { return _drum[pitch].variants; }
81 
82  void save(XmlWriter&) const;
83  void load(XmlReader&);
84  bool readProperties(XmlReader&, int);
85  void clear();
86  int nextPitch(int) const;
87  int prevPitch(int) const;
88  DrumInstrument& drum(int i) { return _drum[i]; }
89  const DrumInstrument& drum(int i) const { return _drum[i]; }
90  DrumInstrumentVariant findVariant(int pitch, const QVector<Articulation*> articulations, Tremolo* tremolo) const;
91  };
92 
93 extern Drumset* smDrumset;
94 extern Drumset* gpDrumset;
95 extern void initDrumset();
96 
97 
98 } // namespace Ms
99 #endif
100 
Definition: xml.h:67
Direction stemDirection(int pitch) const
Definition: drumset.h:77
Drumset * gpDrumset
Definition: drumset.cpp:21
Definition: tremolo.h:39
const QString & name(int pitch) const
Definition: drumset.h:78
SymId
Definition: sym.h:30
QString articulationName
Definition: drumset.h:27
const DrumInstrument & drum(int i) const
Definition: drumset.h:89
QString name
Definition: drumset.h:41
DrumInstrument()
Definition: drumset.h:53
int shortcut(int pitch) const
Definition: drumset.h:79
TremoloType tremolo
Definition: drumset.h:28
Drumset * smDrumset
Definition: drumset.cpp:20
Definition: drumset.h:25
SymId noteHeads(int pitch, NoteHead::Type t) const
Definition: drumset.h:74
Definition: drumset.h:68
int line
place notehead onto this line
Definition: drumset.h:47
NoteHead::Group noteHead(int pitch) const
Definition: drumset.h:73
int voice(int pitch) const
Definition: drumset.h:76
QList< DrumInstrumentVariant > variants(int pitch) const
Definition: drumset.h:80
Definition: aeolus.cpp:26
DrumInstrument & drum(int i)
Definition: drumset.h:88
Definition: xml.h:218
int line(int pitch) const
Definition: drumset.h:75
TremoloType
Definition: tremolo.h:24
Definition: xmlwriter.h:26
void addVariant(DrumInstrumentVariant v)
Definition: drumset.h:57
Direction
Definition: types.h:282
Definition of classes Note and NoteHead.
Definition: drumset.h:40
const int INVALID_PITCH
Definition: pitchspelling.h:24
Direction stemDirection
Definition: drumset.h:48
Group
Definition: note.h:56
char shortcut
accelerator key (CDEFGAB)
Definition: drumset.h:50
SymId noteheads[int(NoteHead::Type::HEAD_TYPES)]
Definition: drumset.h:45
bool isValid(int pitch) const
Definition: drumset.h:72
Type
Definition: note.h:129
NoteHead::Group notehead
notehead symbol set
Definition: drumset.h:44
DrumInstrumentVariant()
Definition: drumset.h:29
DrumInstrument(const char *s, NoteHead::Group nh, int l, Direction d, int v=0, char sc=0)
Definition: drumset.h:54
void initDrumset()
Definition: drumset.cpp:240
int voice
Definition: drumset.h:49
int pitch
Definition: drumset.h:26
QList< DrumInstrumentVariant > variants
Definition: drumset.h:51