Exemplo n.º 1
0
def update_sheet_music(note):
    dict_note = notes_dict[note]
    t.add_notes(dict_note)
    track = LilyPond.from_Track(t)
    LilyPond.to_png(track, "track")
    img = mpimg.imread("track.png")
    cropped_image = img[0:300, :, :]
    sheet.set_data(cropped_image)
Exemplo n.º 2
0
 def test_to_png(self):
     self.assert_(
         LilyPond.to_png(
             '{ %s }' %
             LilyPond.from_NoteContainer(NoteContainer('C'), value.dots(8)),
             'pn1'))
     self.assert_(LilyPond.to_png(LilyPond.from_Bar(self.tbar), 'pn2'))
     self.assert_(LilyPond.to_png(LilyPond.from_Bar(self.mbar), 'pn3'))
Exemplo n.º 3
0
 def test_to_png(self):
     self.assertTrue(
         LilyPond.to_png(
             "{ %s }" %
             LilyPond.from_NoteContainer(NoteContainer("C"), value.dots(8)),
             "pn1",
         ))
     self.assertTrue(LilyPond.to_png(LilyPond.from_Bar(self.tbar), "pn2"))
     self.assertTrue(LilyPond.to_png(LilyPond.from_Bar(self.mbar), "pn3"))
Exemplo n.º 4
0
def stopPlaying():
    x.do_run = False
    n = getattr(x, "notes")
    b = mingus.containers.Bar()
    track = mingus.containers.Track()
    if (len(n) == 0):
        return "No file"
    for i in n:
        track.add_notes(i)
    trackString = lilypond.from_Track(track)
    lilypond.to_png(trackString, "MasterPiece" + str(len(n)))
    time.sleep(3)
    filename = 'MasterPiece' + str(len(n)) + '.png'
    return send_file(filename, mimetype='image/PNG')
Exemplo n.º 5
0
def setup_plotting():
    global fig
    global ax1
    global ax2
    global ax3
    global line1
    global line2
    global sheet

    fig = plt.figure(figsize=(12, 8))
    ax1 = fig.add_subplot(2, 2, 1)  # Volume
    ax2 = fig.add_subplot(2, 2, 2)  # Fourier
    ax3 = fig.add_subplot(2, 1, 2)  # Notes
    ax3.set_axis_off()

    line1, = ax1.plot(np.random.randn(CHUNK_SIZE))
    line2, = ax2.plot(np.random.randn(CHUNK_SIZE))

    b = Bar()
    bar = LilyPond.from_Bar(b)
    LilyPond.to_png(bar, "track")
    img = mpimg.imread("track.png")
    cropped_image = img[0:300, :, :]
    sheet = ax3.imshow(cropped_image, cmap='gray', interpolation='antialiased')
Exemplo n.º 6
0
            for mode_func in MODE_CHORD_FUNCTIONS
        ]
        print(', '.join(chords))

    elif args.action == '12_bar_blues':
        for four_bars in twelve_bar_blues(args.key):
            print('\t'.join(four_bars))

    elif args.action == 'blues_scale':
        print("{} blues scale: {}".format(args.key,
                                          ', '.join(blues_scale(args.key))))

    elif args.action == '12_bar_blues_printout':
        from mingus.containers.note import QuarterNoteFactory as Q
        from mingus.core.chords import WholNoteChordFactory as WNC
        blues_scale = Blues(args.key)
        bar = Bar()
        bar.extend(
            Q(
                list(
                    blues_scale.generate(4 * 12,
                                         undulating=True,
                                         starting_octave=4))))
        bar.set_chord_notes([
            WNC(chord)
            for chord in twelve_bar_blues_chord_progression(args.key)
        ])
        result = from_Bar(bar)
        print(result)
        to_png(result, args.filename)
Exemplo n.º 7
0
 def test_to_png(self):
     self.assert_(LilyPond.to_png('{ %s }'
                   % LilyPond.from_NoteContainer(NoteContainer('C'),
                  value.dots(8)), 'pn1'))
     self.assert_(LilyPond.to_png(LilyPond.from_Bar(self.tbar), 'pn2'))
     self.assert_(LilyPond.to_png(LilyPond.from_Bar(self.mbar), 'pn3'))
Exemplo n.º 8
0
 def test_to_png(self):
     self.assert_(LilyPond.to_png("{ %s }" % LilyPond.from_NoteContainer(NoteContainer("C"), value.dots(8)), "pn1"))
     self.assert_(LilyPond.to_png(LilyPond.from_Bar(self.tbar), "pn2"))
     self.assert_(LilyPond.to_png(LilyPond.from_Bar(self.mbar), "pn3"))
