Raspberry Pi Hifi

Posted by admin on Apr 14, 2015 in Uncategorized

For Christmas I was given a Raspberry Pi as a Kris Kringle gift. It is a model A+ with no network interface card and 1 USB port. It took me a while to decide what to do with it.

After looking at a few projects, I decided to set up a streaming music server for streaming my music collection that lives on a Windows 7 server to my HiFi in another room. The first real obstacles I found were that a wifi dongle would be needed and the audio out through the headphone jack of the RPi is poor quality. I could either scrap the project or buy a digital to analogue converter and wifi.

I bought an “Audiophonics DAC Sabre ES9023 I2S” on eBay for $18 since the picture showed it connected to a RPi. My A+ however does not have the 8 pin “P5” connector so I had to work out what pins to connect up to the 40 pin GPIO and use the newest kernel 3.18.7+. I also bought a “ralink rt5370 based dongle” for $8.

At this stage I should say that I am using the Volumio 1.55 software image. After wiring it up it worked first time and the sound is brilliant. The DAC lacks a hardware volume control so the volume is either max or controlled by software.

Basic wiring is below;

I2S DAC wire -> GPIO Pin
LRCK (red) -> 35
GND (yellow) -> 39
DATA (white) -> 40
BCK (black) -> 12
MCLK (orange) not used
+5v (red) -> 4
0v (black) -> 6

Closeup of the RPi showing DAC and wifi









I wasn’t completely happy with the software because I wanted to be able to control the HiFi with my Android phone or tablet. There are some good apps to control Volumio such as MPDroid but I wanted more.

Next, I have installed the free Logitech Music Server on my Windows 7 server and squeezelite-armv6hf (Logitech LMS client) on my RPi. I think this is a better solution as the RPi is now a lightweight client instead of a music server.

As a controller I am using OrangeSqueeze app on my tablet. This is not free but is very user friendly and works nicely.

Finally, I have installed the “Triode” third party Spotify app in the Logitech Music Server and now can play Spotify using OrangeSqueeze.

OrangeSqueeze Album View












OrangeSqueeze Spotify View


Hiding Indexes

Posted by admin on Nov 25, 2013 in Database, Oracle

I just found out that its possible to hide indexes rather than making them unusable.

alter session set ddl_lock_timeout = 10;
alter index INDEX_START_DATE_TIME invisible;

This is beneficial because the index does not have to be rebuilt it it is made visible again.


Media Portal Online Videos Tweak

Posted by admin on Sep 16, 2013 in MediaPortal

Its possible to use VLC as an alternative player using the context menu.

Its also possible to change the default by editing the OnlineVideoSites.xml and adding player=”VLC” (or player=”WMP”)


MySQL variables for 5.6

Posted by admin on Jul 23, 2013 in Database

After upgrading MySQL Cluster from 7.2 to 7.3 (5.6.11) performance was poor. My workload is not typical OLTP or OLAP but a mixture of both and some real-time updating. Also I have 2 MySQL instances running on different ports and the disk subsystem is quiet slow.

The following parameters got the databases back to normal (or better)


innodb_thread_concurrency is limited to 4 on each instance. This matches the CPU count of 8. The default is 0 – unlimited which seemed to generate excessive load averages.

innodb_old_blocks_time has changed from a default of 0 to a default of 1000 (milliseconds). The purpose of this parameter is to not flood the buffer pool when a large table scan occurs. The default of 1000 caused the system load averages to increase rapidly probably due to the slow disks causing io wait. Setting to 10 (milliseconds) seems a good compromise.

innodb_old_blocks_pct=37 is the default but for some reason mine was set to 95.

innodb_flush_method is O_DIRECT to improve insert/update performance

innodb_io_capacity has a default of 200 and a maximum of 2000. I have it set lower on one instance than the other to prioritize io.

innodb_buffer_pool_instances=1. The default is 8 buffer pool instances when a large buffer pool is allocated. This is not satisfactory for me and I prefer a single buffer pool. Thread concurrency is not a concern.


Accessing Hulu, The Daily Show etc using DD-WRT

Posted by admin on Nov 2, 2012 in Uncategorized

DNS redirection can be easily set up on a DD-WRT enabled router such as my D-Link DIR-815. Under the services tab there is a setting for DNSMasq :

Additional DNSMasq Options

These IP addresses point back to tunlr.net.

An additional benefit is that I can VPN into the router and then access the sites from work.


StreamedMP Tweaks

Posted by admin on May 22, 2012 in HTPC, MediaPortal, Uncategorized

My preferred skin for MediaPortals is StreamedMP and these tweaks make it slightly more user friendly.

1. Fonts

The Avalon skin has a nicer font “AvalonType Light” and this can be downloaded and installed in the windows fonts directory and added to the fonts.xml file instead of the current fonts. Install the font by installing the Avalon skin. By the way, I like the Avalon skin but it does not have enough fanart for me.

cd c:\ProgramData\Team MediaPortal\MediaPortal\skin\StreamedMP
Edit fonts.xml and replace font names so they look like this

<filename>AvalonType Light</filename>

I also like the Spiderman font which I use as “font18” on the home menu.

