10
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

music21を使う環境構築

Last updated at Posted at 2019-02-03

はじめに

こちらの記事から環境構築を行った時の備忘録です。

インストール

$ python3 -m venv env
$ . env/bin/activate
$ pip install jupyter
$ pip install music21
$ pip install pyknon
$ brew cask install lilypond
$ brew cask install musescore

jupyter 入れた後は 再読み込みが必要でした。

設定

MuseScoreのバージョンが2から3にあがっていたので、初期設定のままではうごきませんでした。

スクリーンショット 2019-02-03 17.22.45.png

environment.pyのMuseScoreの設定はここ

スクリーンショット 2019-02-03 17.25.38.png

http://web.mit.edu/music21/doc/usersGuide/usersGuide_24_environment.html
より
下記を実行すると~/.music21に設定が保存されます。

from music21 import environment

us = environment.UserSettings()
us.create()
us['musescoreDirectPNGPath'] = '/Applications/MuseScore 3.app/Contents/MacOS/mscore'
us['musicxmlPath'] = '/Applications/MuseScore 3.app/Contents/MacOS/mscore'

~/.music21を消した場合は再起動するまでメモリ上で設定を保持しているような挙動でした。

VS Codeでの動作確認用

#%%
from music21 import environment

us = environment.UserSettings()
us.getSettingsPath()

#%%
from music21 import environment

us = environment.UserSettings()
us.create()
us['musescoreDirectPNGPath'] = '/Applications/MuseScore 3.app/Contents/MacOS/mscore'
us['musicxmlPath'] = '/Applications/MuseScore 3.app/Contents/MacOS/mscore'

#%%
from music21 import note,stream

stream1 = stream.Stream()
note = note.Note("C4", quarterLength = 1)
stream1.repeatAppend(note, 4)
stream1.show()

参考

さいごに

VSCode1つで開発できてしまって
環境構築はコマンドライン完了できるのは素敵です。

10
9
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
10
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?