RaspyFi » Documentation http://www.raspyfi.com Pi never sounded so good! Mon, 16 Dec 2013 15:20:41 +0000 it-IT hourly 1 Raspberry Pi Usb Audio fix http://www.raspyfi.com/raspberry-pi-usb-audio-fix/ http://www.raspyfi.com/raspberry-pi-usb-audio-fix/#comments Fri, 10 May 2013 11:46:44 +0000 admin http://www.raspyfi.com/?p=392 Ladies and gens, finally usb audio problems affecting the Pi, have been solved! For those of you seeking a Raspberry Pi Usb Audio fix, you’re in the right place!  I was compulsively lurking this thread hoping that the foundation would eventually

L'articolo Raspberry Pi Usb Audio fix sembra essere il primo su RaspyFi.

]]>
Ladies and gens,

finally usb audio problems affecting the Pi, have been solved! For those of you seeking a Raspberry Pi Usb Audio fix, you’re in the right place!  I was compulsively lurking this thread hoping that the foundation would eventually find a fix for the usb issue. What was it?

Well, to make it simple, when the usb bus of the pi was receiving lot of i\o requests, it cannot satisfy them all, and as a result part of the data travelling trough usb was lost. So, while communicating with a usb dac , if the file being played was more than 44/16 the usb bus was overwhelmed and some parts of the data (packets, jargon comes in finally) was lost. If you google for packet loss, you can figure out what was happening.

I’ve been investigating a lot on the matter, hoping to find a Raspberry Pi usb audio fix , tried almost everything. But this was in the hands of the foundation, since there is no extensive documentation available.

Finally, the Raspberry Pi usb Audio Fix came on Thu May 09, 2013 9:19 am, from gsh (which has my imperiture gratitude)

Basically, this updates some part of the pi firmware and kernel, via rpi-update (this is an experimental branch you won’t find on the master branch of rpi-update by hexxeh 

For those of you on RaspyFi, update is hassle free since you already have rpi-update up and running. Just do this to enable the Raspberry Pi Usb Audio Fix:

sudo apt-get install git-core binutils

sudo BRANCH=fiq_split rpi-update

Let it run, it will need almost 20 minutes to complete. In case you’re receiving some errors, just retry. Sometimes the git servers are not able to face the requests of thousands users simoultaneusly.

Once it’s done, and you’re not getting any error, just reboot.

Now, it’s time to enable bit perfect playback on RaspyFi via mpd.conf

sudo nano /etc/mpd.conf

the line:

format “44100:16:2″ # optional

becomes

#format “44100:16:2″ # optional

ctrl + x to save.

Now, we’ll restart mpd:

sudo /etc/init.d/mpd restart

 

Now, play and enjoy! Files >44/16 will be played without glitches, and I hope that async dacs will work flawlessly as well! I cannot confirm this by now since I don’t have any async to the test this Raspberry Pi usb audio fix for them… But please let me know via comments below.

To check if your Pi now resides in Bit Perfect heaven just type, while playing:

cat /proc/asound/card0/pcm0p/sub0/hw_params

The output will show you current bit rate and bit depth, that should be the same as the file. Please note that if a bit rate/bit depth is not supported by your dac, mpd will automatically resample it to  the nearest supported one.

Here, an example (showing different bitrates/bitdepths, with perfect sound)

Raspberry Pi in bit perfect mode

Raspberry Pi in bit perfect mode

Obviously, this raspberry pi usb audio fix will be implemented and working out of the box in next Release of RaspyFi, which is in its final stage of development.

This raspberry pi audio fix, also can be excecuted on plain Raspbian and all the other distros out there. Just type that:

sudo apt-get install git-core
sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update
sudo BRANCH=fiq_split rpi-update

Et voilà, you’re done! Please let me know if it works for you, and if you got some troubles doing it !

 

UPDATE FOR SAMBA USERS

As suggested by Klinkt Beter and Carlo Bernardini this fixes the samba issues for async dac users. With my new xmos to i2s dac  and this fix I don’t have any stuttering at 24/96 , some reports this works well with 24/192 as well. So edit /etc/auto.nas as follows:

Nas    -fstype=cifs,file_mode=0777,dir_mode=0777,iocharset=utf8,sec=ntlm,rsize=2048,wsize=4096,cache=strict,username=pi,password=    ://192.168.nasip/sharename

 

 

L'articolo Raspberry Pi Usb Audio fix sembra essere il primo su RaspyFi.

]]>
http://www.raspyfi.com/raspberry-pi-usb-audio-fix/feed/ 127
Wi-fi on Raspberry Pi, a simple guide http://www.raspyfi.com/wi-fi-on-raspberry-pi-a-simple-guide/ http://www.raspyfi.com/wi-fi-on-raspberry-pi-a-simple-guide/#comments Tue, 19 Mar 2013 16:24:32 +0000 admin http://www.raspyfi.com/?p=321 Since the Raspberry Pi comes only with a wired network, it could be useful for lot of us to get it wi-fi ready. Wi-fi on Raspberry Pi can be achieved with little effort and at cheap expences. We do only

L'articolo Wi-fi on Raspberry Pi, a simple guide sembra essere il primo su RaspyFi.

]]>
Since the Raspberry Pi comes only with a wired network, it could be useful for lot of us to get it wi-fi ready. Wi-fi on Raspberry Pi can be achieved with little effort and at cheap expences.
We do only require a compatible wi-fi dongle, and the best candidate for the job is the Edimax EW-7811Un.
These are the features:

  • Supports 150 Mbps 802.11n, so if you have a N network, you’ll have enough bandwith to stream even Hi-res FLACs
  • Low power consumption, it can work directly attached to the Pi withouth a powered usb hub
  • Works automatically with Raspbian, since it’s drivers are included
  • It’s very small, so there’s plenty of space left on the Pi to attach your USB DAC or USB Dongle
  • It’s quite cheap, you can find easily at prices above 10 euros (see later)