Screen shots

2. Hidden menus

I like to delete all the *hidden* files in the skins directory e.g.
cd c:\ProgramData\Team MediaPortal\MediaPortal\skin\StreamedMP
del movingpictures.common.hiddenmenu.xml
del TVSeries.Common.HiddenMenu.xml

The reason I do this is so that children or visitors do not accidentally go into context menus and change my layouts.

3. Remove seperators —————–

Replace separators so that paragraphs of text flow better. I use unix/cygwin tools for windows.

sed -i “s/-*<\/seperator>/\&#176;<\/seperator>/” *.xml

&#176; is a little circle °

4. Mediaportal Tweaks

Dynamic Refresh Rate

CINEMA – 23.976 – 23
CINEMA24 – 24 – 24
TV – 25 – 50
HDTV – 50 – 50
NTSC – 59.94 – 59
NTSCHD – 60 – 60
NTSCFILM – 29.97 – 59

Default is TV


MediaPortal Configuration>Videos>Subtitle
subtitle engine MPC-HC
subpicture buffer to “5 (Advanced)


MediaPortal Configuration>General
Process priority AboveNormal

UPDATE: I have disabled Dynamic Refresh Rate because my Samsung TV does a better job by itself.


Tuning DD-WRT

Posted by admin on Apr 24, 2012 in Uncategorized

echo 0 > /proc/sys/net/ipv4/tcp_westwood (default 1)
echo 1 > /proc/sys/net/ipv4/tcp_vegas_cong_avoid
echo 3 > /proc/sys/net/ipv4/tcp_vegas_alpha
echo 3 > /proc/sys/net/ipv4/tcp_vegas_beta

TCP Vegas tunes the network performance based on packet delay instead of packet loss.


Microsoft Remote Debounce

Posted by admin on Apr 13, 2012 in HTPC, MediaPortal

The MCE remote implements something called “debounce”, which means that with each button press the remote alternates the signal code it sends, I think to limit accidental double button presses. Hence, when you program your universal remote it only has one of the codes, so it will work the first time you press it but wont work again until after you’ve pressed something else.

To disable debounce you need to change a registry key. Find this key:


and change the value of the EnableDebounce DWORD value on the right hand side from 1 to 0. Reboot for it to take effect.


replace into

Posted by admin on Apr 10, 2012 in Database

I had been using mysql’s replace into syntax until I read this article http://code.openark.org/blog/mysql/replace-into-think-twice which makes a lot of sense.

I have mostly changed statements to use insert .. on duplicate key instead.
For example

    insert into currentusage (
      sum(case when timing = 'ANYTIME' then bytesuploaded end),
      sum(case when timing = 'ANYTIME' then bytesdownloaded end),
      sum(case when timing = 'PEAK'    then bytesuploaded end),
      sum(case when timing = 'PEAK'    then bytesdownloaded end),
      sum(case when timing = 'OFFPEAK' then bytesuploaded end),
      sum(case when timing = 'OFFPEAK' then bytesdownloaded end),
    from netflowsummary
      where userid = 12350
      and summaryinterval >= '2012-04-04'
    on duplicate key update


Upscaling Xvid using Avisynth

Posted by admin on Mar 16, 2012 in HTPC, MediaPortal

I knew that ffdshow could use avisynth for complex scaling and sharpening but only recently had the time to play around with it. I’m pretty happy with the results.

This tutorial was the basis of my experimentation –

There are a number of software versions of all the associated plugins so these are the ones I used.

Downloaded the standard avisynth 2.6 from SF
googled “avisynth 2.6 MT download” for the Multithreaded version of avisynth –
http://forum.doom9.org/showthread.php?t=148782 and overwrite the avisynth DLL in the windows system directory
googled “LimitedSharpenFaster” for home page –
and downloaded prerequisites masktools-v2.0a48.zip, RemoveGrain.rar and LimitedSharpenFaster.avsi which is in masktools.

Then installed the following script in ffdshow.

dispWidth = 1920
dispHeight = 1080
mWidth = float(last.width)
mHeight = float(last.height)
ratio = (mWidth/mHeight)
newHeight= round((dispWidth/ratio)/2)*2
newHeight > dispHeight ? Eval("""
""") : Eval("""
GetMTMode(false) > 0 ? distributor() : last

Note that LimitedSharpenFaster is placed before the resize because this did not work when placed after it during testing.

The following screen shot shows a comparison with a Kung Fu Panda trailer although its a bit hard to see the difference, the detail is discernable. Kung Fu Panda

A similar improvement can be gained using ffdshow alone by using the built-in resize & aspect filter and resizing to 1920 x 1080. On the settings tab, set the Luma method to spline and the Chroma method to bicubic. Then adjust the Luma and Chroma sharpen settings to around 0.75.

In my opinion, the avisynth sharpening seems slightly warmer and brighter but that’s a subjective personal preference.

This soon to be moot because most dowloaded movies and TV will be in H.264 codec anyway.

I added an additional filter that provides temporal filtering so the filters in the script now look like this.


Copyright © 2008-2018 Brinsmead Data Services All rights reserved.