Beispiel #1
0
 def _get_staff_info(self, staff):
     options_block = correct_indent(self._typeset_staff_options(staff), 0)
     parts = ['{',
              " "*4 + '\clef {}'.format(staff.clef),
              correct_indent(staff.music_expr, 4),
              '}']
     return StaffInfo('\n'.join(parts), staff.instrument_name, options_block=options_block)
 def typeset_staffs(self, staff_info_list):
     staffs = '\n'.join([s.typeset_staff(True) for s in staff_info_list])
     return correct_indent(correct_indent(r'''
         <<
         {staffs}
         >>
     ''', 0).format(staffs=correct_indent(staffs, 4)), 16)
Beispiel #3
0
    def typeset_staffs(self, staff_info_list):
        layout = '\n<<'

        former_is_piano = False

        for staff_info in staff_info_list:
            is_piano_staff = 'piano' in staff_info.instrument_name.lower()

            if is_piano_staff and not former_is_piano:
                layout += '\\new PianoStaff <<'
                layout += r'\set PianoStaff.instrumentName = #"Piano"'

            layout += correct_indent(
                staff_info.typeset_staff(
                    display_instrument_name=not is_piano_staff), 4)

            if former_is_piano:
                layout += '>>'
                former_is_piano = False
            else:
                if is_piano_staff:
                    former_is_piano = True

        layout += '\n>>'
        return correct_indent(layout, 16)
Beispiel #4
0
    def typeset_staff(self, display_instrument_name=False):
        """Typeset this staff

        Args:
            display_instrument_name (str): if we want to display the instrument name or not

        Returns:
            str: the typeset staff
        """
        instrument = ''
        if display_instrument_name:
            instrument = '\set Staff.instrumentName = #"{} "'.format(
                self.instrument_name)

        return correct_indent(
            r'''
            \new Staff
            <<
            {instrument}
            {options}
            {music}
            >>
        ''', 0).format(instrument=correct_indent(instrument, 4),
                       options=correct_indent(self.options_block, 4),
                       music=correct_indent(self.music_block, 4))
Beispiel #5
0
 def typeset_staffs(self, staff_info_list):
     staffs = '\n'.join([s.typeset_staff(True) for s in staff_info_list])
     return correct_indent(
         correct_indent(
             r'''
         <<
         {staffs}
         >>
     ''', 0).format(staffs=correct_indent(staffs, 4)), 16)
    def typeset_staffs(self, staff_info_list):
        staffs = '\n'.join([s.typeset_staff(False) for s in staff_info_list])

        return correct_indent(correct_indent(r'''
            \new PianoStaff
            <<
            {staffs}
            >>
            \layout {{
                indent = 0\mm
            }}
        ''', 0).format(staffs=correct_indent(staffs, 4)), 16)
Beispiel #7
0
    def typeset_staffs(self, staff_info_list):
        staffs = '\n'.join([s.typeset_staff(False) for s in staff_info_list])

        return correct_indent(
            correct_indent(
                r'''
            \new PianoStaff
            <<
            {staffs}
            >>
            \layout {{
                indent = 0\mm
            }}
        ''', 0).format(staffs=correct_indent(staffs, 4)), 16)
Beispiel #8
0
    def typeset(self):
        staffs = []
        midi_instrument_names = []

        for ind, staff in enumerate(self.staffs):
            instrument_name = self._get_midi_option(ind, 'instrument')

            midi_instrument_names.append(instrument_name)

            staff_options = ['midiMinimumVolume = #{}'.format(self._get_midi_option(ind, 'min_volume')),
                             'midiMaximumVolume = #{}'.format(self._get_midi_option(ind, 'max_volume')),
                             'midiInstrument = #"{}" '.format(instrument_name)]
            staffs.append(correct_indent(self._typeset_staff(staff, staff_options), 20))

        typeset = r'''
            \score {{
                \unfoldRepeats
                \articulate
                \new GrandStaff
                <<
                    {staffs}
                >>
                \midi {{ }}
            }}
        '''.format(staffs="\n".join(staffs)[20:])

        return LilypondScore(self._title, typeset, is_midi_score=True, midi_instruments=midi_instrument_names)