You can buy it on Ebay

or here on Amazon .

Now we’ll start the setup of the WI-Fi on Raspberry Pi. RaspyFi comes with Wicd-curses already installed and running, this a user friendly gui  wi-fi setup utility. With Wicd-curses the setup of Wi-Fi on Raspberry Pi is simple and straightforwarding. You should access the Pi’s shell, this can be done in 2 ways:

  • Get a monitor and a keyboard attached to the Pi
  • Connect trought SSH, the Pi has to be connected to a wired network to do this. Refer to this guide to do this.

 

If you’re using Raspbian, and you’ve not installed Wicd-curses just type:
sudo apt-get update
sudo apt-get install wicd-curses

Ok, now we are ready to start, type:
sudo wicd-curses
You’ll get a list of the wireless network found by the Raspberry PI

raspberry wi-fi

 

 

Now, you can select your Wi-fi Network, just highlight it with arrow keys and press right arrow key to edit its properties:

raspberry wi-fi1

 

Sorry for Italian language, (not being nationalist!!) but you should be able to guess what these lines mean. You just insert the WEP or WPA KEY. If you wish, you can assing a static ip, configure alternative dns and so on. Remember to check the auto connection.

If you wish to have static ip, just put the ip you desire (e.g. 192.168.1.3), the subnet mask (255.255.255.0) and your router’s ip (e.g.: 192.168.1.1). Please note that the Ip of the Raspberry Pi and the gateway ip should have the same index, so if your router has 192.168.1.ip then also the raspberry pi should have the same, the only thing that will change is the last ip digits (192.168.1.ip).

 

When you’re done, just press F10 to save, then it should connect!

 

Now you’ve Wi-Fi on Raspberry Pi! Feel confident to try other wi-fi dongles other than the one suggested here. You can check the Raspberry Pi compatiblity list.

The Main WICD-CURSES windows, will also tell you the ip of your Raspberry Pi, so you can be able to connect to it via GMPC or your preferred mpd client.

 

UPDATE

Since I got some reports of Wi-Fi dongle not being recognized, this is how you can sort it out:

Enter in wicd-curses,
sudo wicd-curses
then press P (that stands for preferences). You’ll find that there’s a field called wireless interface, which is empty. Just write wlan0
in it. Then F10 to save.

Then, back to the main screen, hit R to refresh, et voilà!!!
Thanks to Andrea Zani from tforum for the hint!

L'articolo Wi-fi on Raspberry Pi, a simple guide sembra essere il primo su RaspyFi.

]]>
http://www.raspyfi.com/wi-fi-on-raspberry-pi-a-simple-guide/feed/ 42
Power Supply for Raspberry Pi, what you should know about http://www.raspyfi.com/power-supply-for-raspberry-pi-what-you-should-know-about/ http://www.raspyfi.com/power-supply-for-raspberry-pi-what-you-should-know-about/#comments Fri, 15 Mar 2013 00:31:11 +0000 admin http://www.raspyfi.com/?p=303 Every so called audiophile, once in his truthless life, will look himself at the mirror, and ask himself, one fundamental question: Is my power supply good enough?  Terrible drama then, desperation, no certainesses, no peace. Then he will start to

L'articolo Power Supply for Raspberry Pi, what you should know about sembra essere il primo su RaspyFi.

]]>
Every so called audiophile, once in his truthless life, will look himself at the mirror, and ask himself, one fundamental question:

Is my power supply good enough? 

Terrible drama then, desperation, no certainesses, no peace. Then he will start to browse and google compulsively, ask in forums, call his mom, loose hairs etc etc.

Well, at this point, there is only one thing you can do. Get a better one. So, for those of you in these miserable condition, here’s a tip on how to choose wisely a good power supply for Raspberry Pi.

Let’s introduce what are we talking about

Why Power supply is so important? Trivially speaking, we can say that our fancy audio\electronic gizmos work with electricity. And, the better and the most stable electricity we can give to them, the better they will work. This comes to an extreme importance in Audio, but can be true also for all kind of electrical equipment.  Let’s see why:
Most circuits works with DC. DC is direct current, which is:

used to refer to power systems that use only one polarity of voltage or current, and to refer to the constant, zero-frequency, or slowly varying local mean value of a voltage or current.For example, the voltage across a DC voltage source is constant as is the current through a DC current source. The DC solution of an electric circuit is the solution where all voltages and currents are constant. It can be shown that any stationary voltage or current waveform can be decomposed into a sum of a DC component and a zero-mean time-varying component; the DC component is defined to be the expected value, or the average value of the voltage or current over all time.
 
http://en.wikipedia.org/wiki/Direct_current
 

Usually, direct current is obtained by rectifying AC (Alternated current), which flows by our wall socket. A rectifier is an electrical device that converts alternating current (AC), which periodically reverses direction, to direct current (DC), which flows in only one direction.
This is the first quality sensible step that our electrons are faced to do. In these process, it could happen that some residuals of the AC’s typical voltage oscillations will remain in the DC stream, producing some kind of “fluctuation” from our desired voltage.
This phenomenon is called ripple:

The most common meaning of ripple in electrical science is the small unwanted residual periodic variation of the direct current (dc) output of a power supply which has been derived from analternating current (ac) source. This ripple is due to incomplete suppression of the alternating waveform within the power supply.

This could be better described with picture below:

ripple - unfiltered vs filtered

 

As you can see, by simply rectifiying AC (first scenario) we will end with lot of oscillations in voltage, this will result in poor performance (in audio domains). As for our Raspberry Pi, a power supply with high ripple will result in malfunctions, sd card corruptions etc etc.
In the second picture, we’ll see how a filter applied to our power supply can dramatically reduce ripple. This more stable voltage will result in a HUGE improvement in audio applications, and for our raspberry Pi will mean better working conditions.
Those of you who already know about this matter could find this explanation extremely reductive and simple. I know it is, but I’m trying to keep things simple.

