示例#1
0
def main():
    freqs, freq_to_amp = y.record(5, 2, 10)
    readings = list()
    for reading in freqs:
        cr_reading = y.CustomRound(reading)
        temp = y.clst(reading, 0.98, 1.02)
        temp.sort(key=lambda elem: freq_to_amp[cr_reading(elem)])
        temp2 = temp[-3:]
        temp2.sort()
        readings.append(temp2[-3:])
    chords = y.convList(readings)

    c = abjad.Container()
    time = 1
    prev = chords[0]
    for i in range(len(chords) - 1):
        i += 1
        a = chords[i]
        if prev != a:
            show_chord(prev, time, c)
            prev = a
            time = 1
        else:
            time += 1
    show_chord(chords[-1], time, c)
    abjad.show(c)
示例#2
0
def main():
    objects = (ephem.Mercury(), ephem.Venus(), ephem.Mars(), ephem.Jupiter(),
        ephem.Saturn(), ephem.Uranus(), ephem.Neptune())

    observer = ephem.Observer()
    observer.lat = '57:10'
    observer.lon = '-135:15'

    object_events = []
    for o in objects:
        events = []
        observer.date = START_DATE
        while observer.date < ephem.Date(END_DATE):
            next_rising = observer.next_rising(o)
            next_setting = observer.next_setting(o)
            events.append((next_rising, next_setting, o.earth_distance))
            observer.date = next_setting
        object_events.append(events)


    staves = []
    for object_events in object_events:
        staff = abjad.Staff()
        staves.append(staff)
        current_time = ephem.Date(START_DATE)
        for event_start, event_stop, distance in object_events:
            # add rest to fill time until event start
            rest_duration = get_duration_from_interval(event_start - current_time)
            staff.extend(make_rests(rest_duration))
            note_duration = get_duration_from_interval(event_stop - event_start)
            staff.extend(make_notes(note_duration, get_pitch(distance)))
            current_time = event_stop
    abjad.show(abjad.Score(staves))
示例#3
0
def treble():
    trebleclef = ab.Clef('treble')
    treblestaff = ab.Staff(listnotes(combinedlist))
    ab.attach(trebleclef, treblestaff[0])
    ab.attach(ksignature, treblestaff[0])
    ab.attach(tsignature, treblestaff[0])
    ab.show(treblestaff)
def draw_the_score(time_sec, key_pressed, bpm):

    key_as_abjad_number = convert_key_pressed_to_abjad_number(key_pressed)

    beats, key_temp = how_many_beats(time_sec, key_as_abjad_number, bpm)

    #print(beats)

    beats = [i * 4 for i in beats]

    #print(beats)

    notes = []

    for i in range(len(beats)):
        # note: beats has been scaled up earlier by multiplying by 4!
        duration = abjad.Duration(beats[i], 16)
        if (key_as_abjad_number[i] == 100):
            #notes.append(abjad.Rest('r16'))
            rest = abjad.Rest(duration)
            notes.append(rest)
        else:
            notes.append(abjad.Note(key_as_abjad_number[i], duration))

    staff = abjad.Staff(notes)
    abjad.show(staff)
示例#5
0
文件: demo.py 项目: Abjad/intensive
def show_demo():
    talea = abjad.rhythmmakertools.Talea(
        counts=[1, 2, 3],
        denominator=16,
        )
    tie_specifier = abjad.rhythmmakertools.TieSpecifier(
        tie_across_divisions=True,
        )
    burnish_specifier = abjad.rhythmmakertools.BurnishSpecifier(
        left_classes=(abjad.Rest, abjad.Note),
        left_counts=(1,),
        )
    talea_rhythm_maker = abjad.rhythmmakertools.TaleaRhythmMaker(
        talea=talea,
        extra_counts_per_division=[0, 1, 1],
        burnish_specifier=burnish_specifier,
        tie_specifier=tie_specifier,
        )
    divisions = [(3, 8), (5, 4), (1, 4), (13, 16)]
    score = abjad.Score()
    for i in range(8):
        selections = talea_rhythm_maker(divisions, rotation=i)
        voice = abjad.Voice(selections)
        staff = abjad.Staff([voice], context_name='RhythmicStaff')
        score.append(staff)
        divisions = rotate(divisions, 1)
    lilypond_file = make_sketch_lilypond_file(score)
    abjad.show(lilypond_file)
