summaryrefslogtreecommitdiffstats
path: root/src/base/Track.h
blob: bcded51a9092d04ad0fdeb9df56cfc31ddb10cea (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// -*- c-basic-offset: 4 -*-

/*
    Rosegarden
    A sequencer and musical notation editor.

    This program is Copyright 2000-2008
        Guillaume Laurent   <[email protected]>,
        Chris Cannam        <[email protected]>,
        Richard Bown        <[email protected]>

    The moral right of the authors to claim authorship of this work
    has been asserted.

    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; either version 2 of the
    License, or (at your option) any later version.  See the file
    COPYING included with this distribution for more information.
*/

// Representation of a Track
//
//


#ifndef _TRACK_H_
#define _TRACK_H_

#include <string>

#include "XmlExportable.h"
#include "Instrument.h"
#include "Device.h"

namespace Rosegarden
{
class Composition;

typedef unsigned int TrackId;

/**
 * A Track represents a line on the SegmentCanvas on the
 * Rosegarden GUI.  A Track is owned by a Composition and
 * has reference to an Instrument from which the playback
 * characteristics of the Track can be derived.  A Track
 * has no type itself - the type comes only from the
 * Instrument relationship.
 *
 */
class Track : public XmlExportable
{
    friend class Composition;

public:
    Track();
    Track(TrackId id,
          InstrumentId instrument = 0,
          int position =0 ,
          const std::string &label = "",
          bool muted = false);

    void setId(TrackId id) { m_id = id; }

private:
    Track(const Track &);
    Track operator=(const Track &);

public:

    ~Track();

    TrackId getId() const { return m_id; }

    void setMuted(bool muted);
    bool isMuted() const { return m_muted; }

    void setPosition(int position) { m_position = position; }
    int getPosition() const { return m_position; }

    void setLabel(const std::string &label);
    std::string getLabel() const { return m_label; }

    void setPresetLabel(const std::string &label);
    std::string getPresetLabel() const { return m_presetLabel; }

    void setInstrument(InstrumentId instrument);
    InstrumentId getInstrument() const { return m_instrument; }

    // Implementation of virtual
    //
    virtual std::string toXmlString();

    Composition* getOwningComposition() { return m_owningComposition; }

    void setMidiInputDevice(DeviceId id);
    DeviceId getMidiInputDevice() const { return m_input_device; }

    void setMidiInputChannel(char ic);
    char getMidiInputChannel() const { return m_input_channel; }

    int getClef() { return m_clef; }
    void setClef(int clef) { m_clef = clef; }

    int getTranspose() { return m_transpose; }
    void setTranspose(int transpose) { m_transpose = transpose; }

    int getColor() { return m_color; }
    void setColor(int color) { m_color = color; }

    int getHighestPlayable() { return m_highestPlayable; }
    void setHighestPlayable(int pitch) { m_highestPlayable = pitch; }
    
    int getLowestPlayable() { return m_lowestPlayable; }
    void setLowestPlayable(int pitch) { m_lowestPlayable = pitch; }

    // Controls size of exported staff in LilyPond
    int getStaffSize() { return m_staffSize; }
    void setStaffSize(int index) { m_staffSize = index; }
    
    // Staff bracketing in LilyPond
    int getStaffBracket() { return m_staffBracket; }
    void setStaffBracket(int index) { m_staffBracket = index; }
    
    bool isArmed() const { return m_armed; }
    void setArmed(bool armed);

protected: // For Composition use only
    void setOwningComposition(Composition* comp) { m_owningComposition = comp; }

private:
    //--------------- Data members ---------------------------------

    TrackId        m_id;
    bool           m_muted;
    std::string    m_label;
    std::string    m_presetLabel;
    int            m_position;
    InstrumentId   m_instrument;

    Composition*   m_owningComposition;

    DeviceId       m_input_device;
    char           m_input_channel;
    bool           m_armed;

    // default parameters for new segments created belonging to this track
    int            m_clef;
    int            m_transpose;
    int            m_color;
    int            m_highestPlayable;
    int            m_lowestPlayable;

    // staff parameters for LilyPond export
    int            m_staffSize;
    int            m_staffBracket;
};

}

#endif // _TRACK_H_