So, what power supply should I choose? There are 2  main categories:

Linear power supplies

StepperPowerSupplySchematic

 

These are the type we discussed earlier, as you can see the first component (from left side) is a power trasformer, this transform the voltage from our wall socket to a desired one (let’s say 24 volts), passing this step the current is still alternated.
Then it passes trough some diodes (1,2,3,4), their function is to rectify current and make it dc. Passing this step our DC is very dirty, and that’s why there will be some filtering capacitors (C) to smooth it out and reduce ripple. This is a very simple schematic, but should give you the idea. Usually, where a given voltage with very low ripple is needed you’ll use also a voltage regulator. This component will reduce the imput voltage to a given one, and provide very low ripple output. Capacitors are often used to further smooth the output voltage, and their quality is hugely responsible of subsequent psu quality.
The main disadvantage of these kind of power supply is their efficiency. Lot of energy got wasted in this process (as heat, for example) and they usually drain lot more current than they put out.

Then, we’ll find

Switching power supply

switched-mode power supply (switching-mode power supplySMPS, or switcher) is an electronic power supply that incorporates a switching regulator to convert electrical power efficiently. Like other power supplies, an SMPS transfers power from a source, like mains power, to a load, such as a personal computer, while converting voltage and current characteristics. An SMPS is usually employed to efficiently provide a regulated output voltage, typically at a level different from the input voltage.

Unlike a linear power supply, the pass transistor of a switching-mode supply continually switches between low-dissipation, full-on and full-off states, and spends very little time in the high dissipation transitions (which minimizes wasted energy). Ideally, a switched-mode power supply dissipates no power. Voltage regulation is achieved by varying the ratio of on-to-off time.

 

So as you can understand, switching power supplies achieve the same result by turning on and off repeatedly (thousands of times per second) the electrical stream, resulting in better efficiency (no rectification, no voltage transformation, no voltage regulation). The main disadvantage are in terms of quality. Switching power supply usually have higher ripple than linear power supplies.

So now the choice is between quality and efficiency. Since our raspberry Pi will draw as much as 700 mA (current) at 5 ± 0,25 volts      (voltage) we should choose a psu which can output at least 1 amp (extra 300mA for connected devices such as DACs or usb keys), whith a voltage between 4,75 and 5,25 volts. Any different value from these will (and I mean, it will) result in SD Card corruption, especially if you decided to overclock your PI.
By choosing a linear power supply for Raspberry Pi, like

, you’re sure gettin highest quality power supply, but this will result in lot of enery wasted and a higher electricity bill (of course, relatively speaking) (please also mind that you should change the DC jack in favour of a microUSB plug). By the other hand a switched mode power supply for Raspberry Pi like this (or

if you’re on the other side of the Atlantic)  will  be an energy saving savy choice but quality wise, is the worst scenario you can get.

And after telling you all of this, I’ll let you cry in tears and desperately wating to know what to do by saying goodbye !

Next , will come a comparison of multiple power supply for Raspberry Pi, and a project of a custom power supply which will hopefully satisfy both quality and efficiency!

L'articolo Power Supply for Raspberry Pi, what you should know about sembra essere il primo su RaspyFi.

]]>
http://www.raspyfi.com/power-supply-for-raspberry-pi-what-you-should-know-about/feed/ 12
Hiface on linux: Getting Hiface 1 working on RaspyFi and Debian http://www.raspyfi.com/hiface-on-linux-getting-hiface-1-working-on-raspyfi-and-debian/ http://www.raspyfi.com/hiface-on-linux-getting-hiface-1-working-on-raspyfi-and-debian/#comments Tue, 05 Mar 2013 15:30:58 +0000 admin http://www.raspyfi.com/?p=290 Hiface on Linux, finally done! Well guys, since some of you wanted to use the HiFace 1 on RaspyFi, here’s how to get it working. Basically all you need to do is compiling it’s drivers, and execute it on boot.

L'articolo Hiface on linux: Getting Hiface 1 working on RaspyFi and Debian sembra essere il primo su RaspyFi.

]]>
Hiface on Linux, finally done!

Well guys, since some of you wanted to use the HiFace 1 on RaspyFi, here’s how to get it working. Basically all you need to do is compiling it’s drivers, and execute it on boot. I plan to include those drivers on next release of RaspyFi.

Let’s start:

In order to build the driver you need to install your kernel-headers, the build-essential package and git-core binaries, this is quite a hefty amount of data, so make sure you have at least 600 mb free on your SD Card:

 

apt-get install kernel-headers-$(uname -r)
apt-get install build-essential
apt-get install git

Now, we’ll clone the git repository

git clone git://github.com/panicking/snd-usb-asyncaudio.git

Then, we are ready to build our driver:

cd snd-usb-asyncaudio
make

Then, we’ll start the module by typing:

 

sudo insmod snd-usb-asyncaudio.ko

Then, we should add the module to /etc/modules in order to make it start at system boot.

Et voilà! Hiface on Linux, so on RaspyFi!

This tutorial is made thanks to following pages:

 

https://github.com/panicking/snd-usb-asyncaudio/wiki

https://github.com/panicking/snd-usb-asyncaudio

L'articolo Hiface on linux: Getting Hiface 1 working on RaspyFi and Debian sembra essere il primo su RaspyFi.

]]>
http://www.raspyfi.com/hiface-on-linux-getting-hiface-1-working-on-raspyfi-and-debian/feed/ 31
RaspyFi Rc2 – How it’s made and list of all the optimizations http://www.raspyfi.com/raspyfi-rc2-how-its-made-and-list-of-all-the-optimizations/ http://www.raspyfi.com/raspyfi-rc2-how-its-made-and-list-of-all-the-optimizations/#comments Thu, 14 Feb 2013 00:25:35 +0000 admin http://www.raspyfi.com/?p=270 These optimizations come from a trial and error procedure, which led me to get an overall idea of what influences music playback performance and what doesn’t. Basically, less processes running don’t improve directly the outcome in terms of quality, but

