当前位置: 首页>>代码示例>>Python>>正文


Python music.NoteSeq类代码示例

本文整理汇总了Python中pyknon.music.NoteSeq的典型用法代码示例。如果您正苦于以下问题:Python NoteSeq类的具体用法?Python NoteSeq怎么用?Python NoteSeq使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了NoteSeq类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: strToMidi

def strToMidi(msg, fileName):
    from pyknon.genmidi import Midi
    from pyknon.music   import NoteSeq
    from pyknon.music   import Note
    notes = {
        '0' : Note(value=0, octave=5), # Do
        '1' : Note(value=2, octave=5), # Re
        '2' : Note(value=4, octave=5), # Mi
        '3' : Note(value=5, octave=5), # Fa
        '4' : Note(value=7, octave=5), # Sol
        '5' : Note(value=9, octave=5), # La
        '6' : Note(value=11, octave=5), # Si
        '7' : Note(value=0, octave=6),
        '8' : Note(value=2, octave=6),
        '9' : Note(value=4, octave=6),
        'a' : Note(value=5, octave=6),
        'b' : Note(value=7, octave=6),
        'c' : Note(value=9, octave=6),
        'd' : Note(value=11, octave=6),
        'e' : Note(value=0, octave=7),
        'f' : Note(value=2, octave=7)
    }
    msgHex = msg.encode('hex');
    sequence = NoteSeq('C1')
    before = ''
    for i in msgHex:
        if before == i:
            sequence.append(Note(value=4, octave=7))
        sequence.append(notes[i])
        before = i
    midi = Midi(1, tempo = 290)
    midi.seq_notes(sequence, track=0)
    midi.write(fileName)
开发者ID:Donluigimx,项目名称:str2Audio,代码行数:33,代码来源:str2Audio.py

示例2: test_stretch_inverval

 def test_stretch_inverval(self):
     seq1 = NoteSeq("C D E")
     seq2 = NoteSeq("C E G#")
     seq3 = NoteSeq("A Bb F#")
     seq4 = NoteSeq("A C#'' C''")
     self.assertEqual(seq1.stretch_inverval(2), seq2)
     self.assertEqual(seq3.stretch_inverval(3), seq4)
开发者ID:adamobeng,项目名称:pyknon,代码行数:7,代码来源:test_music.py

示例3: pix2noteseq

def pix2noteseq(pixelmap, width, height):
    """
    Convert a PIL pixel map to a PyKnon NoteSeq

    Use:
        pix2noteseq(pixelmap)

    Arguemnts:
        pixelmap: the PIL pixel map of the image
        width: the width in pixels
        height: height in pixels

    This function presumes the pixel map is in RGB and correct behavior when
    otherwise is not at all guaranteed.
    """
    notes = NoteSeq()
    
    # Iterate over the pixels, starting at the top left and working
    # colomn by colomn
    for y in range(height):
        for x in range(width):
            notes.append(pix2note(pixelmap[x,y]))
            if y == math.ceil(height/2) and x == math.ceil(width/2):
                print("50% done...")

    return notes
开发者ID:Jayjader,项目名称:PixelNoise,代码行数:26,代码来源:pixelnoise.py

示例4: crab_canon

def crab_canon(filename):
    theme = NoteSeq("file://%s.notes" % filename)
    rev_theme = theme.transposition(-12).retrograde()

    midi = Midi(2, tempo=120)
    midi.seq_notes(theme)
    midi.seq_notes(rev_theme, track=1)
    midi.write("%s.mid" % filename)
开发者ID:kuno,项目名称:music-for-geeks-exercises,代码行数:8,代码来源:exercise11.py

示例5: test_rotate

 def test_rotate(self):
     seq1 = NoteSeq("C E G")
     seq2 = NoteSeq("E G C")
     seq3 = NoteSeq("G C E")
     self.assertEqual(seq1.rotate(0), seq1)
     self.assertEqual(seq1.rotate(1), seq2)
     self.assertEqual(seq1.rotate(2), seq3)
     self.assertEqual(seq1.rotate(3), seq1)
开发者ID:adamobeng,项目名称:pyknon,代码行数:8,代码来源:test_music.py

示例6: play_list

def play_list(pitch_list, octave_list, duration, volume=120):
    result = NoteSeq()
    for pitch in pitch_list:
        note = pitch % 12
        octave = choice_if_list(octave_list)
        dur = choice_if_list(duration)
        vol = choice_if_list(volume)
        result.append(Note(note, octave, dur, vol))
    return result
开发者ID:kuno,项目名称:music-for-geeks-exercises,代码行数:9,代码来源:exercise10.py

示例7: random_notes

def random_notes(pitch_list, octave_list, duration,
                 number_of_notes, volume=120):
    result = NoteSeq()
    for x in range(0, number_of_notes):
        pitch = choice(pitch_list)
        octave = choice_if_list(octave_list)
        dur = choice_if_list(duration)
        vol = choice_if_list(volume)
        result.append(Note(pitch, octave, dur, vol))
    return result
