//============================================================================= // MuseScore // Music Composition & Notation // $Id: instrument.h 5149 2011-12-29 08:38:43Z wschweer $ // // Copyright (C) 2002-2011 Werner Schweer // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 // as published by the Free Software Foundation and appearing in // the file LICENCE.GPL //============================================================================= #ifndef __INSTRUMENT_H__ #define __INSTRUMENT_H__ #include "mscore.h" #include "event.h" #include "interval.h" struct InstrumentTemplate; class Xml; class Drumset; class Tablature; //--------------------------------------------------------- // StaffName //--------------------------------------------------------- struct StaffName { QString name; int pos; // even number -> between staves StaffName(const QString& s, int p=0) : name(s), pos(p) {} }; //--------------------------------------------------------- // StaffNameDoc //--------------------------------------------------------- struct StaffNameDoc { QTextDocumentFragment name; int pos; // even number -> between staves StaffNameDoc(const QTextDocumentFragment& s, int p=0) : name(s), pos(p) {} bool operator==(const StaffNameDoc&) const; }; //--------------------------------------------------------- // NamedEventList //--------------------------------------------------------- struct NamedEventList { QString name; QString descr; EventList events; void write(Xml&, const QString& name) const; void read(const QDomElement&); bool operator==(const NamedEventList& i) const { return i.name == name && i.events == events; } }; //--------------------------------------------------------- // MidiArticulation //--------------------------------------------------------- struct MidiArticulation { QString name; QString descr; int velocity; // velocity change: -100% - +100% int gateTime; // gate time change: -100% - +100% void write(Xml&) const; void read(const QDomElement&); MidiArticulation() {} bool operator==(const MidiArticulation& i) const; }; //--------------------------------------------------------- // Channel //--------------------------------------------------------- // this are the indexes of controllers which are always present in // Channel init EventList (maybe zero) enum { A_HBANK, A_LBANK, A_PROGRAM, A_VOLUME, A_PAN, A_CHORUS, A_REVERB, A_INIT_COUNT }; struct Channel { QString name; QString descr; int channel; // mscore channel number, mapped to midi port/channel mutable EventList init; int synti; int program; // current values as shown in mixer int bank; // initialized from "init" char volume; char pan; char chorus; char reverb; bool mute; bool solo; bool soloMute; QList midiActions; QList articulation; Channel(); void write(Xml&) const; void read(const QDomElement&); void updateInitList() const; bool operator==(const Channel& c) { return (name == c.name) && (channel == c.channel); } }; //--------------------------------------------------------- // Instrument //--------------------------------------------------------- class InstrumentData; class Instrument { QSharedDataPointer d; public: Instrument(); Instrument(const Instrument&); ~Instrument(); Instrument& operator=(const Instrument&); bool operator==(const Instrument&) const; void read(const QDomElement&); void write(Xml& xml) const; NamedEventList* midiAction(const QString& s, int channel) const; int channelIdx(const QString& s) const; void updateVelocity(int* velocity, int channel, const QString& name); void updateGateTime(int* gateTime, int channel, const QString& name); int minPitchP() const; int maxPitchP() const; int minPitchA() const; int maxPitchA() const; void setMinPitchP(int v); void setMaxPitchP(int v); void setMinPitchA(int v); void setMaxPitchA(int v); Interval transpose() const; void setTranspose(const Interval& v); void setDrumset(Drumset* ds); // drumset is now owned by Instrument Drumset* drumset() const; bool useDrumset() const; void setUseDrumset(bool val); void setAmateurPitchRange(int a, int b); void setProfessionalPitchRange(int a, int b); Channel& channel(int idx); const Channel& channel(int idx) const; const QList& midiActions() const; const QList& articulation() const; const QList& channel() const; void setMidiActions(const QList& l); void setArticulation(const QList& l); void setChannel(const QList& l); void setChannel(int i, const Channel& c); Tablature* tablature() const; void setTablature(Tablature* t); static Instrument fromTemplate(const InstrumentTemplate*); const QList& longNames() const; const QList& shortNames() const; QList& longNames(); QList& shortNames(); void setLongName(const QTextDocumentFragment&); void setShortName(const QTextDocumentFragment&); void addLongName(const StaffNameDoc& f); void addShortName(const StaffNameDoc& f); QString trackName() const; void setTrackName(const QString&); }; //--------------------------------------------------------- // InstrumentList //--------------------------------------------------------- typedef std::map::iterator iInstrument; typedef std::map::const_iterator ciInstrument; class InstrumentList : public std::map { static Instrument defaultInstrument; public: InstrumentList() {} const Instrument& instrument(int tick) const; Instrument& instrument(int tick); void setInstrument(const Instrument&, int tick); }; #endif