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


Python NoteSeq.append方法代码示例

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


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

示例1: pix2noteseq

# 需要导入模块: from pyknon.music import NoteSeq [as 别名]
# 或者: from pyknon.music.NoteSeq import append [as 别名]
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,代码行数:28,代码来源:pixelnoise.py

示例2: test_init_empty

# 需要导入模块: from pyknon.music import NoteSeq [as 别名]
# 或者: from pyknon.music.NoteSeq import append [as 别名]
 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,代码行数:9,代码来源:test_music.py

示例3: strToMidi

# 需要导入模块: from pyknon.music import NoteSeq [as 别名]
# 或者: from pyknon.music.NoteSeq import append [as 别名]
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,代码行数:35,代码来源:str2Audio.py

示例4: play_list

# 需要导入模块: from pyknon.music import NoteSeq [as 别名]
# 或者: from pyknon.music.NoteSeq import append [as 别名]
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,代码行数:11,代码来源:exercise10.py

示例5: random_notes

# 需要导入模块: from pyknon.music import NoteSeq [as 别名]
# 或者: from pyknon.music.NoteSeq import append [as 别名]
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,代码行数:12,代码来源:exercise08.py

示例6: play_list

# 需要导入模块: from pyknon.music import NoteSeq [as 别名]
# 或者: from pyknon.music.NoteSeq import append [as 别名]
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,代码行数:19,代码来源:beat_box.py

示例7: random_notes_with_memory

# 需要导入模块: from pyknon.music import NoteSeq [as 别名]
# 或者: from pyknon.music.NoteSeq import append [as 别名]
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,代码行数:39,代码来源:exercise09.py

示例8: test_append

# 需要导入模块: from pyknon.music import NoteSeq [as 别名]
# 或者: from pyknon.music.NoteSeq import append [as 别名]
 def test_append(self):
     seq1 = NoteSeq("C# D#")
     seq1.append(Note("F#"))
     seq2 = NoteSeq("C# D# F#")
     self.assertEqual(seq1, seq2)
开发者ID:adamobeng,项目名称:pyknon,代码行数:7,代码来源:test_music.py


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