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 __INSTRTEMPLATE_H__ 14 #define __INSTRTEMPLATE_H__ 15 16 #include "mscore.h" 17 #include "instrument.h" 18 #include "clef.h" 19 #include "stringdata.h" 20 21 namespace Ms { 22 23 class XmlWriter; 24 class Part; 25 class Staff; 26 class StringData; 27 class StaffType; 28 29 //--------------------------------------------------------- 30 // InstrumentGenre 31 //--------------------------------------------------------- 32 33 class InstrumentGenre { 34 public: 35 QString id; 36 QString name; 37 InstrumentGenre()38 InstrumentGenre() {} 39 void write(XmlWriter& xml) const; 40 void write1(XmlWriter& xml) const; 41 void read(XmlReader&); 42 }; 43 44 //--------------------------------------------------------- 45 // InstrumentFamily 46 //--------------------------------------------------------- 47 48 class InstrumentFamily { 49 public: 50 QString id; 51 QString name; 52 InstrumentFamily()53 InstrumentFamily() {} 54 void write(XmlWriter& xml) const; 55 void write1(XmlWriter& xml) const; 56 void read(XmlReader&); 57 }; 58 59 //--------------------------------------------------------- 60 // InstrumentTemplate 61 //--------------------------------------------------------- 62 63 class InstrumentTemplate { 64 int staves; // 1 <= MAX_STAVES 65 66 public: 67 QString id; 68 QString trackName; 69 StaffNameList longNames; ///< shown on first system 70 StaffNameList shortNames; ///< shown on followup systems 71 QString musicXMLid; ///< used in MusicXML 3.0 72 QString description; ///< a longer description of the instrument 73 74 char minPitchA; // pitch range playable by an amateur 75 char maxPitchA; 76 char minPitchP; // pitch range playable by professional 77 char maxPitchP; 78 79 Interval transpose; // for transposing instruments 80 81 StaffGroup staffGroup; 82 const StaffType* staffTypePreset; 83 bool useDrumset; 84 Drumset* drumset; 85 86 StringData stringData; 87 88 QList<NamedEventList> midiActions; 89 QList<MidiArticulation> articulation; 90 QList<Channel> channel; 91 QList<InstrumentGenre*> genres; //; list of genres this instrument belongs to 92 InstrumentFamily* family; //; family the instrument belongs to 93 94 ClefTypeList clefTypes[MAX_STAVES]; 95 int staffLines[MAX_STAVES]; 96 BracketType bracket[MAX_STAVES]; // bracket type (NO_BRACKET) 97 int bracketSpan[MAX_STAVES]; 98 int barlineSpan[MAX_STAVES]; 99 bool smallStaff[MAX_STAVES]; 100 101 bool extended; // belongs to extended instrument set if true 102 103 bool singleNoteDynamics; 104 105 InstrumentTemplate(); 106 InstrumentTemplate(const InstrumentTemplate&); 107 ~InstrumentTemplate(); 108 void init(const InstrumentTemplate&); 109 void linkGenre(const QString &); 110 void addGenre(QList<InstrumentGenre *>); 111 bool genreMember(const QString &); 112 bool familyMember(const QString &); 113 114 void setPitchRange(const QString& s, char* a, char* b) const; 115 void write(XmlWriter& xml) const; 116 void write1(XmlWriter& xml) const; 117 void read(XmlReader&); nstaves()118 int nstaves() const { return staves; } setStaves(int val)119 void setStaves(int val) { staves = val; } 120 ClefTypeList clefType(int staffIdx) const; 121 }; 122 123 //--------------------------------------------------------- 124 // InstrumentGroup 125 //--------------------------------------------------------- 126 127 struct InstrumentGroup { 128 QString id; 129 QString name; 130 bool extended; // belongs to extended instruments set if true 131 QList<InstrumentTemplate*> instrumentTemplates; 132 void read(XmlReader&); 133 void clear(); 134 InstrumentGroupInstrumentGroup135 InstrumentGroup() { extended = false; } 136 }; 137 138 //--------------------------------------------------------- 139 // InstrumentIndex 140 //--------------------------------------------------------- 141 142 struct InstrumentIndex { 143 int groupIndex; 144 int instrIndex; 145 InstrumentTemplate* instrTemplate; 146 InstrumentIndexInstrumentIndex147 InstrumentIndex(int g, int i, InstrumentTemplate* it) 148 : groupIndex { g }, instrIndex { i }, instrTemplate { it } {} 149 }; 150 151 152 extern QList<InstrumentGenre *> instrumentGenres; 153 extern QList<InstrumentFamily *> instrumentFamilies; 154 extern QList<MidiArticulation> articulation; 155 extern QList<InstrumentGroup*> instrumentGroups; 156 extern void clearInstrumentTemplates(); 157 extern bool loadInstrumentTemplates(const QString& instrTemplates); 158 extern bool saveInstrumentTemplates(const QString& instrTemplates); 159 extern InstrumentTemplate* searchTemplate(const QString& name); 160 extern InstrumentIndex searchTemplateIndexForTrackName(const QString& trackName); 161 extern InstrumentIndex searchTemplateIndexForId(const QString& id); 162 extern InstrumentTemplate* searchTemplateForMusicXmlId(const QString& mxmlId); 163 extern InstrumentTemplate* searchTemplateForInstrNameList(const QList<QString>& nameList); 164 extern InstrumentTemplate* searchTemplateForMidiProgram(int midiProgram, const bool useDrumKit = false); 165 extern InstrumentTemplate* guessTemplateByNameData(const QList<QString>& nameDataList); 166 extern InstrumentGroup* searchInstrumentGroup(const QString& name); 167 extern ClefType defaultClef(int patch); 168 169 } // namespace Ms 170 #endif 171 172