Tuesday, August 22, 2017

Creating a Raspberry Pi Squeezebox server

Frustration with Spotify

In my last blog post I wrote how Spotify remotely deleted their app from my Squeezeboxes. This pissed me off and I wondered who was in control of the Squeezebox devices, me or some third party. It forced me to choose between the service mysqueezebox.com, that streams music from the internet, or set up the Squeezebox server on my network. The Squeezebox server software being free and open source software guarantees that I take control of my Squeezeboxes and the music that I'm streaming.

The're many hardware options for the Squeezebox server software (or Logitech Media Server) but I decided to use the Raspberry Pi 2 that I had lying around because of it's small footprint and massive support for the Pi. Within a couple of hours I had the Logitech Squeezebox Server up an running with my music playing.

Below I'll show the steps that need to be taken to set up the Logitech Squeezebox Server on the Raspberry Pi. I got some important steps from the Variax Firmation website but I tested everything.

Raspberry Pi 2 with a USB-harddrive connected to my network with an ethernet cable.


Step 1: Ripping CD's and writing them on an HDD (choosing an audio format)

Before setting up a server rip the CD's and write them to a HDD. For this project I used a small usb-harddrive that was also lying around. I formatted the HDD as FAT32. Next I collected all my music CD's and ripped them. As ripping software I used the Asunder software on my Tahrpup Linux system (6.0.5) but I guess that the're good alternatives. As audio format I choose mp3 for now. If I buy a larger drive I'll probably move to flac.

Step 2: Installing Rasbian Stretch Lite

Next I installed the just released Rasbian Strech Lite on the Raspberry Pi 2 by first downloading the image and writing the image to the micro SD card using these instructions.  I chose the lite version of Rasbian Stretch to make the server as lightweight as possible. I had no problems booting the Raspberry Pi and connecting it to my network using ethernet. To avoid potential problems connect the Pi to a monitor with an HDMI cable and make sure that it boots properly.

Step 3: Mount the HDD on the Raspberry Pi

Now with Rasbian Lite installed I mounted the HDD that we prepared in step 1 we need to login remotely and retrieve the name of the drive. To login remotely we need another computer (Windows, Linux or OSX). Open a terminal (or Putty in case of Windows) and type
sudo ssh pi@Raspberry_Pi_ip_address (in my case 192.168.178.69)
The password is raspberry. Then type.
sudo fdisk -l
Then look for the HDD that is just connected. This was /dev/sda1 in my case (but this may differ in yours). To make the files on the HDD accesible to the Raspberry Pi we need mount the drive. But before that we need to make a mounting point.
sudo mkdir /media/usb-drive
and mount
sudo mount /dev/sda1 /media/usb-drive
You should hear some HDD activity. Now type
cd /media/usb-drive ls -l
and a list of your music should be visible.
To unmount the HDD do
sudo umount /media/usb-driv

The list of folders with albums that I ripped. In this stage I only ripped a few albums to test the system.

Step 4: Installing Logitech Media Center on the Raspberry Pi

Before we need to install a library to play audio files.  Since you want mp3 only do:
sudo apt-get install -y libsox-fmt-all.
This installes SoX, a command line utility that, among other things, plays various types of audio files. If you want flac you'll probably need to do this
sudo apt-get install -y libsox-fmt-all
Now with the audio libraries in place the Logitech Media Software can be downloaded. We want the latest version which is 7.9.0.
wget -O logitechmediaserver_all.deb $(wget -q -O - "http://www.mysqueezebox.com/update/?version=7.9.0&revision=1&geturl=1&os=deb")
Now install the server software with:
sudo dpkg -i logitechmediaserver_all.deb
With all the software installed we're ready to go.

Step 5: Working with Logitech Media Center

To enter the web interface of the Logitech Media Center on the Pi we need a computer and a browser. In the browser url we type:
<your_Raspberry_Pi_ip_address:9000> (in my case 192.168.178.69:9000) 

The Logitech Media Center is started for the first time and a script is started to set it up. Important is that the mounting point of the HDD (in my case /media/usb-drive) is entered. This way the Media Center is able to retrieve all the music files.
sudo mkdir /media/usb-drive
The Logitech Media Server is now ready and every time the Raspberry Pi boots the Logitech Media Server is automatically started however the HDD is not automatically mounted so we need to change that. This is done in the fstab system configuration file that can be found at /etc/fstab
sudo nano fstab
and add the following line
/dev/sda1    /media/usb-drive     vfat&    defaults     0
Save the file and exit nano. Reboot the Raspberry Pi. Now the installation is complete. The music can be played from the web interface (see above), with the remote controls that come with the Squeezebox devices or with a free app for Android. The Squeezebox Radio also has controls on the device to play the music. So, plenty of options.

Webinterface of the Logitech Media Server.

What's next

To give the media server a permanent place a case is needed. Luckily I have a 3D printer and some 3D CAD skills so I'll create my own. I'll show the finished product in a future blog post. I also wonder if I could make this work on the C.H.I.P which would make the project even cheaper.

