Created
December 8, 2015 13:11
-
-
Save kvvzr/b716fdc0042e5f5fe796 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import melete.lyrics as Lyrics | |
import melete.rhythm as Rhythm | |
import melete.chord as Chord | |
import melete.melody as Melody | |
# 4/4拍子 | |
ts = Rhythm.TimeSignature(4, 2) | |
# リズムパターン | |
rhythms = [[0], [0, 96], [48, 96, 144], [0, 48, 96, 144], [0, 24, 48, 96, 144]] | |
tree = Rhythm.RhythmTree(48, 1, ts, rhythms) | |
# 歌詞とリズムを合体 | |
text = u'八ツ橋 を 粉状 に なる まで すりつぶ す===粉状 に したもの に ねっと うを 加え混ぜ る' | |
lyrics = Lyrics.analyze(text) #歌詞の形態素とイントネーションを調べる | |
lyrics = map(lambda l: Lyrics.divide(l['phoneme'], tree), lyrics) | |
beats = map(lambda l: Lyrics.pair(l, tree), lyrics) | |
# コード進行 | |
c = Chord.Chord.from_name('C') | |
f = Chord.Chord.from_name('F') | |
f.inversion(1) | |
g = Chord.Chord.from_name('G') | |
g.inversion(1) | |
progs = [ | |
Chord.ChordProg(48, 4, [(c, 0), (g, 192), (f, 384), (c, 576)]), | |
Chord.ChordProg(48, 4, [(f, 0), (c, 192), (g, 384), (c, 576)]) | |
] | |
# 伴奏のパターン(最近作ったのでcore側が適当) | |
accom_patterns = [ | |
{ | |
0.0: {'length': 0.25, 'notes': [1, 2]}, | |
0.25: {'length': 0.25, 'notes': [0]}, | |
0.5: {'length': 0.25, 'notes': [1, 2]}, | |
0.75: {'length': 0.25, 'notes': [0]}, | |
}, | |
{ | |
0.0: {'length': 1.0, 'notes': [0, 1, 2]}, | |
} | |
] | |
note_range = Chord.note_range('C4', 'A5') | |
midi = Melody.create(ts, beats, progs, note_range, accom_patterns, bpm=240) | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment