The current repo belongs to Paused status, and some functions are restricted. For details, please refer to the description of repo status
1 Star 3 Fork 0

二花 / guitar-synthesizer
Paused

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
main.py 982 Bytes
Copy Edit Web IDE Raw Blame History
二花 authored 2019-01-08 16:28 . remove code in matlab and julia
import numpy as np
from tone import generate_song
from wav_writer import WaveWriter
# 主旋律:八辈子
song = [[3, 1], [5, 1], [3, 1], [3, .5],
[5, .5], [10, 1], [10, 1], [10, .5],
[7, .5], [5, .5], [7, .5], [5, 1],
[3, 1], [3, 1], [3, .5], [5, .5],
[5, 1], [3, 1], [3, 1], [-2, .5], [-2, .5]]
# 伴奏:八辈子
chords = [3, -2, 3, 5, 7, 5, 10, 7,
3, -2, 3, 5, 7, 5, 10, 7,
-2, -2, 3, 5, 7, 5, 10, 7,
-2, -2, 3, 5, 7, 5, 7, 10]
if __name__ == "__main__":
# generate wav
wav = generate_song(song, .5)
chords = generate_song([[chord, 1] for chord in chords], .25, amplitude=0.5)
# 和弦循环至歌曲结束
while len(chords) < len(wav):
chords = np.append(chords, chords)
chords = chords[:len(wav)]
wav = (wav + chords) / 2
# write wav into a file
writer = WaveWriter('test.wav')
writer.set_header(nchannels=1)
writer.write_wave(wav)
writer.close()

Comment ( 0 )

Sign in for post a comment

Python
1
https://gitee.com/ryan_yin/guitar-synthesizer.git
git@gitee.com:ryan_yin/guitar-synthesizer.git
ryan_yin
guitar-synthesizer
guitar-synthesizer
master

Search

105716 1d94204e 1850385 105716 2d26be5c 1850385