L'articolo RaspyFi Rc2 – How it’s made and list of all the optimizations sembra essere il primo su RaspyFi.

]]>
These optimizations come from a trial and error procedure, which led me to get an overall idea of what influences music playback performance and what doesn’t. Basically, less processes running don’t improve directly the outcome in terms of quality, but it improves overall computing performance, which indirectly affects playback quality.
Then, special attention is required to alsa optimization, using hw instead of plug or mmap_emu ensures raspyFi directly controls the Dac. So this is a big step forward.
Then, compiling the latest version of Mpd brings minor under-the-hood fixes which tend to further improve overall result.
So, this is the entire process to obtain what RaspyFi Rc2 is.

First, update to latest kernel and firmware. This brings minor usb optimizations, unfortunately the bugs affecting over 44,1 khrz playback are still present. The foundation reported to be working hard on the matter (they hired a specialist to solve the issue, at least that’s what i got…)

sudo apt-get install git-core
sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update
sudo rpi-update

Then, we’ll strip down the distro. This aims basically to use less disk space, but less processes active (especially X graphic user interface) leave the pi arm cpu quieter. Some folks believe that less processes running= better sound. I am not one of those. I indeed can say that less cpu used= less power drain and more responsive system. This can indirectly improve playback quality, also for electrical inducion reasons. But my physics knowledge is not enough to explain clearly the reason why.

Sudo apt-get update

Getting a list of all packages installed give us an idea of what we can remove.

dpkg --get-selections

Let’s remove what we don’t mind to use

sudo apt-get remove aspell desktop-base desktop-file-utils dictionaries-common dillo fonts-droid fonts-freefont-ttf fontconfig fontconfig-config galculator gnome-icon-theme gnome-themes-standard gpicview gsettings-desktop-schemas gsfonts gsfonts-x11 hicolor-icon-theme leafpad lightdm lightdm-gtk-greeter lxappearance lxde lxde-common lxde-core lxde-icon-theme lxmenu-data midori mime-support openbox omxplayer penguinspuzzle x11-common wpagui python3 python3-minimal python-pygame x11-common

Python games? Glad to ask, but no.

sudo rm -rf python_games

Opt contains lot of heavy stuff, such like a damn 1080i video.

sudo rm -rf /opt/vc/src/hello_pi/hello_video/

Python, go away!

sudo apt-get remove `sudo dpkg --get-selections | grep -v "deinstall" | grep python | sed s/install//`

Removing gcc, we’ll install latest version later

sudo apt-get remove gcc-4.4-base:armhf gcc-4.5-base:armhf gcc-4.6-base:armhf

Clean unnecessary packages

sudo apt-get autoremove
sudo apt-get clean

Ok, now let’s update the software environment

sudo apt-get update
sudo apt-get upgrade

sudo apt-get clean

let’s check how much space did we free up:

 

df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 1.8G 870M 804M 52% /
/dev/root 1.8G 870M 804M 52% /
devtmpfs 235M 0 235M 0% /dev
tmpfs 49M 252K 49M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 98M 0 98M 0% /run/shm
/dev/mmcblk0p1 56M 21M 36M 37% /boot
tmpfs 98M 0 98M 0% /tmp

870, could be worse

We don’t need swap. Do we?

sudo swapoff -a
cd /var
sudo dd if=/dev/zero of=swap bs=1M count=100

 

Now, we’ll install Mpd. We will now get and install the vanilla package, the one provided with debian. We will use this to get it’s infrastructure, and then we’ll install latest version from source.

sudo apt-get install mpd mpc

Now we install both prerequisites to compile mpd and mpd’s dependencies

 

sudo apt-get install aptitude wget binutils gcc make subversion autoconf automake autotools-dev libtool pkg-config build-essential libncurses5-dev libncursesw5-dev gcc libglib2.0-dev

sudo apt-get install libfaad2 libfaad-dev libflac8 libflac-dev libogg0 libogg-dev libvorbis0a libvorbis-dev libid3tag0 libid3tag0-dev libmad0 libmad0-dev libcue-dev libcue1 libasound2 libasound-dev libasound2-dev libao-dev libwavpack-dev libwavpack1 libsamplerate0 libsamplerate-dev libmikmod2-dev libmikmod2 libmikmod-dev libshout-dev libavformat-dev libavcodec-dev libavutil-dev libaudiofile-dev libcurl4-openssl-dev libmms-dev libmms0 libtwolame-dev libtwolame0 libmp3lame-dev git-core

Now, we clone the official mpd repo, in order to obtain and compile latest mpd version. As root:

sudo su
cd /home/pi
git clone git://git.musicpd.org/master/mpd.git

cd ./mpd

./autogen.sh

We then configure it to use few options, making mpd more lightweight.

./configure --disable-bzip2 --disable-iso9660 --disable-zzip --enable-id3 --disable-sqlite --enable-ffmpeg --enable-alsa --disable-wave-encoder --enable-pipe-output --enable-httpd-output --disable-recorder-output --disable-sndfile --enable-oss --enable-shout --disable-pulse --disable-ao --disable-mad --disable-inotify --disable-ipv6 --enable-curl --disable-mms --disable-wavpack --disable-lame-encoder --disable-twolame-encoder --enable-vorbis --enable-lsr --with-zeroconf=auto
make
make install
sudo su
/etc/init.d/mpd stop
echo DAEMON=/usr/local/bin/mpd >>/etc/default/mpd
/etc/init.d/mpd start
mkdir -p ~/.mpd/playlists

Now, we’ll start configuring mpd, editing the mpd.conf file

sudo nano /etc/mpd.conf

What interest us is:

#group "nogroup"

Becomes

group "audio"

 

Mpd will belong to “audio” group, which will be useful for setting mpd’s priorities.

Then

bind_to_address "localhost"

that will become

bind_to_address "any"

Activating auto-update by uncommenting following line, this will enable mpd to automatically update its music database when something new is added or removed.

#auto_update "yes"

Then

audio_output {
type "alsa"
name "My ALSA Device"
device "hw:0,0" # optional
format "44100:16:2" # optional
mixer_device "default" # optional
mixer_control "PCM" # optional
mixer_index "0" # optional

that will become

audio_output {
type "alsa"
name "USB Dac"
device "hw:0,0" # optional
format "44100:16:2" # optional
# mixer_device "default" # optional
# mixer_control "PCM" # optional
# mixer_index "0" # optional

Then we’ll uncomment the lines regarding the buffer

audio_buffer_size "2048"
buffer_before_play "10%"

Ctrl+ x to save, then y to confirm.

Now we assign to our usb dac the device number 0, which is the default for mpd and the mixer. We can do so by commenting out the line

options snd-usb-audio index=-2

in

sudo nano /etc/modprobe.d/alsa-base.conf

By doing so, RaspyFi will use as default the USB Dac. If a usb dac is not connected, then the default audio out will be the analog jack. Nasty!

Now, we create our music directories and mount points. We can use multiple directories, such a nas and a usb drive, by putting a shortcut in mpd default music directory.

mkdir /mnt/nas
chmod 777 /mnt/nas

Add the following line in /etc/fstab

nano /etc/fstab
//192.168.1.NasIP/YourShareName /mnt/nas cifs username=pi,password=,uid=mpd,file_mode=0644,dir_mode=0755,iocharset=utf8,rsize=130048,wsize=4096 0 0

This will automatically mount our samba share on /mnt/nas.

Now we mount an usb drivE. Please note that it is preferrable to use a fat formatted drive, this uses less resources. This is quite important, considering the notorious usb problems.

See how the drive is called

sudo fdisk -l

in my case:
/dev/sda1

We create the music folder:

mkdir /media/music
chmod -R 777 /media/music
mount /dev/sda1 /media/music

Then we add this line to /etc/fstab

sudo nano /etc/fstab

/dev/sda1 /media/music vfat defaults 0 0

Ctrl+ X then, y
We now add a symlink into the default music directory, this will give us the possibility to store our music library on multiple locations. For example, we can have a part of our library on the nas and another one on a usb drive

cd /var/lib/mpd/music
sudo ln -s /mnt/nas
sudo ln -s /media/music

Installing wi-fi client:

sudo apt-get install wicd-curses
cd /var/lib/mpd/music/

 

Tweaking

This is a fine tuning of the Pi software echosystem, even if we cannot get rid (as for now) of the usb problems, we can still do something to improve general usb performance. Adding this line to:

sudo nano /etc/modprobe.d/alsa-base.conf

options snd-usb-audio nrpacks=1

This sounds really effective to my hears!

There’s another tweak that should fix the usb problems, you should add a line in the cmdline.txt. This line turns the usb into 1.1 mode. Please note that by doing so, both usb and ethernet performance in terms of transfer speed will be greatly reduced. This doesn’t work for me, as my Usb Dac doesn’t work with this mode. Feel free to try it, please report if it solves the problem with your dac. You can remove this tweak by deleting the added parameter.

sudo nano /boot/cmdline.txt

dwc_otg.speed=1

Next step is to set the Pi’s cpu to work always at its full power. This is due to the fact that mpd for an unknown reason doesn’t trigger the scaling governor to increase computing speed while in use. By enabling the “performance” option, we’ll be sure that mpd has the full power it deserves.
First, we check out which power management profile we have:

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
powersave

Ok, let’s put the Pi in performance mode:

sudo su
echo -n performance > /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

Check again with previous command to see if it is effective.
Using hw, insted of plug and mmemu

nano /etc/asound.conf

cancel existing text and paste this

pcm.!default {
type hw
card 0
}

ctl.!default {
type hw
card 0
}

LAN TUNING

sudo nano /etc/sysctl.conf

add line

fs.inotify.max_user_watches = 524288

If you should have some problems, remove it. In my configuration I don’t have any problems, but sometimes they could occour depending on traffic and tcp tranfer size.

Adjust limit values of the audio group

First we add mpd to the audio group

sudo nano /etc/security/limits.conf
@audio - rtprio 99
@audio - memlock unlimited
@audio - nice -19

Then we set mpd to have the highest priority (niceness). We do so by adding a script that starts afer mpd that renices it to -20

sudo su
cd /etc/init.d
nano myruns

We put this in the script:

#! /bin/sh
# /etc/init.d/myruns
#
### BEGIN INIT INFO
# Provides: myruns
# Required-Start: $all
# Required-Stop: $mpd
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Renicing mpd
# Description: Being nice with music
### END INIT INFO
# Some things that run always
touch /var/lock/myruns

MAXTRIES=15
TRIES=0

# Carry out specific functions when asked to by the system
case "$1" in
start)
#
# mount music
#
renice -n -20 -p `pgrep mpd`
;;
stop)
echo "Exiting myruns"
;;
*)
echo "Usage: /etc/init.d/myruns {start|stop}"
exit 1
;;
esac

exit 0
Ctrl+ x then y

We then set this as script and we add it to the init.d boot sequence:

chmod 755 myruns
update-rc.d myruns defaults

NAS tuning

sudo nano /etc/fstab

adding line
uid=mpd,file_mode=0644,dir_mode=0755,iocharset=utf8,rsize=130048,wsize=4096

Now we selectively deactivate some process, so they don’t start up nad we’ll have less active processes.

sudo apt-get install rccconf
sudo rccconf

The services I disabled:

cron – scheduler
lightdm – graphic login manager
motd – message of the day for ssh
plymouth- graphic bootlogo
x11-common graphic interface

