1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 3 /* 4 Rosegarden 5 A sequencer and musical notation editor. 6 Copyright 2000-2021 the Rosegarden development team. 7 See the AUTHORS file for more details. 8 9 This program is free software; you can redistribute it and/or 10 modify it under the terms of the GNU General Public License as 11 published by the Free Software Foundation; either version 2 of the 12 License, or (at your option) any later version. See the file 13 COPYING included with this distribution for more information. 14 */ 15 16 #ifndef RG_TRACK_H 17 #define RG_TRACK_H 18 19 #include "rosegardenprivate_export.h" 20 21 #include "XmlExportable.h" 22 #include "Instrument.h" 23 #include "Device.h" 24 25 #include <string> 26 27 28 namespace Rosegarden 29 { 30 31 32 class Composition; 33 34 typedef unsigned int TrackId; 35 constexpr TrackId NoTrack = 0xDEADBEEF; 36 37 /// Representation of a Track. 38 /** 39 * A Track represents a line on the SegmentCanvas on the 40 * Rosegarden GUI. A Track is owned by a Composition and 41 * has reference to an Instrument from which the playback 42 * characteristics of the Track can be derived. A Track 43 * has no type (Audio or MIDI) itself - the type comes only from the 44 * Instrument relationship. 45 * 46 */ 47 class ROSEGARDENPRIVATE_EXPORT Track : public XmlExportable 48 { 49 public: 50 Track(TrackId id, 51 InstrumentId instrument = 0, 52 int position = 0, 53 const std::string &label = "", 54 bool muted = false); ~Track()55 ~Track() override { } 56 57 // Accessors/Mutators 58 getId()59 TrackId getId() const { return m_id; } 60 setMuted(bool muted)61 void setMuted(bool muted) { m_muted = muted; } isMuted()62 bool isMuted() const { return m_muted; } 63 setArchived(bool archived)64 void setArchived(bool archived) { m_archived = archived; } isArchived()65 bool isArchived() const { return m_archived; } 66 setSolo(bool solo)67 void setSolo(bool solo) { m_solo = solo; } isSolo()68 bool isSolo() const { return m_solo; } 69 setPosition(int position)70 void setPosition(int position) { m_position = position; } getPosition()71 int getPosition() const { return m_position; } 72 setLabel(const std::string & label)73 void setLabel(const std::string &label) { m_label = label; } getLabel()74 std::string getLabel() const { return m_label; } 75 setShortLabel(const std::string & shortLabel)76 void setShortLabel(const std::string &shortLabel) 77 { m_shortLabel = shortLabel; } getShortLabel()78 std::string getShortLabel() const { return m_shortLabel; } 79 80 void setPresetLabel(const std::string &label); getPresetLabel()81 std::string getPresetLabel() const { return m_presetLabel; } 82 83 void setInstrument(InstrumentId instrument); getInstrument()84 InstrumentId getInstrument() const { return m_instrument; } 85 86 // For Composition use only setOwningComposition(Composition * comp)87 void setOwningComposition(Composition *comp) { m_owningComposition = comp; } getOwningComposition()88 Composition *getOwningComposition() { return m_owningComposition; } 89 90 void setMidiInputDevice(DeviceId id); getMidiInputDevice()91 DeviceId getMidiInputDevice() const { return m_input_device; } 92 93 void setMidiInputChannel(char ic); getMidiInputChannel()94 char getMidiInputChannel() const { return m_input_channel; } 95 96 enum ThruRouting { Auto, On, Off, WhenArmed }; 97 void setThruRouting(ThruRouting thruRouting); getThruRouting()98 ThruRouting getThruRouting() const { return m_thruRouting; } 99 getClef()100 int getClef() const { return m_clef; } setClef(int clef)101 void setClef(int clef) { m_clef = clef; } 102 getTranspose()103 int getTranspose() const { return m_transpose; } setTranspose(int transpose)104 void setTranspose(int transpose) { m_transpose = transpose; } 105 getColor()106 int getColor() const { return m_color; } setColor(int color)107 void setColor(int color) { m_color = color; } 108 getHighestPlayable()109 int getHighestPlayable() const { return m_highestPlayable; } setHighestPlayable(int pitch)110 void setHighestPlayable(int pitch) { m_highestPlayable = pitch; } 111 getLowestPlayable()112 int getLowestPlayable() const { return m_lowestPlayable; } setLowestPlayable(int pitch)113 void setLowestPlayable(int pitch) { m_lowestPlayable = pitch; } 114 115 // Controls size of exported staff in LilyPond getStaffSize()116 int getStaffSize() const { return m_staffSize; } setStaffSize(int index)117 void setStaffSize(int index) { m_staffSize = index; } 118 119 // Staff bracketing in LilyPond getStaffBracket()120 int getStaffBracket() const { return m_staffBracket; } setStaffBracket(int index)121 void setStaffBracket(int index) { m_staffBracket = index; } 122 isArmed()123 bool isArmed() const { return m_armed; } 124 /// This routine should only be called by Composition::setTrackRecording(). 125 /** 126 * Composition maintains a list of tracks that are recording. Calling 127 * this routine directly will bypass that. 128 */ setArmed(bool armed)129 void setArmed(bool armed) { m_armed = armed; } 130 131 132 // XmlExportable override. 133 134 /// For writing. See RoseXmlHandler for reading. 135 std::string toXmlString() const override; 136 137 private: 138 // Hide copy ctor and op=. 139 Track(const Track &); 140 Track operator=(const Track &); 141 142 //--------------- Data members --------------------------------- 143 144 TrackId m_id; 145 bool m_muted; 146 bool m_archived; 147 bool m_solo; 148 std::string m_label; 149 std::string m_shortLabel; 150 std::string m_presetLabel; 151 int m_position; 152 InstrumentId m_instrument; 153 154 Composition *m_owningComposition; 155 156 DeviceId m_input_device; 157 char m_input_channel; 158 ThruRouting m_thruRouting; 159 bool m_armed; 160 161 // default parameters for new segments created belonging to this track 162 int m_clef; 163 int m_transpose; 164 int m_color; 165 int m_highestPlayable; 166 int m_lowestPlayable; 167 168 // staff parameters for LilyPond export 169 int m_staffSize; 170 int m_staffBracket; 171 }; 172 173 174 } 175 176 #endif // RG_TRACK_H 177