本文整理汇总了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
示例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"))
示例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)
示例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
示例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
示例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
示例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
示例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)