This broke somehow my ssh server, avoiding me to connect via ssh, so be aware of it. If this will happen you should have access to your pi via a monitor and a keyboard and reinstall sshd via those commands:

sudo apt-get remove openssh-client openssh-server
sudo apt-get install openssh-client openssh-server

Now, we proceed to remove everything we used to compile and several things more. In case we don’t think we’re going to recompile something again.

sudo apt-get remove autoconf automake autotools-dev binutils build-essential dpkg-dev g++ g++-4.6 gcc gcc-4.6 libglib2.0-dev libid3tag0-dev libsamplerate0-dev libstdc++6-4.6-dev make pkg-config git-core x11-common dbus-x11 libice6 libx11-6 libx11-data libx11-xcb1 libxext6 libxi6 libxmuu1 libxtst6 xauth xkb-data fonts-freefont-ttf

cd /home/pi
sudo rm -rf mpd

 

That’s all folks, shake and serve with ice!

L'articolo RaspyFi Rc2 – How it’s made and list of all the optimizations sembra essere il primo su RaspyFi.

]]>
http://www.raspyfi.com/raspyfi-rc2-how-its-made-and-list-of-all-the-optimizations/feed/ 24
Anatomy of a PI – USB Audio quality and related issues on Pi http://www.raspyfi.com/anatomy-of-a-pi-usb-audio-quality-and-related-issues-on-pi/ http://www.raspyfi.com/anatomy-of-a-pi-usb-audio-quality-and-related-issues-on-pi/#comments Fri, 11 Jan 2013 17:30:00 +0000 admin http://www.raspyfi.com/?p=146 One of the main concerns of folks who bought the Pi is to use it a media player – streamer – server, using USB Audio. Unfortunately there are some problems with audio stuttering and pop up clicking noises. Just quoting

L'articolo Anatomy of a PI – USB Audio quality and related issues on Pi sembra essere il primo su RaspyFi.

]]>
One of the main concerns of folks who bought the Pi is to use it a media player – streamer – server, using USB Audio. Unfortunately there are some problems with audio stuttering and pop up clicking noises. Just quoting around:

Hey,

I’m experiencing audio stutter while playing movies via the Raspberry Pi to the TV. I used to have the 1080p videos buffering all the time, but I fixed by switching my shares from Samba to NFS, using Hanewin NFS Server. That fixed all the buffering issues and makes the Pi read the shares much, much faster.

http://openelec.tv/forum/134-usage/40394-audio-stuttering

I’m also having problems with RaspyFI, when i comment out the line

format          ”44100:16:2″    # optional

in order to avoi resampling (you remember Audiophilia Hysterica obliges you to think resampling is evil??) I get audio stuttering, especially with flac with samplerate higher than redbook standards . I do really think this is related to an driver issue of the Soc controlling both ethernet and USB.

The main theory circulating on the net states that usb related issues (which can affect wi-fi dongles transfer, keyboard and mouse imputs etc etc) are due to some drivers problems which manifestates themselfs under heavy stress of usb\ethernet pathways, in conjunction and in some cases alone. More precisely there seems that there is some packet loss:

- USB congestion:our devices work in full-speed (USB 1.1 12 Mbit/s) and transmit at max 1 packet of 64 bytes each frame (64 Kb/s). We have analyse the transfer with and USB analyser and ALL packets are correctly transmitted over the wire (no bus reset, no invalid packet, the USB host ack all packet). this mean that the USB Host controller of the raspberry Pi as correctly received and ack the missing USB packet.Our conclusion is that or the libusb or the linux kernel drop some packets and do not raise any error.
We have found a serious issue on the raspberry PI USB stack (or at last the HID USB stack). We produce USB device and have found that we often get missing packet.
We have create an specific firmware illustrate the problem. This debug protocol is very simple the Raspberry will send one packet of 64 bytes, then the device will start a burst of USB transaction. Our USB device work in full speed (USB 1.1) and follow the HID protocol. All packets have the same size (64 bytes). the first uint32_t will contain the current packet number and the second uint32_t will contain the number of packet to send. Each packet is numbered and we stop after burst of 4096 packet of on the first missing packet.

The debug program call libusb-1.0, and will look for one of our device with the debug firmware, then send one USB packet to the device to start the burst. Then we will wait for all packet and check that all packet are send. You can download the source here http://www.yoctopuce.com/tmp/debug_libusb.zip

We have test this code and firmware on many linux platform (i386 and x86_64), and on a ARM based NAS (QNAP TS-219P II). We never get any missing packet. but on the Raspberry PI we always get missing packets. We have check with a USB analyser that the missing packet is correctly sent on the wire (the packet has been correctly acked by the Raspberry PI USB host). It seems that the packet is lost by the Raspberry PI firmware.

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=5249

In addition to this:

The USB driver may not be fixable, the jury is still out on this one. There are three key problems:

1) Documentation on the Broadcom USB controller is proprietary and is not made openly available by the Raspberry Pi Foundation.

2) The USB core for the Broadcom SoC was bought from a 3rd party, and we are told that not even Broadcom has full documentation, nor understands the driver.

3) The Foundation has discovered that the controller and its driver expect realtime response from the ARM core, and if Linux’s non-realtime scheduling doesn’t respond in 1 ms, a split transaction USB event can be dropped. Not surprisingly, this occurs regularly and produces lost mouse clicks, stuck keyboard keys, etc..

That’s a pretty nasty combination of problems, and it means that assuming that it’s fixable may not be a safe prediction. We’ll have to wait and see.

For the time being though, USB and networking (which is implemented over USB) have a large catalogue of issues and incompatibilities. All boards have this inherent problem but YMMV on whether the issues bite you, as it depends on exactly what devices you have connnected and what you’re doing with the board.

In addition to the above faults, the community discovered a PCB track layout error on the board which causes a proportion of the USB chips to overheat owing to an incorrect connection. It doesn’t appear to be critical but wastes power and the heat may shorten board or device lifetime.