示例#6
0
def render_score(score, beats, jigs):
    # adapted from https://github.com/Abjad/abjad/blob/5c7f5f7abd8013f99b60c9ceb3a91c771abbca7c/abjad/demos/ligeti/make_desordre_lilypond_file.py
    file = abjad.LilyPondFile.new(score, global_staff_size=18)

    context_block = abjad.ContextBlock(source_context_name='Score')
    file.layout_block.items.append(context_block)
    # for future reference: http://lilypond.org/doc/v2.18/Documentation/learning/engravers-explained.en.html
    context_block.remove_commands.append('Bar_number_engraver')
    context_block.remove_commands.append('Default_bar_line_engraver')
    abjad.override(context_block).clef.transparent = True
    abjad.override(context_block).spacing_spanner.strict_grace_spacing = True
    abjad.override(context_block).spacing_spanner.strict_note_spacing = True
    abjad.override(context_block).spacing_spanner.uniform_stretching = True
    abjad.override(context_block).text_script.staff_padding = 0
    abjad.override(context_block).time_signature.transparent = True
    abjad.override(context_block).rest.transparent = True
    abjad.override(context_block).dots.transparent = True

    file.header_block.tagline = ' '

    file.paper_block.paper_width = beats * 15
    file.paper_block.paper_height = jigs * 20
    file.paper_block.bottom_margin = 0
    file.paper_block.left_margin = 0
    vector = abjad.SpacingVector(0, 0, 15, 0)
    #file.paper_block.system_system_spacing = vector
    abjad.show(file)
示例#7
0
def bass():
    bassclef = ab.Clef('bass')
    bassstaff = ab.Staff(listnotes(combinedlist))
    ab.attach(bassclef, bassstaff[0])
    ab.attach(ksignature, bassstaff[0])
    ab.attach(tsignature, bassstaff[0])
    ab.show(bassstaff)
示例#8
0
文件: melody.py 项目: classam/blurge
 def show(self):
     lilypond_file = abjad.lilypondfiletools.make_basic_lilypond_file(self.score)
     lilypond_file.score_block.append(abjad.lilypondfiletools.MIDIBlock() )
     layout_block = abjad.lilypondfiletools.LayoutBlock()
     layout_block.is_formatted_when_empty = True
     lilypond_file.score_block.append(layout_block)
     
     abjad.show( lilypond_file) 
示例#9
0
def see_pitches(pitches):
    G_staff = abjad.Staff()
    F_staff = abjad.Staff()
    staff_group = abjad.StaffGroup([G_staff, F_staff])
    pitch_range = abjad.pitch.PitchRange("[C4, +inf]")
    for pitch in pitches:
        test = pitch in pitch_range
        if test is True:
            note = abjad.Note.from_pitch_and_duration(pitch, (1, 1))
            G_staff.append(note)
            F_staff.append(abjad.Skip((1, 1)))
        if test is False:
            note = abjad.Note.from_pitch_and_duration(pitch, (1, 1))
            G_staff.append(abjad.Skip((1, 1)))
            F_staff.append(note)

    for i, note in enumerate(F_staff):
        abjad.attach(abjad.Markup(i), note)

    clef3 = abjad.Clef("treble^8")
    clef3_range = abjad.pitch.PitchRange("[G6, +inf]")
    clef2 = abjad.Clef("treble")
    clef2_range = abjad.pitch.PitchRange("[E4, E5]")
    clef1 = abjad.Clef("bass")
    clef1_range = abjad.pitch.PitchRange("[A1, G3]")
    clef0 = abjad.Clef("bass_8")
    clef0_range = abjad.pitch.PitchRange("[-inf, C1]")

    selection = abjad.select(G_staff).leaves()
    for i, leaf in enumerate(selection):
        if isinstance(leaf, abjad.Note):
            test3 = leaf in clef3_range
            test2 = leaf in clef2_range
            if test3 is True:
                abjad.attach(clef3, G_staff[i])
            elif test2 is True:
                abjad.attach(clef2, G_staff[i])

    selection2 = abjad.select(F_staff).leaves()
    for i, leaf in enumerate(selection2):
        if isinstance(leaf, abjad.Note):
            test3 = leaf in clef3_range
            test2 = leaf in clef2_range
            test1 = leaf in clef1_range
            test0 = leaf in clef0_range
            if test2 is True:
                abjad.attach(clef2, F_staff[i])
            elif test1 is True:
                abjad.attach(clef1, F_staff[i])
            elif test0 is True:
                abjad.attach(clef0, F_staff[i])

    abjad.show(staff_group)

    return staff_group
