Hi Folks,
its great work you are doing on your distribution!
My Pi isn't actually running the raspify distro but its built based upon what you guys do.
I have all my CDs ripped on a drive connected to a Mac Mini as part of a Plex Media Server and Plex OSX client 5.1 set up in the main Lounge. We have another room with a nice 2.1 stereo set up and I was looking for a means of getting all the audio streamed into it. The obvious choice was another Mac Mini, ATV (ridiculously expensive to buy a v2 now and jailbreak), Sonos, Roku box etc.
The HiFi system has a Cambridge Audio DacMagic which had the USB input spare so I ordered up a Pi – I'd needed an excuse to buy one and this seemed to be it. With a nice familiar Linux environment and a few hours tinkering it was up and running headless on a wired network attached to the DAC and working perfectly. I'm sure its pretty much the same as everyone else's setup:
* Fast SD Card
* 64mb GPU Memory
* Modest over clock
* samba/cifs mount through to the audio share on the Mac
* Alsa finds the DAC as
[card 1: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]
* mpd with the following bits of config specific to me:
group "audio"
bind_to_address "any"
zeroconf_enabled "yes"
zeroconf_name "Music Room Hifi"
audio_output {
type "alsa"
name "Cambridge Audio DAC Magic"
device "hw:1,0"
}
mixer_type "disabled"
audio_buffer_size "2048"
buffer_before_play "10%"
* mpc – to kick off scans of the music directory
* id3v2 – to help with re-tagging some tracks
* avahi-daemon – so mpd can advertise itself to clients on the LAN
* noip-duc-linux daemon – the pi is responsible for updating the house's no-ip.org DNS record
* denyhosts daemon – to auto ban sshd attacks and update /etc/hosts.deny
* tree – to pretty print directory structures
* dnsutils and whois – to help check ip addresses that end up in /etc/hosts.deny
* htop – lazy pretty ncurses top
Everything came from the raspbian repos other than noip-duc-linux which was compiled locally.
On the client side of things we have MPod and MPad for iOS devices and MPDroid for the Tab 2.0
The Pi has been up and running for a week now and its been doing everything pretty much perfectly. Initially I found that PCM output was getting restricted to 44.1Khz – but – as soon as I removed:
format "44100:16:2"
from mpd.conf (along with other mixer settings so alsa left everthing to hardware) alsa sent the raw sound stream straight into the DAC. I could see the sample frequency rate changing as expected on the front of the dac depending on the file being played. Playing normal 320kbs mp3 sources the mpd process runs at about 10% of the cpu – maybe double that for 48Khz flac files – its quite funny that using htop to monitor processes uses up 5% of the cpu
Today I added some other .flac files into the library that are extracted audio streams with a sample rate of 96Khz – the files are approx 100-130mb in size. When I play them back via mpd (variable bit rate ~3000kbs, sample rate 96000khz) I can notice tiny clicks and jumps in the sound like the Pi is not coping too well – the mpd process is now using 45% of the cpu.
I am wondering if there are some things I could do to improve on things ?
* I'm sure its not a network bandwidth issue pulling these files over a wired lan. Has anyone experimented with the NFS client on the Pi ? its it likely to give any IO improvement over Samba/cifs ?
* Is this an issue with USB bus bandwidth ? The only thing connected externally on the USB bus is the DAC
* Is it worth going up another step with overclocking from modest ?
* diverting from the main repo build of mpd ?
Thanks again
Ian
Hello Ian, and welcome to RaspyFi! I read your post with great pleasure, you seem to know what you're doing, and sure you're deep into digital audio!
The issue you are reporting are due to a combination of hardware\software flaws on the Raspberry Pi. If you try to feed to your dac an audio stream with resolution bigger than 48khrz 16 bit, the pi cannot cope with the bandwith.
In these scenario there are lot of data losses during the usb transfer, because if the handler of the usb doesn't receiver real time responses, it drops the packet involved, and this is what makes your sound so horrible.
I'm trying to cope with that, I tried every single tweak, but nothing seem to work. I'm waiting the foundation to solve the issue, since it seems the driver for the Broadcom soc is buggy.
The only way you can get undistorted audio is, unfortunately, to force a resampling to 44,1\16 or 48\16 if you prefer. But, if your dac is compatible with 1.1 standards you can try to add the following line
dwc_otg.speed=1
in
/boot/cmdline.txt
This will solve the packet loss issue if your dac is capable of working in 1.1 mode. Please consider that, by enabling this, your ethernet will work considerably slowly, cause the ethernet chip works through the usb bus.
Please let me know!!!
In the meanwhile you can check this thread, there is a guy who's working on the usb driver:
Hey,
thanks for taking the time to read my post. The Pi is working out wonderfully well all things considered.
I haven't looked too much at the architecture of the Pi but I kinda guessed there is likely a single USB 2.0 bus for pretty much everything including the network interface and sound card. Bandwidth is going to be in contention and probably made worse by the fact the DAC magic I have is likely USB 1.0 which I think will effect asynchronous IO. Its this one here.
I'm not sure what the USB speed of the DAC is ?
The Mac Mini/Plex copes ok with the 96Khz flacs – but – its got a bit more grunt than the pi. This goes straight into a Yamaha AV amp via TOSLink and out to KEF speakers and MJ Acoustics reference sub. As nice as that 5.1 set up is I prefer music in true stereo – the Pi is running through the Cambridge Audio stuff above and some Bowers & Wilkins speakers and its much better for 2 channel stereo – a much more detailed and warmer sound. I'll keep an eye on the USB driver above and see how it comes along.
I added in a bit more functionality today in the form of mpdscribble. To be able to scrobble tracks up to last.fm takes about 2mb of ram but given this is a head less music box there is plenty of ram left to play with.
If it helps somebody what you have to do is this:
read about it first:
apt-cache show mpdscribble
then install it:
sudo apt-get install mpdscribble
then configure it as a daemon:
vi /etc/default/mpdscribble
and set:
# Whether to enable system wide daemon
MPD_SYSTEMWIDE=1
# user/group to use (mpdscribble:mpdscribble are default)
USER=mpdscribble
GROUP=mpdscribble
vi /etc/mpdscribble.conf
and set:
pidfile = /var/run/mpdscribble.pid
daemon_user = mpdscribble
(if you don't want mpdscribble to log into /var/log/daemon.log via syslog do)
log = /var/log/mpdscribble/mpdscribble.log
verbose = 2
journal_interval = 600
configure your last.fm username and password in the [last.fm] section
[last.fm]
url = http://post.audioscrobbler.com/
username =
password =
(Note
you can set your password as an md5 hash using
echo -n '' | md5sum | cut -f 1 -d " "
)
start the daemon:
service mpdscribble start
look in the log:
tail -100f /var/log/mpdscribble/mpdscribble.log
and you'll see mpdscribble output:
connected to mpd 0.16.0 at (null)
starting mpdscribble (mdc 0.22)
loaded 0 songs from /var/cache/mpdscribble/lastfm.journal
go play some music and you'll see the likes of:
new song detected (John Frusciante – After The Ending), id: 86, pos: 18
[last.fm] handshake successful
[last.fm] sending 'now playing' notification
[last.fm] OK
1362940743, songchange: Russian Circles – 309 (530)
new song detected (Russian Circles – Mlàdek), id: 99, pos: 1
[last.fm] submitting 1 song
[last.fm] OK
[last.fm] sending 'now playing' notification
[last.fm] OK
All done. Every time mpd plays a track it will scrobble it to last.fm
and the only other thing you may wish to do add some log rotation – so in:
/etc/logrotate.d
create a new file called:
mpdscribble
and add the log rotation scheme:
/var/log/mpdscribble/*.log {
weekly
missingok
rotate 7
compress
notifempty
copytruncate
create 600
}
and the logs will get rotated in-line with mpd.
Most Users Ever Online: 200
Currently Online:
7 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Gyp: 82
yoghurtlidlicker: 37
PaulM: 36
icai: 35
Derek: 29
Karsten: 27
tc-fi: 22
Ronaldo: 21
ENSen: 21
chriz: 20
Member Stats:
Guest Posters: 3619
Members: 569
Moderators: 0
Admins: 1
Forum Stats:
Groups: 4
Forums: 10
Topics: 469
Posts: 13163
Newest Members: polo2016, dongdong8, wlpwlp, Sager, ninestab123, lmx66, lmx, jlgg, chenyan, guoyanying
Administrators: admin (401)