Open dt-woods opened 3 years ago
See also abcnotation and LilyPond
On the discussion of ABC notation versus lilly pond.
Trying mingus. See here for documentation.
setup.py
in virtual environment: got mingus to workThe online tutorials are weird, but basically works.
import mingus.extra.lilypond as LilyPond
b = Bar()
b + "C"
b + "E"
b + "G"
b + "B"
LilyPond.from_Bar(b) # "{ \\time 4/4 \\key c \\major c'4 e'4 g'4 b'4 }"
Note that the Note class also exists in LilyPond
print(LilyPond.Note().from_hertz(440)) # prints 'A-4'
Yes, and we can map keys to treble clef using LilyPond notation.
c' # middle C
LOL. Mingus can basically replace our utilities.py
from mingus.containers import Note
print(Note().from_hertz(215)) # prints A-3
c = Note().from_hertz(261)
c.note # prints C
c.octave # prints 4
The issue is when the peak frequency is zero, which presently is set to REST
; therefore, we still need the get_note
function and at least one if-statement.
Notice that erroneous frequency values to the Note().from_hertz()
function throw a ValueError
, which can be caught in a try-except block.
Notice that mingus assumes a default standard pitch is 440 (the A-4).
This works for now:
import mingus.extra.lilypond as LilyPond
from mingus.containers import Bar
from mingus.containers import Note
mb = Bar()
mb.place_notes(Note().from_hertz(440), 4) # assume quarter notes
mb.place_notes(Note().from_hertz(880), 4)
LilyPond.from_Bar(mb, False, False) # save this to an .ly file
Is there a way to write notes in a sheet music format?