示例#10
0
 def generate_n_random_notes(cls, n: int, scale: str=None, scale_type: str='base'):
     duration = abjad.Duration(1, 4)
     if not scale:
         scale = cls.select_random_scale()
     print('selected scale is ' + scale)
     signature = KeySignature(scale.lower(), 'major')
     random_scale = cls.scale_shift[scale]
     notes = cls.get_random_notes_for_a_scale(n, scale_type)
     new_notes = [abjad.Note(i + random_scale, duration) for i in notes]
     staff = abjad.Staff(new_notes)
     abjad.attach(signature, staff[0])
     abjad.show(staff)
示例#11
0
def make_score(sequence, chords, midi=False):
    print("Length of sequence:", len(sequence), "of", len(chords))
    staff = make_one_part(sequence)
    abjad.show(staff)
    if midi:
        abjad.play(staff)

    # make csv
    filename = 'chords.csv'
    with open(filename, 'w') as csvfile:
        chord_writer = csv.writer(csvfile, delimiter=',')
        for chord in sequence:
            chord_writer.writerow([chord])
示例#12
0
def treblebass():
    trebleclef = ab.Clef('treble')
    treblestaff = ab.Staff(listnotes(toplist))
    ab.attach(trebleclef, treblestaff[0])
    ab.attach(ksignature, treblestaff[0])
    ab.attach(tsignature, treblestaff[0])

    bassclef = ab.Clef('bass')
    bassstaff = ab.Staff(listnotes(bottomlist))
    ab.attach(bassclef, bassstaff[0])
    ab.attach(ksignature, bassstaff[0])
    ab.attach(tsignature, bassstaff[0])

    group = ab.StaffGroup([treblestaff, bassstaff])
    ab.show(group)
示例#13
0
 def generate_random_interval_sequences(cls, n: int, scale: str=None, scale_type: str='base'):
     duration = abjad.Duration(1, 4)
     if not scale:
         scale = cls.select_random_scale()
     print('selected scale is ' + scale)
     signature = KeySignature(scale.lower(), 'major')
     random_scale = cls.scale_shift[scale]
     notes = cls.get_random_notes_for_a_scale(n, scale_type=scale_type)
     new_notes = []
     for note in notes:
         new_notes.append(abjad.Note(random_scale, duration))
         new_notes.append(abjad.Note(note + random_scale, duration))
     staff = abjad.Staff(new_notes)
     abjad.attach(signature, staff[0])
     abjad.show(staff)
示例#14
0
def plot_notes(notes_list, time_list):
    
    #number_of_measures = math.ceil(len(notes_inp)/bpm)
    
    
    notes = []
    print(time_list)
    print(len(time_list))
    print(len(notes_list))
    for i in range(len(notes_list)):
        
        duration = abjad.Duration(time_list[i], 16)
        notes.append(abjad.Note(notes_list[i], duration))
        
    staff = abjad.Staff(notes)
    abjad.show(staff)
示例#15
0
def getSheetMusic(Melody, scale):
    print(scale)
    melodyNotes = [note_name(n,name_to_number(scale[0])).lower() for n in [note.value for note in Melody]]
    print(melodyNotes)
    durations = [int(1/note.dur) for note in Melody]
    octaves = [note.octave for note in Melody]
    abjadArr = []
    for i in zip(melodyNotes, durations, octaves):
        abjadArr.append(i[0] + octaveDict[i[2]] + str(i[1]))
    abjadString = ' '.join(abjadArr)
    staff = Staff(abjadString)
    #attach(KeySignature('c','major'), staff[0])
    attach(KeySignature(scale[0],scale[1]), staff[0])
    attach(TimeSignature((3,4)),staff[0])
    #attach(Clef("bass"), staff[0])
    show(staff)
示例#16
0
def show_notes(notes):
    """
    notes: array-like of pretty_midi Note

    Shows the notes in a standard music sheet format using abjad
    """
    import abjad
    notes_abjad = list()
    for n in notes:
        notes_abjad.append(
            abjad.Note(
                n.pitch - 5 * 12,
                abjad.Duration(n.get_duration() /
                               2).equal_or_greater_assignable))
    staff = abjad.Staff(notes_abjad)
    abjad.show(staff)