Exemplo n.º 9
0
combine_test = header + "rhMusic =  {" + LithHarbor_ly_right + "}"
combine_test = combine_test + "lhMusic =  {" + LithHarbor_ly_left + "}"
combine_test = combine_test + """
\\score {
  \\new PianoStaff <<
    \\new Staff = "RH"  <<
      \\rhMusic
    >>
    \\new Staff = "LH" <<
      \\clef "bass"
      \\lhMusic
    >>
  >>
}"""

LilyPond.to_png(combine_test, outputname)  #Create png

#### Create midi file:
#Combine Notes_r and Notes_l from the df into 1 congomerate
combined_notes = []
for i in range(df.shape[0]):
    try:
        combined_notes.append(df.iloc[i]["Notes_l"] + df.iloc[i]["Notes_r"])
    except:
        if df.iloc[i]["Notes_l"] != "":
            combined_notes.append(df.iloc[i]["Notes_l"])
        else:
            combined_notes.append(df.iloc[i]["Notes_r"])
df["Notes_both"] = combined_notes

#Now create a track by adding these notes from both hands
Exemplo n.º 10
0
from mingus.midi import fluidsynth
from mingus.containers import NoteContainer, Note
import mingus.midi.fluidsynth
from mingus.midi import midi_file_in
from mingus.midi import midi_file_out
from mingus.extra import lilypond as lp
import time
import sys
from random import random
import os.path

(m, bpm) = midi_file_in.MIDI_to_Composition("sample/MIDI/PIrate.mid")
midi_file_out.write_Composition("test.mid", m, bpm)

exportpdf = lp.from_Composition(m)
lp.to_png(exportpdf, "PirateTest")

print("TEST")
Exemplo n.º 11
0
def create_sheet(melody):
    sheet = LilyPond.from_Track(melody.notes)
    sheet = LilyPond.to_png(sheet, VIDPIC)
    im = Image.open(VIDPIC)
    im = im.crop((0, 0, 834, 500))
    im.save(VIDPIC)
Exemplo n.º 12
0
        for chord in args.chords:
            chord_notes = chords.from_shorthand(chord)
            new_note = reduce_accidentals(tritone(chord_notes[0]))
            new_chord = new_note + '7'

            ii_chord_type_short, chord = reharmonize_v_to_ii_v(new_chord)
            print("{} {}".format(ii_chord_type_short, new_chord))

    elif args.action == 'chord_modes':
        chords = [chords.determine_seventh(mode_func(args.key), shorthand=True)[0]
                  for mode_func in MODE_CHORD_FUNCTIONS]
        print(', '.join(chords))

    elif args.action == '12_bar_blues':
        for four_bars in twelve_bar_blues(args.key):
            print('\t'.join(four_bars))

    elif args.action == 'blues_scale':
        print("{} blues scale: {}".format(args.key, ', '.join(blues_scale(args.key))))

    elif args.action == '12_bar_blues_printout':
        from mingus.containers.note import QuarterNoteFactory as Q
        from mingus.core.chords import WholNoteChordFactory as WNC
        blues_scale = Blues(args.key)
        bar = Bar()
        bar.extend(Q(list(blues_scale.generate(4*12, undulating=True, starting_octave=4))))
        bar.set_chord_notes([WNC(chord) for chord in twelve_bar_blues_chord_progression(args.key)])
        result = from_Bar(bar)
        print(result)
        to_png(result, args.filename)
Exemplo n.º 13
0
    "V",
    "V",
    "I",
    "I",
]

#getting the chords for the progression
my_chords = progressions.to_chords(my_progression)

#add a 4th note on each chord
my_chords = [my_chord + [my_chord[1]] for my_chord in my_chords]

#grouping notes as 4x4
all_notes = list(itertools.chain(*my_chords))
all_notes_4x4 = chunks(all_notes, 4)

#generating the track
my_track = Track()
for my4notes in all_notes_4x4:
    my_bar = Bar()
    for my_note in my4notes:
        my_bar + my_note
    my_track + my_bar

#exporting
my_lilypond = LilyPond.from_Track(my_track)
_folder = "Scores"
_file = "poc"
_path = os.path.join(_folder, _file)
LilyPond.to_png(my_lilypond, _path)