summaryrefslogtreecommitdiffstats
path: root/src/gui/general/ClefIndex.cpp
blob: 3ecf004c018564d080664cceacad6fcc1eb2fcda (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
/*
    Rosegarden
    A sequencer and musical notation editor.

    This program is Copyright 2000-2008
        Guillaume Laurent   <glaurent@telegraph-road.org>,
        Chris Cannam        <cannam@all-day-breakfast.com>,
        Richard Bown        <bownie@bownie.com>

    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.
*/

#include "gui/general/ClefIndex.h"
#include "misc/Debug.h"

namespace Rosegarden
{

const Rosegarden::Clef clefIndexToClef(int index)
{
	Rosegarden::Clef clef;

    // insert an initial clef from track parameters
    switch (index) {
    case TrebleClef:       clef = Clef(Clef::Treble);       break;
    case BassClef:         clef = Clef(Clef::Bass);         break;
    case CrotalesClef:     clef = Clef(Clef::Treble, 2);    break;
    case XylophoneClef:    clef = Clef(Clef::Treble, 1);    break;
    case GuitarClef:       clef = Clef(Clef::Treble, -1);   break;
    case ContrabassClef:   clef = Clef(Clef::Bass, -1);     break;
    case CelestaClef:      clef = Clef(Clef::Bass, 2);      break;
    case OldCelestaClef:   clef = Clef(Clef::Bass, 1);      break;
    case FrenchClef:       clef = Clef(Clef::French);       break;
    case SopranoClef:      clef = Clef(Clef::Soprano);      break;
    case MezzosopranoClef: clef = Clef(Clef::Mezzosoprano); break;
    case AltoClef:         clef = Clef(Clef::Alto);         break;
    case TenorClef:        clef = Clef(Clef::Tenor);        break;
    case BaritoneClef:     clef = Clef(Clef::Baritone);     break;
    case VarbaritoneClef:  clef = Clef(Clef::Varbaritone);  break;
    case SubbassClef:      clef = Clef(Clef::Subbass);      break;
    default:               clef = Clef(Clef::Treble);       break;
    }
    return clef;
}

const int clefNameToClefIndex(TQString s)
{
    int m_elClef = 0;
	if (!s.isNull()) {
        if (s == "treble")
            m_elClef = TrebleClef;
        else if (s == "bass")
            m_elClef = BassClef;
        else if (s == "crotales")
            m_elClef = CrotalesClef;
        else if (s == "xylophone")
            m_elClef = XylophoneClef;
        else if (s == "guitar")
            m_elClef = GuitarClef;
        else if (s == "contrabass")
            m_elClef = ContrabassClef;
        else if (s == "celesta")
            m_elClef = CelestaClef;
        else if (s == "oldCelesta")
            m_elClef = OldCelestaClef;
        else if (s == "french")
            m_elClef = FrenchClef;
        else if (s == "soprano")
            m_elClef = SopranoClef;
        else if (s == "mezzosoprano")
            m_elClef = MezzosopranoClef;
        else if (s == "alto")
            m_elClef = AltoClef;
        else if (s == "tenor")
            m_elClef = TenorClef;
        else if (s == "baritone")
            m_elClef = BaritoneClef;
        else if (s == "varbaritone")
            m_elClef = VarbaritoneClef;
        else if (s == "subbass")
            m_elClef = SubbassClef;
        else if (s == "two-bar")
            m_elClef = TwoBarClef;
        else {
            RG_DEBUG << "startElement: processed unrecognized clef type: " << s << endl;
        }
	}
    return m_elClef;
}

}