示例#17
0
def ChordProgToPic(pop):
    chords = []
    for chord in pop.chords:
        chordString = ""
        for note in chord:
            chordString += convert[note % 12]
            if np.floor(note / 12) - 1 == 4:
                chordString += "' "
            elif np.floor(note / 12) - 1 == 5:
                chordString += "'' "
            elif np.floor(note / 12) - 1 == 6:
                chordString += "''' "
            else:
                chordString += " "
        chords.append(abjad.Chord("<" + chordString + ">4"))
    container = abjad.Container(chords)
    abjad.show(container)
示例#18
0
def make_vla_vln_score(chords, midi=False):
    vla_chords = []
    vln_chords = []

    for chord in chords:
        vla_chord = chord[:4]
        vln_chord = chord[1:]
        vla_chords.append(vla_chord)
        vln_chords.append(vln_chord)

    vla_staff = make_one_part(vla_chords, parenthesis=3)
    clef = abjad.Clef(name='alto')
    abjad.attach(clef, vla_staff[0])
    viola = abjad.instrumenttools.Viola()
    abjad.attach(viola, vla_staff)
    #vla_staff.name = 'Viola'
    vln_staff = make_one_part(vln_chords, parenthesis=0)
    violin = abjad.instrumenttools.Violin()
    abjad.attach(violin, vln_staff)
    #vln_staff.name = 'Violin'
    score = abjad.Score([vln_staff, vla_staff])
    score.add_final_bar_line()

    lilypond_file = abjad.LilyPondFile.new(score,
                                           default_paper_size=('letter',
                                                               'landscape'),
                                           global_staff_size=20)

    #postscript = abjad.Postscript()

    lilypond_file.header_block.title = abjad.Markup("tuning no. 4:")

    lilypond_file.header_block.title.setfont("Arial")
    lilypond_file.header_block.subtitle = abjad.Markup('Pythagorean chains')
    lilypond_file.header_block.composer = abjad.Markup('John Eagle')
    lilypond_file.header_block.tagline = " "
    lilypond_file.paper_block.top_margin = 15
    lilypond_file.paper_block.left_margin = 20

    abjad.show(lilypond_file)
    if midi:
        abjad.play(score)
示例#19
0
def show_score(voiced_chords):
    def add2staff(voice1, voice2, staff):
        voice1 = abjad.Voice(voice1)
        command = abjad.indicatortools.LilyPondCommand('voiceOne')
        abjad.attach(command, voice1)
        voice2 = abjad.Voice(voice2)
        command = abjad.indicatortools.LilyPondCommand('voiceTwo')
        abjad.attach(command, voice2)
        staff.extend([voice1, voice2])
        staff.is_simultaneous = True

    #right format
    notes = []
    satb = [""] * 4
    for chord in voiced_chords:
        for i, note in enumerate(chord):
            octave = note.octave
            name = str.lower(note.name)
            name += ("'" * (octave - 3) * (octave > 3) + "," * (3 - octave) *
                     (octave < 3) + "4 ")

            #builds the voices
            satb[i] += name

    soprano, alto, tenor, bass = satb

    #build the score

    upper_staff = abjad.Staff()
    lower_staff = abjad.Staff()
    satb_staff = abjad.StaffGroup([upper_staff, lower_staff])

    add2staff(soprano, alto, upper_staff)
    add2staff(tenor, bass, lower_staff)
    abjad.attach(abjad.Clef('bass'), lower_staff[0])

    abjad.show(satb_staff)
    abjad.play(satb_staff)
示例#20
0
def make_note_sheet(music):
    violin = abjad.Violin()
    notes=[]
    for row in music:
        if row[0]=='r':
            if row[-1]:
                note=abjad.Rest(row[-2])
            else:
                note=abjad.Rest(abjad.Duration(1,int(lilypod_dur[row[-2]])))
        else:
            x=notes_ann[row[0]].lower()
            if x[-1]=='#' or x[-1]=='b':
                x=x[0]
                x=x+'s'
            note_=x
            oct_=Helmholtz_octave[row[1]]
            due_=lilypod_dur[row[-2]]
            note=abjad.Note(note_+oct_+due_)
        notes.append(note)  
    abjad.attach(violin, notes[0])
    container = abjad.Container(notes)
    abjad.show(container)        
    return
示例#21
0
 def _show_chords(self, chords):
     lilypond_file, score = self._make_lilypond_file_and_score_from_chords(chords)
     abjad.show(lilypond_file)