Wednesday, August 16, 2017

Spotify silently and remotely deleted app from Squeezebox devices

Spotify removed

Spotify silently and remotely deleted the Spotify app from the Squeezebox devices I found out after returning from vacation (Yes, they did post an article on their help pages I found out but I wasn't notified). I own a Squeezebox Radio and a Squeezebox Touch that I both use heavily to listen to music with the Spotify app. I even have a Spotify Premium Family account that enables me to play Spotify on multiple devices. I understand that support for hardware, such as the Squeezebox, is limited and will end some day. However what outrages me is that Spotify remotely removes software on a device that I own. Spotify makes it very clear that they control the software that they provide for the device and not the user. With that they control the functionality of my devices.

The Logitech Squeezebox Radio, one of several types of Squeezebox devices, now without Spotify (photo from https://en.wikipedia.org/wiki/Squeezebox_(network_music_player)).

The Squeezebox music player

The Squeezebox device is a network music player from Logitech. The devices are versatile and have excellent hardware. The Squeezebox can be used in two different ways; as a player that works with an online service, mysqueezebox.com, or with a private server called Logitech Media Server. I preferred to use my Squeezebox devices with the online service mainly for its ease of use and because some streaming services such as Spotify and Deezer are available as an app. The apps are very convenient to stream music just with a remote control. The Squeezebox hardware was discontinued in 2012 but  but, to it's credit, Logitech maintains the online service to this very day.

I didn't mention the best thing about Squeezebox, both the server and player software are non-proprietary and can be installed on several different operating systems. This enables all users to make build their own Squeezebox clients and servers.

Choices

With the removal of the Spotify app I have a choice to make. Will I continue to be using the my Squeezebox devices with the online server using Deezer instead of Spotify or will I set up my own private server? The latter is of course more of a hassle since it involves installing and maintaining the Logitech Media Server, ripping CD's to mp3's and storing them on the server. Nevertheless I may choose to create my own private server. I recently decided to move the software on my iMac from proprietary to non-proprietary so creating the private server for my Squeezebox would also make sense. I happen to have a Raspberry Pi 2 lying around and in the coming weeks I'll try to set it up as a Logitech Media Server.


Thursday, August 10, 2017

Replacing Contacts, Calender and Mail with Thunderbird on OSX

Introduction

I prevously wrote about the reason why I prefer open source software above proprietary software for my DIY projects. This time I'd like to take it a step further by replacing all proprietary software on my iMac with open source or non-proprietary software. This is of course not possible because the OSX operating system itself is proprietary but I'm replacing as much programs on it as I can. This will ultimately make it easier to move to the Linux operating system.

Thunderbird the replacement for Contacts, Calender and Mail on OSX.

 

Thunderbird

Today I replaced the proprietary Contacts, Calender and Mail, that come with OSX, with Mozilla's Thunderbird (v52.2.1). Most important are my mails. I have three email accounts from which two migrated without program. Not suprisingly I was unable to migrate my iCloud account. Not a huge problem since I want to abandon this account anyway.

All contacts from OSX Contacts were imported during the installation of Thunderbird. Next I exported my Calender data as an .ics file. Thunderbird imported this file without problem (Events and Tasks/Import).

After just a couple of hours of usage I can't provide a opinion of the Thunderbird software but that is not relevant. Even if Thunderbird would lack certain features or the user interface is not as pretty as the other programs the more important point is that I gained more freedom today. I unchained myself from three proprietary OSX programs and I'm slowly freeing myself from the Apple ecosystem.

Further down the road

Next on the agenda are Quicktime and iMovie which I use extensively for my video tutorials. Possible candidates are OpenShot and Kdenlive. I've heard that both programs can have stability issues so that may be a challenge also the Kdenlive version of OSX is outdated according the Kdenlive website.

Even further down the road is OSX Photos. I have thousands of photo's and as you can imagine they're precious to me. Finding an non-proprietary image organizer for OSX is not easy. My son uses Shotwell on his Ubuntu system but I haven't found an OSX version of it. Another alternative is digiKam. This program appears to be maintained very well so I might want to give it a try.

Any comments on migrating from proprietary to non-proprietary programs are welcome as well as any comments on proprietary versus non-proprietary in general. In the future I'll regularly write an update on how I'm faring with the transition.

 

Tuesday, June 20, 2017

Line and Polyline modules in OpenSCAD

Polygon in OpenSCAD

The polygon function of OpenSCAD is very cool but for some applications it just doesn’t cut it. For instance when polygon is used to draw a Starpolygon, a self intersecting polygon, the space between the polygon lines is filled, an undesired effect that cannot be negated. In case of the Starpolygon we just want to see the lines.

Line and Polyline

Luckily we can create our own polygon module in OpenSCAD that meets our needs. However before we can create a polygon we need to be able to create a single line. Also a single line can be created in OpenSCAD, actually in several ways. In the YouTube video below I'll show one such approach.

A Vase created with line, polyline and rotate_extrude in OpenSCAD.

Furthermore I’ll show how to create a line module and a polygon module that fit our needs but it doesn’t stop there. With the line and polyline a complete 2D-library in OpenSCAD can be created. Also, in combination with linear_extrude and rotate_extrude 3D objects can be created that are impossible to create with CSG alone.



In a next blogpost I’ll show you how to create a Bezier Spline with line and polyline. This Bezier Spline can then be used to create a smooth curve needed in a 3d printable vase for example.

I want to mention Justin Lin here. He has a great website www.openhome.cc where he, not only shares his OpenSCAD work, but also explains it in great detail. I think it’s a very useful resource for OpenSCAD.

The file of this video can be downloaded with the following link: https://drive.google.com/open?id=0Bwg0RBbuN0fMVkJISXdDQV9sekE

OpenSCAD is open source (GPLv2 license) and is well maintained by Marius Kintel et al. Besides the stable releases for Windows, OSX and Linux, development snapshots are available. I recommend using these development snapshots since they have all the latest features. 

Friday, June 2, 2017

Cubic Bezier Spline tool in Solvespace

Cubic Bezier Spline tool 

The Cubic Bezier Spline tool in Solvespace can be used to create shapes that are hard or impossible to accomplish with other tools such as straight lines. A Cubic Bezier Spline is a line segment that can be controlled with four points. By changing the position of these points the curve can be manipulated or smoothened.

By clicking with the left mouse button in the graphics window the new control points can be added to the Cubic Bezier Spline tool to a maximum of 12. This is essentially a Composite Bezier Curve or polybezier. The problem with these curves is that it is hard to keep the curve smooth.

Polybezier with eight control points fully constrained approximating a circle


a classic example of shapes that benefit from Cubic Bezier Splines are Vases. Vases also appear to be popular with 3d printers. In the video below I'll demonstrate how to create a Vase in Solvespace using the Cubic Bezier Spline tool.

At the end of the Vase video I’ll demonstrate two often overlooked functions in Solvespace, the Length Ratio constraint and the Length Difference constraint I’ll also show how to apply the Length Ratio constraint to two circles.


The Solvespace Vase file from this tutorial can be downloaded here.

For this tutorial I used Solvespace 2.3 on OSX.

Solvespace is open source (GPLv3 license) and is available for Window, OSX and Linux. It is developed by Jonathan Westhues and maintained by Whitequark and others. It can be downloaded here: http://solvespace.com/download.pl

Tuesday, May 30, 2017

Spiral Phyllotaxis patterns in OpenSCAD

Spiral Phyllotaxis

In just uploaded a YouTube video about Spiral Phyllotaxis patterns in OpenSCAD. This time it’s a script that I made to demonstrate Spiral Phyllotaxis. Phyllotaxis is a term used for patterns that emerge during the growth of plants. Spiral Phyllotaxis is observed in the heads of sunflowers, in pine-cones and pineapples, and in a variety of other plants.

The script that I wrote uses a mathematical description of Spiral Phyllotaxis called Vogel’s formula. Vogel’s formula actually exists of two equations, one for an angle theta, and one for a radius, describing the a pattern of seeds in a sunflower head. I’ll put a link in the description if you want to know more about Vogel’s formula. These simple equations can generate beautiful patterns that have some interesting mathematical properties.

The number of spirals derived from Vogel’s formula has a close relationship with the Fibonacci sequence. Exactly 55 spirals go counterclockwise, 34 smaller spirals go clockwise and 21 even smaller spirals go counterclockwise and so on. These numbers of spirals are all integers in the Fibonacci sequence.

The Golden Angle or Fibonacci Angle of 137.5 degrees is key in these Spiral Patterns. This angle results in the best distribution of the seeds. A slightly smaller or larger angle leads to a less optimized distribution.

Not only can the Spiral Pattern be examined in OpenSCAD. A big bonus of the program is that the user can create an stl file that can be printed. The physical model can then be studies further.

Tuesday, May 16, 2017

A Solvespace tutorial, the Fidget Spinner

Another Solvespace tutorial. 

In this tutorial I'm going to create a Fidget Spinner. For those who don’t know, a Fidget Spinner is a stress-relieving toy. A basic Fidget Spinner consists of a bearing in the center of a design made from any of a variety of materials. I got this idea from Paul Randall’s YouTube channel. Paul has a great channel with an increasing number of excellent OpenSCAD and FreeCAD tutorials. Last week Paul uploaded two video tutorials where he creates a Fidget Spinner, one in OpenSCAD and one in FreeCAD. I thought it was a good idea to add a Solvespace tutorial to this and leave it for the user to judge which of these open source 3D CAD programs is best for these kind of models.

The Fidget Spinner that we create in this tutorial can easily be 3D printed. However it may require some adjustments of the dimensions before it can be succesfully assembled into a working Fidget. When this is finished insert a bearing and three nuts and the Fidget is ready for use.