Perl日記

日々の知ったことのメモなどです。Perlは最近やってないです。

Sota (Intel Edison版) にMIDIキーボードをつないで音を鳴らす

Sota (Intel Edison版) にMIDIキーボードをつなげて音を鳴らしてみたメモ。

社会的対話ロボット「CommU(コミュー)」・普及型社会的対話ロボット「Sota(ソータ)」 | ヴイストン株式会社


とはいうものの、以下のサイトをやってみただけ、という感じだったけど。

www.instructables.com

デモ


Sota MIDI

SotaにMIDIキーボードを挿す

今回は、以下のMIDIキーボードを使用した。(というかこれしか持ってない)

www.korg.com

ALSAをインストールする
$ opkg install alsa-utils

もしかしたらもう既にインストールされているかもしれない。

FluidSynthをインストールする

http://www.fluidsynth.org/

$ tar zxvf fluidsynth-1.1.6.tar.gz
$ cd fluidsynth-1.1.6
$ ./configure
***************************************************************
The autotools build system is deprecated and might be removed
in a future version. Please use the CMake build system instead.
***************************************************************
Summary:
libsndfile:            no (raw audio file rendering only)
D-Bus:                 yes
PulseAudio:            no
JACK:                  no
ALSA:                  yes
PortAudio:             no
OSS:                   yes
MidiShare:             no
CoreAudio:             no
CoreMIDI:              no
LADSPA support:        no
LASH support:          no
LADCCA support:        no
OS/2 DART support:     no
Audio to file driver:  yes
Readline:              yes (NOTE: GPL library)
Profiling:             no
Debug:                 no
Trap on FPE (debug):   no
Check FPE (debug):     no
***************************************************************

$ make
$ make check
$ make install
$ make clean

音源のサウンドフォントは、以下をお借りしてSotaにコピーした。

polyphone-soundfonts.com

$ ls -l akai_steinway.sf2
-rw-r--r-- 1 root  root  25696060 Dec 25 07:22 akai_steinway.sf2
FluidSynthで音を鳴らす
$ fluidsynth -a alsa -g 3 akai_steinway.sf2

aオプションでALSAを指定、gオプションで音量(0 < g < 10)を指定する。

起動したら、一旦Ctrl+zでサスペンドする。

$ fluidsynth -a alsa -g 3 akai_steinway.sf2
FluidSynth version 1.1.6
Copyright (C) 2000-2012 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of E-mu Systems, Inc.

fluidsynth: warning: No preset found on channel 9 [bank=128 prog=0]
fluidsynth: warning: Requested a period size of 64, got 1024 instead
fluidsynth: warning: Requested 16 periods, got 4 instead
Type 'help' for help topics.

> ^Z
[1]+  Stopped                 fluidsynth -a alsa -g 3 akai_steinway.sf2

すると、aconnectコマンドでFluidSynthのポートが増えているのが確認できる。

$ aconnect -o
client 28: 'nanoKEY2' [type=kernel]
    0 'nanoKEY2 MIDI 1 '
client 128: 'FLUID Synth (752)' [type=user]
    0 'Synth input port (752:0)'

MIDIキーボードのデータをFluidSynthに送るようにする。

$ aconnect 28:0 128:0

fgコマンドでFluidSynthを復帰させる。

$ fg
(Enter)
fluidsynth -a alsa -g 3 FluidR3_GM.sf2

>

入力待ちになるが、これで終わり。



あとはMIDIキーボードを押せば、音が鳴る。


終わりたいときは、Ctrl+CでもCtrl+Dでも、FluidSynthを終了すればOK。