示例#22
0
for handler, staff in zip(handlers_3, quartet_group):
    handler(staff)

moment = "#(ly:make-moment 1 10)"
abjad.setting(score).proportional_notation_duration = moment

block = abjad.Block(name="score")
block.items.append(score)

style = '"dodecaphonic"'
layout = abjad.Block(name="layout")
layout.items.append(rf"\accidentalStyle {style}")

file = abjad.LilyPondFile(items=[
    r'\include "/Users/gregoryevans/abjad/abjad/_stylesheets/ekmelos-ji-accidental-markups.ily"',
    r'\include "/Users/gregoryevans/scores/polillas/polillas/build/score_stylesheet.ily"',
    layout,
    block,
])

evans.make_sc_file(
    score=score,
    tempo=tempo_pair,
    current_directory=pathlib.Path(__file__).parent,
)

abjad.mutate.transpose(group_2, abjad.NamedInterval("+P8"))

abjad.show(file)
示例#23
0
文件: main.py 项目: Abjad/intensive
from abjad import Duration
from abjad import show
from SegmentMaker import SegmentMaker


durations = [Duration(4, 4)] * 4
segment_maker = SegmentMaker(durations)


if __name__ == '__main__':
    show(segment_maker)
示例#24
0
    voice_1_timespan_list,
    voice_2_timespan_list,
    voice_3_timespan_list,
    voice_4_timespan_list,
    voice_5_timespan_list,
    voice_6_timespan_list,
    voice_7_timespan_list,
    voice_8_timespan_list,
    voice_9_timespan_list,
    voice_10_timespan_list,
    voice_11_timespan_list,
    voice_12_timespan_list,
    voice_13_timespan_list,
    voice_14_timespan_list,
    voice_15_timespan_list,
    voice_16_timespan_list,
    voice_17_timespan_list,
    voice_18_timespan_list,
    voice_19_timespan_list,
    voice_20_timespan_list,
    voice_21_timespan_list,
]

all_timespan_lists = abjad.TimespanList([])
all_timespan_lists = make_showable_list(all_timespans)

abjad.show(all_timespan_lists,
key='annotation',
scale=2
)
示例#25
0
#! /usr/bin/env python
import abjad

if __name__ == '__main__':
    lilypond_file = abjad.demos.mozart.make_mozart_lilypond_file()
    abjad.show(lilypond_file)
示例#26
0
def main():
    image_bgr = cv2.imread(IMAGE)
    image_hsv = cv2.cvtColor(image_bgr, cv2.COLOR_BGR2HSV)
    staves = [abjad.Staff() for _ in range(3)] # oboe, clarinet, bassoon
    abjad.attach(abjad.Clef('bass'), staves[2])
    abjad.attach(abjad.instrumenttools.Oboe(), staves[0])
    abjad.attach(abjad.instrumenttools.ClarinetInBFlat(short_instrument_name_markup='Cl.'), staves[1])
    abjad.attach(abjad.instrumenttools.Bassoon(), staves[2])

    # walk the image's pixels, in a 'square spiral' towards the center
    pixels = get_square_spiral_positions(20)

    prev_dynamics = [None] * 3
    prev_octave_shifts = [None] * 3
    prev_pitch = None
    for i, (x, y) in enumerate(pixels):
        pixel = (y, x)
        B, G, R = image_bgr[pixel]
        H, S, V = image_hsv[pixel]
        dynamic = get_dynamic(V)
        soloist = get_soloist(S)
        pitch = get_pitch(H)

        dynamics = [dynamic] * 3
        dynamics[soloist] += 2
        instrument_channels = [R, B, G]
        instrument_base_octaves = [0, -1, -2]

        for instrument in range(3):
            staff = staves[instrument]
            channel = instrument_channels[instrument]
            octave_shift = get_octave_shift(instrument, channel)
            if octave_shift == -1:
                if prev_octave_shifts[instrument] == -1 and i % 4 != 0:
                    staff[-1].written_duration += abjad.Duration(1, 4)
                    if staff[-1].written_duration == 1:
                        staff[-1] = abjad.scoretools.MultimeasureRest(1)
                    note = None
                else:
                    note = abjad.Rest(NOTE_DURATION)
            else:
                base_pitch = pitch + instrument_base_octaves[instrument] * 12
                note = abjad.Note(base_pitch + octave_shift * 12, NOTE_DURATION)
                if dynamics[instrument] != prev_dynamics[instrument]:
                    dynamic = abjad.Dynamic(DYNAMICS[dynamics[instrument]])
                    abjad.attach(dynamic, note)

                if prev_octave_shifts[instrument] == octave_shift and prev_pitch == pitch:
                    if dynamics[instrument] != prev_dynamics[instrument] or i % 4 == 0:
                        staff.append(note)
                        note = None
                        abjad.attach(abjad.Tie(), staff[-2:])
                    else:
                        staff[-1].written_duration += abjad.Duration(1, 4)
                        note = None

            prev_octave_shifts[instrument] = octave_shift
            if note is not None:
                staff.append(note)

        prev_pitch = pitch
        prev_dynamics = dynamics

    for staff in staves:
        bar_line = abjad.indicatortools.BarLine('|.')
        abjad.attach(bar_line, staff[-1])
    abjad.show(abjad.Score(staves))