Beispiel #9
0
 def _get_header(self):
     title = ' '
     if self.show_title:
         title = self.title
     return correct_indent(r'''
         \header{{
             title = "{}"
             tagline = ""
         }}
     '''.format(title), 0)
    def typeset_staffs(self, staff_info_list):
        layout = '\n<<'

        former_is_piano = False

        for staff_info in staff_info_list:
            is_piano_staff = 'piano' in staff_info.instrument_name.lower()

            if is_piano_staff and not former_is_piano:
                layout += '\\new PianoStaff <<'
                layout += r'\set PianoStaff.instrumentName = #"Piano"'

            layout += correct_indent(staff_info.typeset_staff(display_instrument_name=not is_piano_staff), 4)

            if former_is_piano:
                layout += '>>'
                former_is_piano = False
            else:
                if is_piano_staff:
                    former_is_piano = True

        layout += '\n>>'
        return correct_indent(layout, 16)
    def typeset_staff(self, display_instrument_name=False):
        """Typeset this staff

        Args:
            display_instrument_name (str): if we want to display the instrument name or not

        Returns:
            str: the typeset staff
        """
        instrument = ''
        if display_instrument_name:
            instrument = '\set Staff.instrumentName = #"{} "'.format(self.instrument_name)

        return correct_indent(r'''
            \new Staff
            <<
            {instrument}
            {options}
            {music}
            >>
        ''', 0).format(instrument=correct_indent(instrument, 4),
                       options=correct_indent(self.options_block, 4),
                       music=correct_indent(self.music_block, 4))
Beispiel #12
0
    def _get_paper_settings(self):
        parts = ['\paper {']

        if self.page_limit is not None:
            parts.append("\t" + 'page-count = {}'.format(self.page_limit))

        if self.ragged_right is not None:
            parts.append("\t" + 'ragged-right = ##{}'.format('t' if self.ragged_right else 'f'))

        parts.append(correct_indent(r'''
            print-all-headers = ##t
            score-markup-spacing = #'((basic-distance . 10))
            markup-system-spacing #'minimum-distance = 0

            scoreTitleMarkup = \markup {
                \override #'(baseline-skip . 10) %% changes the distance between title/subtitle and composer/arranger
                \column {
                    \override #'(baseline-skip . 3.5)
                    \column {
                        \huge \larger \bold
                        \fill-line {
                            \larger \fromproperty #'header:title
                        }
                        \fill-line {
                            \large \smaller \bold
                            \larger \fromproperty #'header:subtitle
                        }
                        \fill-line {
                            \smaller \bold
                            \fromproperty #'header:subsubtitle
                        }
                    }
                    \override #'(baseline-skip . 3.5)
                    \column {
                        \fill-line {
                            \fromproperty #'header:poet
                            { \large \bold \fromproperty #'header:instrument }
                            \fromproperty #'header:composer
                        }
                        \fill-line {
                            \fromproperty #'header:piece
                            \fromproperty #'header:meter
                            \fromproperty #'header:arranger
                        }
                    }
                }
            }''', 4))
        parts.append('}')
        return "\n".join(parts)
Beispiel #13
0
    def typeset(self):
        """Typeset the book.

        Returns:
            LilypondBook: the lilypond book
        """
        parts = ['\\version "{}"'.format(self._lilypond_version),
                 '\include "articulate.ly"',
                 self._get_paper_settings(),
                 self._get_header()]

        for score in self._scores:
            parts.append(correct_indent(score.score, 0))

        parts.append("\n".join(comment.to_lilypond() for comment in self.comments))
        return LilypondBook(self._scores, self.title, "\n".join(parts))
Beispiel #14
0
    def _typeset_staff(self, staff, staff_options=None):
        options = ''
        if staff_options:
            options = r'''
                \with {{
                    {options}
                }}'''.format(options=correct_indent("\n".join(staff_options), 20)[20:])

        staff_settings = correct_indent(self._typeset_staff_options(staff), 8)

        typeset = correct_indent(r'''
            \new Staff
                {options}
            <<
                {staff_settings}
                {{
                    \clef {clef}
                    {music_expr}
                }}
            >>
        '''.format(options=correct_indent(options, 16), staff_settings=correct_indent(staff_settings, 16),
                   clef=staff.clef, music_expr=correct_indent(staff.music_expr, 20)[20:]), 12)
        return typeset