Jun 04, 2016
Raspberry Pi でメモリ再生を試みる2(raspbianにmpdをインストールする)
タイトルに2とあるが、実はメモリ再生はpiCore7よりも前にraspbianで成功していた。
そもそも、デバイスの設定をconfig.txtに書き込むとalsaが認識してくれるというのは、raspbianで試みて気付いたことだった。piCore7だけいじっていたときにはこれに気付かず、諦め、まあ気を取り直してraspbianでやってみっか、、、で、気付いたのだ。
ネットで探してもpiCoreのalsaの設定の仕方はよく分からない。
僕は出来合いのi2sDACでhifiberryから設定をもらえたので簡単だったが、USB-DACとかつなぐ場合の設定は全く分からない
それはともあれ。
大したことはないけど、これも備忘録にしておく。
raspbianをmicroSDにインストール、i2sデバイスを設定
僕が使ったのはRaspbian Jessie Liteだ。 https://www.raspberrypi.org/downloads/raspbian/ 上記のサイトからダウンロードできる。
これをmicroSDに焼いて、config.txtにi2sデバイスの設定を書き込む。
下記サイトを参考。
https://www.hifiberry.com/guides/configuring-linux-3-18-x/
raspbianをRas Piで起動した後で、/boot/config.txtに書き込んで再起動でもかまわない。
ちなみにpiCore7だとブート後はconfig.txtが見えなくなる。
ファイルイメージの拡張
Ras Piに刺して起動し、sshでログインする。
ユーザーはpi、パスワードはraspberry。
そこで以下のコマンドでファイルイメージを拡張しておく。ついでにローカル設定とかもしておく。
pi@raspberrypi:~ $ sudo raspi-config
alsaインストール
下記のコマンドでインストール。
pi@raspberrypi:~ $ sudo apt-get install alsa-base
swapを止める
ほっとくと100MB程がswapに取られてしまうので設定しなおす。
コマンドなど経過は下記のとおり。
本当はpiCoreでも止めたいんだけど、こっちは方法が分からない。まあ、音楽ファイル用にswapが使われるので放置でもいいんだろうけど、止めるほうがすっきりしてるんじゃないかという気がする。
pi@raspberrypi:~ $ free total used free shared buffers cached Mem: 445124 191848 253276 4460 12388 150836 -/+ buffers/cache: 28624 416500 Swap: 102396 0 102396 pi@raspberrypi:~ $ swapon -s Filename Type Size Used Priority /var/swap file 102396 0 -1 pi@raspberrypi:~ $ sudo swapoff --all pi@raspberrypi:~ $ free total used free shared buffers cached Mem: 445124 191848 253276 4460 12396 150852 -/+ buffers/cache: 28600 416524 Swap: 0 0 0 pi@raspberrypi:~ $ pi@raspberrypi:~ $ sudo apt-get remove dphys-swapfile Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: dc Use 'apt-get autoremove' to remove it. The following packages will be REMOVED: dphys-swapfile 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 85.0 kB disk space will be freed. Do you want to continue? [Y/n] Y Can't set locale; make sure $LC_* and $LANG are correct! perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_TIME = "en_US.UTF-8", LC_MONETARY = "en_US.UTF-8", LC_MEASUREMENT = "en_US.UTF-8", LC_NUMERIC = "en_US.UTF-8", LC_PAPER = "en_US.UTF-8", LANG = "en_GB.UTF-8" are supported and installed on your system. perl: warning: Falling back to a fallback locale ("en_GB.UTF-8"). locale: Cannot set LC_ALL to default locale: No such file or directory (Reading database ... 31037 files and directories currently installed.) Removing dphys-swapfile (20100506-1) ... Processing triggers for man-db (2.7.0.2-5) ... pi@raspberrypi:~ $ pi@raspberrypi:~ $ sudo reboot pi@192.168.1.116's password: Last login: Mon May 23 23:41:23 2016 from 192.168.1.52 pi@raspberrypi:~ $ free total used free shared buffers cached Mem: 445124 62396 382728 4456 6096 31940 -/+ buffers/cache: 24360 420764 Swap: 0 0 0 pi@raspberrypi:~ $
freeのメモリが250MBから380MB以上に増えている。
音楽ファイルの置き場をram diskで設定
以下のとおり。意味があるのかどうか分からないが。
pi@raspberrypi:~ $ df -h Filesystem Size Used Avail Use% Mounted on /dev/root 3.6G 890M 2.5G 26% / devtmpfs 214M 0 214M 0% /dev tmpfs 218M 0 218M 0% /dev/shm tmpfs 218M 4.4M 213M 2% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 218M 0 218M 0% /sys/fs/cgroup /dev/mmcblk0p1 63M 21M 43M 33% /boot pi@raspberrypi:~ $ sudo vi /etc/fstab proc /proc proc defaults 0 0 /dev/mmcblk0p1 /boot vfat defaults 0 2 /dev/mmcblk0p2 / ext4 defaults,noatime 0 1 # a swapfile is not a swap partition, no line here # use dphys-swapfile swap[on|off] for that ##### ramdisk tmpfs /home/pi/music tmpfs defaults,size=400m 0 0 pi@raspberrypi:~ $ sudo reboot pi@raspberrypi:~ $ df -h Filesystem Size Used Avail Use% Mounted on /dev/root 3.6G 890M 2.5G 26% / devtmpfs 214M 0 214M 0% /dev tmpfs 218M 0 218M 0% /dev/shm tmpfs 218M 4.4M 213M 3% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 218M 0 218M 0% /sys/fs/cgroup tmpfs 100M 0 100M 0% /home/pi/music /dev/mmcblk0p1 63M 21M 43M 33% /boot
flacをインストール、mpdをインストール
以下のコマンドでインストールできる。
pi@raspberrypi:~ $ sudo apt-get install flac pi@raspberrypi:~ $ sudo apt-get install mpd
あとはmpd.confを編集してmpdを動かすだけで音が出るはず。
wikieditish message: Ready to edit this entry.
A quick preview will be rendered here when you click "Preview" button.