示例#27
0
def main():
    score = crawl_to_target_chord(TARGET_CHORD)
    show(score)
示例#28
0
# -*- coding: utf-8 -*-
#! /usr/bin/env python

if __name__ == '__main__':
    from abjad import show
    from abjad.demos import part
    lilypond_file = part.make_part_lilypond_file()
    show(lilypond_file)
示例#29
0
文件: main.py 项目: snappizz/abjad
#! /usr/bin/env python
import abjad
import sys


if __name__ == '__main__':

    arguments = sys.argv[1:]
    if len(arguments) != 3:
        print('USAGE: tuplet_duration row_count column_count')
        print(' e.g.: python main.py 1/4 11 6')
        sys.exit(0)

    tuplet_duration = abjad.Duration(arguments[0])
    row_count = int(arguments[1])
    column_count = int(arguments[2])

    assert 0 < tuplet_duration
    assert 0 < row_count
    assert 0 < column_count

    demo = abjad.demos.ferneyhough.FerneyhoughDemo()
    lilypond_file = demo(
        tuplet_duration=tuplet_duration,
        row_count=row_count,
        column_count=column_count,
        )
    abjad.show(lilypond_file)
示例#30
0
        ])
    # 1 - process source file
    vc_list, bt_list= process_src(src_file)
    # 2 - create a container for both abjad measures and SC events
    beat_measures, events_container= blank_containers(bt_list, vc_list)
    # 3 - adjust durations before filling out beat_measures, as folows:
    # 3.1 - compressing tuplets in a single event with notes list
    events_container= resolve_tuplets(events_container)
    # 3.2 - span long notes (dur > bar_size) over bars
    events_container= note_spanner(events_container)
    # 3.2 - fill rests
    events_container= fill_rest(events_container)
    # 3.3(3.1) - rests inflated beats, spanning should be repeated
    events_container= note_spanner(events_container)
    # 4 - adjust durations to the current measure
    events_container= adjust_durations(events_container)
    report_events( events_container )
    # 5 - fill the score
    ajscore= fill_score(vc_list, events_container)
    # 6 - markup and layout
    ajlily= lily_file(ajscore)
    # 7 - produce ly
    
    # 8 - show the score
    if showpdf:
        print "Producing PDF..."
        try:
            aj.show(ajlily)
        except Exception as e:
            print "ERROR: %s" % e
示例#31
0
        fixed = fixNotes(newNote)
        print fixed
        staff.append(fixed)

        pass
#    except LilyPondParserError:
#        m = re.search('\w.\d',letters)
#        shortenedNote = m.group(0)
#        newNote = shortenedNote[0]+shortenedNote[-1]
#        fixed = fixNotes(newNote)
#        try:
#            staff.append(fixed)
#        except DurationError:
#            pass

abjad.show(staff)
'''Code to turn the xlsx into a more useable xlsx'''
#freqs = pd.read_csv('Book1.csv',delimiter='\t',header=None)
#
#column1 = []
#column2 = []
#notes = []
#for i,v in enumerate(freqs[9]):
#    if i>4:
#        if i%2==0:
#            column2.append(v)
#        else:
#            column1.append(v)
#            notes.append(freqs[8][i])
#
#z = pd.DataFrame([notes,column1,column2])
示例#32
0
def show(staff):
    """Render and show."""

    return abj.show(make_lilyfile(staff))
示例#33
0
import abjad

pitches = ["e'4", "c'4", "cs'8", "ef'8", "d'4"]

notes = [abjad.Note(x) for x in pitches]

container = abjad.Container(notes)