Relations are very tense on the forum, and the Foundation has banned people who express their concern about the faults.

http://hardware.slashdot.org/story/12/08/24/2228251/serious-problems-with-usb-and-ethernet-on-the-raspberry-pi

 

So what happens? Under heavy load some of our precious binary vives is lost and never reaches our fancy USB Dac. Setting the resample mode seems to avoid it because of less bandwith is required to stream the audio to the dac, but we don’t want this as we are:

1- Applying some post processing to our audio stream (which, I remember should be evil to us…)
2- Making our hi-res flac library very sad
3- Degrading our listening experience as it is non-bit- perfect (wheter this is perceptible or not, still I don’t know… but we are damn audio purity integralists, aren’t we?)

But, is there a light out of the tunnel? Of course yes, theorethically at least.

As you can find out from that quote:

3) The Foundation has discovered that the controller and its driver expect realtime response from the ARM core, and if Linux’s non-realtime scheduling doesn’t respond in 1 ms, a split transaction USB event can be dropped. Not surprisingly, this occurs regularly and produces lost mouse clicks, stuck keyboard keys, etc..

 

So, if we succeed in compiling a real-time kernel, hopefully out problem will be solved and finally we’ll have bit perfect reproducion. This is already in process, as a superuser from tforumhifi il helping while compiling a custom real-time kernel for RaspyFi, you can follow the iter here on the RaspyFi thread:

http://www.tforumhifi.com/t32285-raspyfi-raspberry-pi-voyage-mpd-progetto-per-un-ottima-sorgente-low-cost

Meanwhile, a possible solution for audio stuttering via usb is made possible by setting the Usb transfer rate to USB 1.1 and setting it in full mode:

We have run some tests today to validate the tentative fixes.

First we have run rpi-update to get the latest fix. Here is my cmdline.txt and the kernel version

CODE: 
root@raspberrypi:/home/pi# more /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
root@raspberrypi:/home/pi# uname -a
Linux raspberrypi 3.2.27+ #160 PREEMPT Mon Sep 17 23:18:42 BST 2012 armv6l GNU/Linux

As expected, Gordon fix does not completely solve the issue of packet loss in this case, but the packet loss seems to happen far less frequently (I have been able to stress the PI for several minutes before I get a missing packet).

Then we have added the dwc_otg.speed=1 parameter to force USB to work only in full speed mode (speed of USB 1.1). This solved the issue. This confirms that the PI has some trouble to handle USB 1.1 devices behind an USB 2.0 hub, but forcing the USB to work in full speed mode completely solves the packet loss for our USB 1.1 devices.

Our working config:

CODE: 
root@raspberrypi:/home/pi# more /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 dwc_otg.speed=
1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
root@raspberrypi:/home/pi# uname -a
Linux raspberrypi 3.2.27+ 
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=5249&start=200

 

This is done byadding the dwc_otg.speed=1 parameter to force USB to work only in full speed mode:

sudo nano /boot/cmdline.txt

and adding dwc_otg.speed=1 in the text. ctrl +x, y and reboot

adding the dwc_otg.speed=1 parameter to force USB to work only in full speed mode

Some reported this solution as working, It’s worth trying… I’ll let you know…

Then a final option is this, that prevents kernel panic by setting always free quote of memory and setting the Soc in turbo mode.

Just to report, I had exactly the same error and I solved with:

  • vm.min_free_kbytes = 32768 in /etc/sysctl.conf
  • smsc95xx.turbo_mode=N in /boot/cmdline.txt

Remember that with turbo mode enabled you are seriously risking to corrupt your SD card…

So, that’s all about USB problems with the PI, I’ll upgrade this post with new informations when they’ll come out.

L'articolo Anatomy of a PI – USB Audio quality and related issues on Pi sembra essere il primo su RaspyFi.

]]>
http://www.raspyfi.com/anatomy-of-a-pi-usb-audio-quality-and-related-issues-on-pi/feed/ 3
Anatomy of a Pi – Raspberry Pi i2s and usb connections http://www.raspyfi.com/anatomy-of-a-pi-raspberry-pi-i2s-and-usb-connections/ http://www.raspyfi.com/anatomy-of-a-pi-raspberry-pi-i2s-and-usb-connections/#comments Thu, 27 Dec 2012 13:19:21 +0000 admin http://www.raspyfi.com/?p=97 I don’t know how you think about it, but in my opinion computer-science is not an exact science. Without getting murpyh’s laws involved, we can safely assume that when you think something will work, simply it will not. Or it will

L'articolo Anatomy of a Pi – Raspberry Pi i2s and usb connections sembra essere il primo su RaspyFi.

]]>
I don’t know how you think about it, but in my opinion computer-science is not an exact science. Without getting murpyh’s laws involved, we can safely assume that when you think something will work, simply it will not. Or it will do in a unexpected way.
To minimize this common rule, while starting this project, we should examine the hardware itself, taking every predictable aspect into account. Dear practictioners, welcome to today’s lesson: Anatomy of a Pi.

 

Visual RaspberryPI component illustration

Visual RaspberryPI component illustration

As you can see from the picture above, these are the main components of a Pi board. We’ve got 2 usb ports, lan, analog audio and s- video, micro usb power socket, sd card slot and hdmi out. The cpu, gpu and ram are in the middle of the pcb (images from wikipedia)

rasp1
What does it all mean for all project?

First caveat: our goal is to stream hi-quality, hi-res, jitter free audio out of usb ports (while studying how to implement a serious dac via i2s whit the gpio pins). Here starts our first problem. As you certainly now, one of the Audiophilia Hysterica diagnostic cryteria prescribes that if usb bus is dedicated to stream audio to a dac or transport it only should do that. No usb storage then. No usb bluetooth adapters and so on. So, keep in mind, that connecting a usb storage drive, while using a usb transport will affect your audio reproduction. At least, that’s what we’re told everyday, no?
These happens for 2 main reasons:

1- electrical “pollution” from spinning drives. Your hard drive electric noise will affect also the dac, if that’s not galvanic isolated from the usb port you’re using

2- lot of i\o in the usb bus. This will prevalently mean jitter.

Then, you can imagine why audio purists usually tend to avoid usb transport. And here, for our project, there is some serious issue.
The ethernet connection of the Pi is done via an USB to ethernet connection.

rasp2

 

Quite bad, isn’t it? This practically means that even if we use Ethernet access our music library (to a NAS for example) we’ll share the same bus of the dac\transport. That’s why it will be extremely important, for quality and jitter reasons, to find another way to connect to our dac. How? Via the gpio pins (Wikipedia)

General Purpose Input/Output (GPIO) is a generic pin on a chip whose behavior (including whether it is an input or output pin) can be controlled (programmed) by the user at run time.

GPIO pins have no special purpose defined, and go unused by default. The idea is that sometimes the system integrator building a full system that uses the chip might find it useful to have a handful of additional digital control lines, and having these available from the chip can save the hassle of having to arrange additional circuitry to provide them. For example, the Realtek ALC260 chips (audio codec) have 8 GPIO pins, which go unused by default. Some system integrators (Acer Inc. laptops) employing the ALC260 use the first GPIO (GPIO0) to turn on the amplifier used for the laptop’s internal speakers and external headphone jack.

Basically, we can add a custom port delivering a specific output coded in a specific way. My intent is to deliver audio stream via i2s, connecting directly the Pi to a DAC. This functionality was initially available in first revisions of the Pi, but it was dropped in the final release as you can read here. No worries then, even if this appears as a serious challenge, someone has managed to get it running.

So, now you know. For simplicity sake, you can use USB connection to your Dac\transport. If however you would want to have the best quality you can get from RaspyFi, you should wait until we sort out how to safely get i2s stream to a DAC. That will also mean that the path connecting the PI to our DAC should be extremely short, as the i2s standard requires the connection not to be than 3 cm longer. So PI+DAC in the same case. I think that will definitely worth the hassle of the extra job.

A brief example of how to use GPIO Pins

[embedplusvideo height="337" width="550" standard="http://www.youtube.com/v/q_NvDTZIaS4?fs=1" vars="ytid=q_NvDTZIaS4&width=550&height=337&start=&stop=&rs=w&hd=0&autoplay=0&react=1&chapters=&notes=" id="ep3488" /]

My intention is to use the Famous AK4396 DAC , something like this. Obviously, with custom audio output (tube one?). A smart guy on T-forum has managed to get it connected to XMOS via I2s. Thread here. Hope we’ll do something similar.

Suggestions? Critics?

L'articolo Anatomy of a Pi – Raspberry Pi i2s and usb connections sembra essere il primo su RaspyFi.

]]>
http://www.raspyfi.com/anatomy-of-a-pi-raspberry-pi-i2s-and-usb-connections/feed/ 15
Where to buy Raspberry Pi http://www.raspyfi.com/where-to-buy-raspberry-pi/ http://www.raspyfi.com/where-to-buy-raspberry-pi/#comments Wed, 26 Dec 2012 17:52:30 +0000 admin http://www.raspyfi.com/?p=89 Where to buy raspberry pi a.k.a. keyword’s heaven Ok, so you want to get RaspyFi to play your Music Library. What you need is: A brain A raspberry Pi A SD Card A decent Power Supply Audio Gear Music Opposable

L'articolo Where to buy Raspberry Pi sembra essere il primo su RaspyFi.

]]>
Where to buy raspberry pi a.k.a. keyword’s heaven

Ok, so you want to get RaspyFi to play your Music Library. What you need is:

  • A brain
  • A raspberry Pi
  • A SD Card
  • A decent Power Supply
  • Audio Gear
  • Music
  • Opposable Thumbs

Assuming all of these requirements are satisfied, you’re good to go. Instead, if you’re lacking the Raspberry Pi (but still with a brain and opposable thumbs) I’ll give you some advice where to buy it.

As you may know, The Raspberry Pi foundation (don’t know if they get mad if I don’t use the trademark sign… nevermind…) is collaborating with 2 of the biggest electronic goods supply in the world: Farnell\Element 14 (The 14th element is silicum, they got some brilliant tradename department in there) and RS.

If you look in the Raspberry Pi official forum you’ll find a terrible amount of anger for RS. Why? It seems that they are terribly slow (at least, they were… thing can change) at delivering raspberry pis. So, first advice:

Buy your raspberry Pi from FARNELL!!
http://it.farnell.com/raspberry-pi

Where to buy Raspberry Pi a.k.a. Adwords key to heaven

If you don’t have a decent power supply, a SD Card (min 2 gb) and a micro usb cable, I suggest to buy from them. You’ll save some shipping fees and you’ll be ready to go when your Pi will arrive. So, assuming you’re not terribly in a hurry you’ll get your Pi in some weeks.

WAIT!!! I’m in a terrible, desperate hurry! And I suspect I’m a A Type personality, I want it quickly! 

Well, while you’ll learn what Type A personality is, you can check some ebay auctions. You’ll find for sure someone who grabbed a stock of Pi’s and is selling them trough ebay at a larger pricetag. If this little overprice is good for you, then buy from there. You’ll receive it in a few days. Some examples here, here and here.

Personally, I ordered mine in october and I got it in 2 weeks. Decide by yourself what is your cash worth.

HEY!!! HISTORY TEACHS US THAT THERE’S ALWAYS A THIRD WAY!!!

True, my son. You still got this option. Could work.

L'articolo Where to buy Raspberry Pi sembra essere il primo su RaspyFi.

]]>
http://www.raspyfi.com/where-to-buy-raspberry-pi/feed/ 0