1# This file is part of the Frescobaldi project, http://www.frescobaldi.org/ 2# 3# Copyright (c) 2008 - 2014 by Wilbert Berendsen 4# 5# This program is free software; you can redistribute it and/or 6# modify it under the terms of the GNU General Public License 7# as published by the Free Software Foundation; either version 2 8# of the License, or (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program; if not, write to the Free Software 17# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18# See http://www.gnu.org/licenses/ for more information. 19 20""" 21String part types. 22""" 23 24 25import ly.dom 26 27from . import _base 28from . import register 29 30 31class StringPart(_base.SingleVoicePart): 32 """Base class for string part types.""" 33 34 35class Violin(StringPart): 36 @staticmethod 37 def title(_=_base.translate): 38 return _("Violin") 39 40 @staticmethod 41 def short(_=_base.translate): 42 return _("abbreviation for Violin", "Vl.") 43 44 midiInstrument = 'violin' 45 46 47class Viola(StringPart): 48 @staticmethod 49 def title(_=_base.translate): 50 return _("Viola") 51 52 @staticmethod 53 def short(_=_base.translate): 54 return _("abbreviation for Viola", "Vla.") 55 56 midiInstrument = 'viola' 57 clef = 'alto' 58 octave = 0 59 60 61class Cello(StringPart): 62 @staticmethod 63 def title(_=_base.translate): 64 return _("Cello") 65 66 @staticmethod 67 def short(_=_base.translate): 68 return _("abbreviation for Cello", "Cl.") 69 70 midiInstrument = 'cello' 71 clef = 'bass' 72 octave = -1 73 74 75class Contrabass(StringPart): 76 @staticmethod 77 def title(_=_base.translate): 78 return _("Contrabass") 79 80 @staticmethod 81 def short(_=_base.translate): 82 return _("abbreviation for Contrabass", "Cb.") 83 84 midiInstrument = 'contrabass' 85 clef = 'bass' 86 octave = -1 87 88 89class BassoContinuo(Cello): 90 @staticmethod 91 def title(_=_base.translate): 92 return _("Basso Continuo") 93 94 @staticmethod 95 def short(_=_base.translate): 96 return _("abbreviation for Basso Continuo", "B.c.") 97 98 def build(self, data, builder): 99 super(BassoContinuo, self).build(data, builder) 100 data.assignments[0].name.name = 'bcMusic' 101 a = data.assign('bcFigures') 102 b = ly.dom.FigureMode(a) 103 ly.dom.Identifier(data.globalName, b) 104 ly.dom.Line("\\override Staff.BassFigureAlignmentPositioning " 105 "#'direction = #DOWN", b) 106 ly.dom.LineComment(_("Figures follow here."), b) 107 ly.dom.BlankLine(b) 108 figbass = ly.dom.FiguredBass() 109 ly.dom.Identifier(a.name, figbass) 110 data.nodes.append(figbass) 111 112 113register( 114 lambda: _("Strings"), 115 [ 116 Violin, 117 Viola, 118 Cello, 119 Contrabass, 120 BassoContinuo, 121 ]) 122 123 124 125 126