selection = abjad.select(container[:2])
for x in selection:
    abjad.override(x).note_head.color = "red"
abjad.show(container)
示例#34
0
            stack.append(child)


def build_score_from_tree(tree):
    stack = [tree.root]
    while len(stack) > 0:
        node = stack.pop()
        if node.tag == 'measure':
            pass


if __name__ == '__main__':
    tree = build_tree_from_xml('./castle.xml')
    print_tree(tree.root)
    score = build_score_from_tree(tree)
    show(score)

# clef = abjad.Clef('treble_8')
# abjad.attach(clef, measures[0][0])
# staff = abjad.Staff(measures)
# show(staff)

# duration = abjad.Duration(1, 4)
# rests = [abjad.Rest(abjad.Duration(1, 4)), abjad.Rest(abjad.Duration(2, 4))]

# notes = [
#     abjad.Note(16, abjad.Duration(1, 8)),
#     abjad.Note("e4", abjad.Duration(1, 8)),
#     abjad.Note(18, abjad.Duration(1, 8)),
#     # 这两个是一个 chord
#     abjad.Chord([19, -8], abjad.Duration(1, 8)),
示例#35
0
文件: canon.py 项目: Abjad/intensive
    for scaled_staff, duplicate_index in zip(scaled_staves, reversed(range(3))):
        scale_factor = 2**duplicate_index
        staff = duplicate_music(scale_factor, scaled_staff)
        score.append(staff)
    return score

def format_score(score, key_signature, time_signature):
    for staff in score:
        key_sig = abjad.KeySignature(key_signature.tonic, key_signature.mode)
        abjad.attach(key_sig, staff[0])
        time_sig = abjad.TimeSignature(time_signature)
        abjad.attach(time_sig, staff[0])
    abjad.attach(abjad.Clef('bass'), score[2][0])

def make_canon(melody_staff, key_signature, time_signature):
    # make a three-voice prolation canon from a melody
    scaled_staves = make_scaled_staves(melody_staff, time_signature)
    score = duplicate_score(scaled_staves)
    format_score(score, key_signature, time_signature)
    return score

# # "Arirang"
melody_staff = abjad.Staff("e'4. fs'8 e'4 a'4. b'8 a' b' cs''4 b'8 cs''16 b' a'8 fs' e'4. fs'8 e' fs' a'4. b'8 a' b' cs'' b' a' fs' e' fs' a'4. b'8 a'4 a'2.")
melody_staff.extend("e''2 e''4 e'' cs'' b' cs'' b'8 cs''16 b' a'8 fs' e'4. fs'8 e' fs' a'4. b'8 a' b' cs'' b' a' fs' e' fs' a'4. b'8 a'4 a'2.")

for note in melody_staff:
    note.written_pitch += 12

score = make_canon(melody_staff, abjad.KeySignature('d', 'major'), abjad.TimeSignature((3,4)))
abjad.show(score)
示例#36
0
文件: voices.py 项目: jgarte/evans
                    [
                        abjad.Voice(
                            "c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8",
                            name="Voice 2",
                        )
                    ],
                    name="Staff 2",
                ),
            ],
            name="group",
        )
    ],
    name="Score",
)

h = evans.IntermittentVoiceHandler(
    evans.RhythmHandler(
        rmakers.stack(evans.RTMMaker([
            "(1 (1 1 1))",
        ]), ),
        forget=False,
    ),
    direction=abjad.Up,
)

selector = abjad.select().leaf(1)
target = selector(score["Voice 1"])
h(target)

abjad.show(score)
示例#37
0
 def show(self):
     """Show ``self.score``."""
     return abjad.show(self.score)
示例#38
0
                else:
                    upper_staff_components.append(
                        abjad.Rest(abjad.Duration(1, 1)))

            lower_staff = abjad.Staff(lower_staff_components)
            upper_staff = abjad.Staff(upper_staff_components)

            if len(lower_staff_components) > 0:
                leaf = abjad.get.leaf(lower_staff, 0)
                abjad.attach(abjad.Clef('bass'), leaf)

            piano_staff = abjad.StaffGroup([], lilypond_type='PianoStaff')
            piano_staff.append(upper_staff)
            piano_staff.append(lower_staff)

            abjad.show(piano_staff)

        else:

            print("Nothing to notate!")