开发者ID:kuno,项目名称:music-for-geeks-exercises,代码行数:10,代码来源:exercise08.py

示例8: play_list

def play_list(pitch_list, octave_list, duration,
              volume=120):
    result = NoteSeq()
    durl = [1/8, 1/8, 1/16, 1/16]
    cc = [choice([0,1,2,3,4,5,6,7,8,9,10,11]), choice([0,1,2,3,4,5,6,7,8,9,10,11]), choice([0,1,2,3,4,5,6,7,8,9,10,11]), choice([0,1,2,3,4,5,6,7,8,9,10,11])]
    st = 0
    for pitch in pitch_list:
        note1 = pitch
        note = cc[st%4]
        #octave = choice_if_list(octave_list)
        octave = change_range(note1, 0, 11, 1, 7)
        #dur = choice_if_list(duration)
        dur = durl[st%4]
        st += 1
        vol = choice_if_list(volume)
        result.append(Note(note, octave, dur, vol))
    return result
开发者ID:HackerPack,项目名称:StockTunes,代码行数:17,代码来源:beat_box.py

示例9: test_init_empty

 def test_init_empty(self):
     """Test if NoteSeq without arguments will clean previous values."""
     seq = NoteSeq()
     seq.append(Note("C"))
     seq = NoteSeq()
     seq.append(Note("D"))
     self.assertEqual(seq, NoteSeq("D"))
开发者ID:adamobeng,项目名称:pyknon,代码行数:7,代码来源:test_music.py

示例10: random_notes_with_memory

def random_notes_with_memory(pitch_list, octave_list, duration_list,
                             number_of_notes, memory_weights, volume=120):
    assert len(memory_weights) > 1, "more than 1 weight expected for memory"
    result = NoteSeq()
    for offset in range(0, number_of_notes):

        if 1+offset >= len(memory_weights):
            weights = memory_weights
        else:
            weights = memory_weights[0:1+offset]

        pitch_selection = weighted_random(weights)
        if pitch_selection == 0: # new note
            pitch = choice(pitch_list)
        else:
            pitch = result[-pitch_selection].value

        octave_selection = weighted_random(weights)
        if octave_selection == 0: # new note
            octave = choice_if_list(octave_list)
        else: # previous note at given position starting from the end
            octave = result[-octave_selection].octave

        duration_selection = weighted_random(weights)
        if duration_selection == 0: # new note
            dur = choice_if_list(duration_list)
        else: # previous note at given position starting from the end
            dur = result[-duration_selection].dur

        volume_selection = weighted_random(weights)
        if volume_selection == 0: # new note
            vol = choice_if_list(volume)
        else: # previous note at given position starting from the end
            vol = result[-volume_selection].volume

        result.append(Note(pitch, octave, dur, vol))
    return result
开发者ID:eric-brechemier,项目名称:music-for-geeks-exercises,代码行数:37,代码来源:exercise09.py

示例11: test_retrograde

 def test_retrograde(self):
     seq1 = NoteSeq("C4 D8 E8")
     seq2 = NoteSeq("E8 D8 C4")
     self.assertEqual(seq1.retrograde(), seq2)
开发者ID:adamobeng,项目名称:pyknon,代码行数:4,代码来源:test_music.py

示例12: test_append

 def test_append(self):
     seq1 = NoteSeq("C# D#")
     seq1.append(Note("F#"))
     seq2 = NoteSeq("C# D# F#")
     self.assertEqual(seq1, seq2)
开发者ID:adamobeng,项目名称:pyknon,代码行数:5,代码来源:test_music.py

示例13: test_stretch_dur

 def test_stretch_dur(self):
     seq1 = NoteSeq("C4 D8 E8")
     seq2 = NoteSeq("C8 D16 E16")
     seq3 = NoteSeq("C2 D4 E4")
     self.assertEqual(seq1.stretch_dur(.5), seq2)
     self.assertEqual(seq1.stretch_dur(2), seq3)
开发者ID:adamobeng,项目名称:pyknon,代码行数:6,代码来源:test_music.py

示例14: test_inversion_startswith_string

 def test_inversion_startswith_string(self):
     seq1 = NoteSeq("C E G")
     seq2 = NoteSeq("C Ab, F,")
     self.assertEqual(seq1.inversion_startswith("C"), seq2)
开发者ID:adamobeng,项目名称:pyknon,代码行数:4,代码来源:test_music.py

示例15: test_harmonize

 def test_harmonize(self):
     c_major = NoteSeq("C D E F G A B")
     c_major_harmonized = [NoteSeq("C E G"), NoteSeq("D F A"), NoteSeq("E G B"),
                           NoteSeq("F A C''"), NoteSeq("G B D''"), NoteSeq("A C'' E"),
                           NoteSeq("B D'' F''")]
     self.assertEqual(c_major.harmonize(), c_major_harmonized)
开发者ID:adamobeng,项目名称:pyknon,代码行数:6,代码来源:test_music.py


注:本文中的pyknon.music.NoteSeq类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。