Get a Note object and return the LilyPond equivalent in a string. If process_octaves is set to False, all data regarding octaves will be ignored. If standalone is True, the result can be used by functions like to_png and will produce a valid output. The argument is mostly here to le
(note, process_octaves=True, standalone=True)
| 35 | |
| 36 | |
| 37 | def from_Note(note, process_octaves=True, standalone=True): |
| 38 | """Get a Note object and return the LilyPond equivalent in a string. |
| 39 | |
| 40 | If process_octaves is set to False, all data regarding octaves will be |
| 41 | ignored. If standalone is True, the result can be used by functions |
| 42 | like to_png and will produce a valid output. The argument is mostly here |
| 43 | to let from_NoteContainer make use of this function. |
| 44 | """ |
| 45 | # Throw exception |
| 46 | if not hasattr(note, "name"): |
| 47 | return False |
| 48 | |
| 49 | # Lower the case of the name |
| 50 | result = note.name[0].lower() |
| 51 | |
| 52 | # Convert #'s and b's to 'is' and 'es' suffixes |
| 53 | for accidental in note.name[1:]: |
| 54 | if accidental == "#": |
| 55 | result += "is" |
| 56 | elif accidental == "b": |
| 57 | result += "es" |
| 58 | |
| 59 | # Place ' and , for octaves |
| 60 | if process_octaves: |
| 61 | oct = note.octave |
| 62 | if oct >= 4: |
| 63 | while oct > 3: |
| 64 | result += "'" |
| 65 | oct -= 1 |
| 66 | elif oct < 3: |
| 67 | while oct < 3: |
| 68 | result += "," |
| 69 | oct += 1 |
| 70 | if standalone: |
| 71 | return "{ %s }" % result |
| 72 | else: |
| 73 | return result |
| 74 | |
| 75 | |
| 76 | def from_NoteContainer(nc, duration=None, standalone=True): |
no outgoing calls
no test coverage detected