elif mode_text.lower() == "write":

    if len(sys.argv) < 4:
        raise ValueError("No string provided to write to file")

    chord_string = sys.argv[3]

    # make sure the chord string is of valid format
    try:
        c = Chord.from_string(chord_string)
示例#39
0
    lilypond_file.layout.indent = 0
    lilypond_file.layout.ragged_right = True
    lilypond_file.paper.top_margin = 20
    lilypond_file.paper.left_margin = 15
    lilypond_file.paper.print_page_number = False
    lilypond_file.paper.minimal_page_breaking = True
    lilypond_file.paper.ragged_last_bottom = True
    lilypond_file.paper.ragged_bottom = True
    lilypond_file.paper.between_system_padding = 10
    lilypond_file.global_staff_size = 14
    lilypond_file.default_paper_size = 'letter', 'portrait'
    apply_footer(score)
    return lilypond_file


def apply_footer(score):
    lilypond_file = score.lilypond_file
    footer_string = 'désir - fleur pitch sets by arithmetic mean'
    footer_markup = abjad.Markup(r'\fill-line { "%s" }' % footer_string)
    lilypond_file.paper.oddFooterMarkup = footer_markup
    lilypond_file.paper.evenFooterMarkup = footer_markup


if __name__ == '__main__':
    chords = make_chords()
    label.leaf_numbers(chords, direction = 'above')
    chords.sort(lambda x, y: cmp(x.center, y.center))
    score = leaftools.show_leaves(chords, suppress_pdf = True)
    configure_score(score)
    abjad.show(score.lilypond_file)
示例#40
0
            leaf = abjad.inspect(staff).leaf(0)
            abjad.attach(time_signature, leaf)
            score.append(staff)
        return score


if __name__ == "__main__":
    from abjad import show

    arguments = sys.argv[1:]
    if len(arguments) != 3:
        print("USAGE: tuplet_duration row_count column_count")
        print(" e.g.: python main.py 1/4 11 6")
        sys.exit(0)

    tuplet_duration = abjad.Duration(arguments[0])
    row_count = int(arguments[1])
    column_count = int(arguments[2])

    assert 0 < tuplet_duration
    assert 0 < row_count
    assert 0 < column_count

    demo = abjad.demos.ferneyhough.FerneyhoughDemo()
    lilypond_file = demo(
        tuplet_duration=tuplet_duration,
        row_count=row_count,
        column_count=column_count,
    )
    show(lilypond_file)
示例#41
0
        print fixed
        staff.append(fixed)

        pass
#    except LilyPondParserError:
#        m = re.search('\w.\d',letters)
#        shortenedNote = m.group(0)
#        newNote = shortenedNote[0]+shortenedNote[-1]
#        fixed = fixNotes(newNote)
#        try:
#            staff.append(fixed)
#        except DurationError:
#            pass


abjad.show(staff)


'''Code to turn the xlsx into a more useable xlsx'''
#freqs = pd.read_csv('Book1.csv',delimiter='\t',header=None)
#
#column1 = []
#column2 = []
#notes = []
#for i,v in enumerate(freqs[9]):
#    if i>4:
#        if i%2==0:
#            column2.append(v)
#        else:
#            column1.append(v)
#            notes.append(freqs[8][i])
示例#42
0
import abjad

chord = [-12, -5, 2, 9, 16]

new_chord = abjad.Chord(chord, 1)

new_chord.note_heads[4].is_parenthesized = True

#staff = abjad.Staff(new_chord)

abjad.show(new_chord)
示例#43
0
for i in range(number_of_notes):
    # Make staves periodically have same duration
    upper_notes(number_of_notes)
    lower_notes(number_of_notes)

print("Starting duration equalization, should take about {} notes".format(
    int(
        float(
            abs(
                ab.inspect(lower_staff).duration() -
                ab.inspect(upper_staff).duration()))) * 3))
equalize_durations()
print(
    "There are a total of {} notes in the right hand and {} notes in the left hand"
    .format(len(ab.select(upper_staff).leaves()),
            len(ab.select(lower_staff).leaves())))

# Stuff that has to be done at the end
# For some stupid reason
print("Finalizing")
leaf = ab.inspect(lower_staff).leaf(0)
ab.attach(ab.Clef('bass'), leaf)
ab.attach(ab.TimeSignature(time_signature), staff[0][0])
ab.attach(key_signature, staff[0][0])
ab.attach(key_signature, staff[1][0])
score.add_final_bar_line()

# Generate PDF
print("Generating PDF")
ab.show(score)