LoginSignup
4
6

More than 5 years have passed since last update.

めざせpythonライブラリマスター (14)pyknon

Posted at

【ライブラリ説明】

 プログラムで音楽を作れます。
 今回はチューリップの最初の部分をコーディングしてみました。

【プログラム】

pyknon.py
# -*- coding: utf-8 -*-

from pyknon.genmidi import Midi
from pyknon.music import NoteSeq

# 音階?を設定
notes1 = NoteSeq("C D E")
notes2 = NoteSeq("C D E")
notes3 = NoteSeq("G E D C D E D")

# テンポを指定してMidiインスタンス生成
midi = Midi(tempo=90)
# 音が鳴る時間を指定してnotes1~3をつなげる
midi.seq_notes(notes1)
midi.seq_notes(notes2, time=4)
midi.seq_notes(notes3, time=8)

# ファイル書き込み
midi.write("demo.mid")

【感想】

 これは素晴らしいし、面白い!

【参考サイト】

 pypi
 github
 document的なもの
 MIDIのノートナンバーと周波数との対応表

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6