Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3772)

Delta Between Two Patch Sets: python/musicexp.py

Issue 328050043: Change \note markup command to get a duration
Left Patch Set: Created 7 years, 8 months ago
Right Patch Set: Run scripts/auxiliar/update-with-convert-ly.sh Created 7 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « python/convertrules.py ('k') | scm/define-markup-commands.scm » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 import inspect 2 import inspect
3 import sys 3 import sys
4 import string 4 import string
5 import re 5 import re
6 import math 6 import math
7 import lilylib as ly 7 import lilylib as ly
8 import warnings 8 import warnings
9 import utilities 9 import utilities
10 10
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 else: 614 else:
615 num = "#f" 615 num = "#f"
616 if self.display_denominator: 616 if self.display_denominator:
617 den = self.display_denominator 617 den = self.display_denominator
618 else: 618 else:
619 den = "#f" 619 den = "#f"
620 base_number_function = "(tuplet-number::non-default-tuplet-fraction- text %s %s)" % (den, num) 620 base_number_function = "(tuplet-number::non-default-tuplet-fraction- text %s %s)" % (den, num)
621 621
622 622
623 if self.display_type == "actual" and self.normal_type: 623 if self.display_type == "actual" and self.normal_type:
624 # Obtain the note duration in scheme-mode, i.e. \longa as \\longa 624 base_duration = self.normal_type.lisp_expression ()
625 base_duration = self.normal_type.ly_expression (None, True) 625 func ("\\once \\override TupletNumber.text = #(tuplet-number::append -note-wrapper %s %s)" %
626 func ("\\once \\override TupletNumber.text = #(tuplet-number::append -note-wrapper %s \"%s\")" %
627 (base_number_function, base_duration)) 626 (base_number_function, base_duration))
628 func.newline () 627 func.newline ()
629 elif self.display_type == "both": # TODO: Implement this using actual_ty pe and normal_type! 628 elif self.display_type == "both": # TODO: Implement this using actual_ty pe and normal_type!
630 if self.display_number == None: 629 if self.display_number == None:
631 func ("\\once \\omit TupletNumber") 630 func ("\\once \\omit TupletNumber")
632 func.newline () 631 func.newline ()
633 elif self.display_number == "both": 632 elif self.display_number == "both":
634 den_duration = self.normal_type.ly_expression (None, True) 633 den_duration = self.normal_type.lisp_expression ()
635 # If we don't have an actual type set, use the normal duration! 634 # If we don't have an actual type set, use the normal duration!
636 if self.actual_type: 635 if self.actual_type:
637 num_duration = self.actual_type.ly_expression (None, True) 636 num_duration = self.actual_type.lisp_expression ()
638 else: 637 else:
639 num_duration = den_duration 638 num_duration = den_duration
640 if (self.display_denominator or self.display_numerator): 639 if (self.display_denominator or self.display_numerator):
641 func ("\\once \\override TupletNumber.text = #(tuplet-number ::non-default-fraction-with-notes %s \"%s\" %s \"%s\")" % 640 func ("\\once \\override TupletNumber.text = #(tuplet-number ::non-default-fraction-with-notes %s %s %s %s)" %
642 (self.display_denominator, den_duration, 641 (self.display_denominator, den_duration,
643 self.display_numerator, num_duration)) 642 self.display_numerator, num_duration))
644 func.newline () 643 func.newline ()
645 else: 644 else:
646 func ("\\once \\override TupletNumber.text = #(tuplet-number ::fraction-with-notes \"%s\" \"%s\")" % 645 func ("\\once \\override TupletNumber.text = #(tuplet-number ::fraction-with-notes %s %s)" %
647 (den_duration, num_duration)) 646 (den_duration, num_duration))
648 func.newline () 647 func.newline ()
649 else: 648 else:
650 if self.display_number == None: 649 if self.display_number == None:
651 func ("\\once \\omit TupletNumber") 650 func ("\\once \\omit TupletNumber")
652 func.newline () 651 func.newline ()
653 elif self.display_number == "both": 652 elif self.display_number == "both":
654 func ("\\once \\override TupletNumber.text = #%s" % base_number_ function) 653 func ("\\once \\override TupletNumber.text = #%s" % base_number_ function)
655 func.newline () 654 func.newline ()
656 655
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 def set_new_duration (self, dur): 1987 def set_new_duration (self, dur):
1989 self.newduration = dur 1988 self.newduration = dur
1990 def set_beats_per_minute (self, beats): 1989 def set_beats_per_minute (self, beats):
1991 self.beats = beats 1990 self.beats = beats
1992 def set_parentheses (self, parentheses): 1991 def set_parentheses (self, parentheses):
1993 self.parentheses = parentheses 1992 self.parentheses = parentheses
1994 def wait_for_note (self): 1993 def wait_for_note (self):
1995 return False 1994 return False
1996 def duration_to_markup (self, dur): 1995 def duration_to_markup (self, dur):
1997 if dur: 1996 if dur:
1998 # Generate the markup to print the note, use scheme mode for 1997 # Generate the markup to print the note
1999 # ly_expression to get longa and not \longa (which causes an error) 1998 return "\\general-align #Y #DOWN \\smaller \\note {%s} #UP" % dur.ly _expression ()
2000 return "\\general-align #Y #DOWN \\smaller \\note #\"%s\" #UP" % dur .ly_expression(None, True)
2001 else: 1999 else:
2002 return '' 2000 return ''
2003 def tempo_markup_template (self): 2001 def tempo_markup_template (self):
2004 return "\\mark\\markup { \\fontsize #-2 \\line { %s } }" 2002 return "\\mark\\markup { \\fontsize #-2 \\line { %s } }"
2005 def ly_expression (self): 2003 def ly_expression (self):
2006 res = '' 2004 res = ''
2007 if not self.baseduration: 2005 if not self.baseduration:
2008 return res 2006 return res
2009 if self.beats: 2007 if self.beats:
2010 if self.parentheses: 2008 if self.parentheses:
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
2509 expr = test_expr() 2507 expr = test_expr()
2510 expr.set_start (Rational (0)) 2508 expr.set_start (Rational (0))
2511 print expr.ly_expression() 2509 print expr.ly_expression()
2512 start = Rational (0, 4) 2510 start = Rational (0, 4)
2513 stop = Rational (4, 2) 2511 stop = Rational (4, 2)
2514 def sub(x, start=start, stop=stop): 2512 def sub(x, start=start, stop=stop):
2515 ok = x.start >= start and x.start + x.get_length() <= stop 2513 ok = x.start >= start and x.start + x.get_length() <= stop
2516 return ok 2514 return ok
2517 2515
2518 print expr.lisp_sub_expression(sub) 2516 print expr.lisp_sub_expression(sub)
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b