50 Hz strobe

Some of my friends were in a band ’The Valves’ in the late 70s and more recently they have been playing the occasional (and excellent) gig here in Edinburgh. This year they brought out their first album — on vinyl. It’s called ‘Better Late …’. You can find all about them on Facebook: search for ‘The Mighty Valves’. 

Now I was supposed to be getting copy of the album at mates’ rates. But that involved meeting one of them which is not possible during COVID lockdown here on Scotland. But to prepare for its eagerly awaited arrival I thought I’d better dust off my turntable. I had ripped all my albums to MP3 ages ago and rarely used it. I found that it only worked at 45 rpm. The cure was to spray switch cleaner at the 33/45 rpm switch which was hidden inside — the switch that you press was pressing a plastic piece at right angles to the actual switch. 

I though I might as well check it was still at the correct speed and remembered I had a strobe ‘disc’. It’s actually a piece of paper from vinylengine.com.

Strobe disc and screwdriver

The idea of the strobe disc is that the lines on the concentric circles will normally be blurred when the disc is spinning. When you shine a light strobing at 50 Hz the lines freeze and appear to be still if the disc is turning at 33 rpm. If the disc is spinning at some other speed the lines may look like they are spinning slowly backwards or forwards. I tried to take some videos of this working but they don’t show properly presumably due to the frame rate of the camera.

So how to get a 50 Hz light in these days without incandescent bulbs? Here’s a quick program for an Arduino which toggles a digital output at 50 Hz. A white LED and a 330 ohm resistor in series to ground is the entire circuit. About as simple as it gets.

/*
strobe LED at 50 Hz
*/
int ledPin = 12;

// the setup function runs once when you press reset or power the board
void setup() {
pinMode(ledPin, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
int delayms = 20/2; // 50 Hz has a period of 1/50 seconds = 20 ms
delay(delayms);
digitalWrite(ledPin, HIGH);
delay(delayms);
digitalWrite(ledPin, LOW);
}

I compiled this for an Arduino DUE which I had to hand, though I imagine it would work fine on an UNO. The ledPin value may need changed though. I compiled it using Arduino-cli with this incantation:

arduino-cli compile -b arduino:sam:arduino_due_x_dbg -p /dev/cu.usbmodem141101 -u

Arduino as strobe

That meant I didn’t need to use the Arduino IDE and could use my code editor of choice (vim). Arduino-cli works well — thanks to the developers! BTW the Arduino IDE is fine, I’m just a terminal junkie. An oscilloscope confirmed the signal was at 50 Hz.

The picture shows me using a prototype shield on top of the Arduino. The shield is not necessary but the reset switch is easier to get at with the shield so I used it.

Did it work? Well… My turntable is a Pioneer PL-120 and the designers decided to make the speed control impossible to use while the turntable is spinning. See the yellow screwdriver which is at the speed control adjust screw in the picture of the strobe ‘disc’. So my fond dreams of shining the strobe at the disc and simultaneously adjusting the speed were dashed. I found it really difficult to do. Also it is summer here in Scotland and the weather has been good so the sun is in the sky nearly all of the time I am awake. So the LED could have been brighter to compete with the sun. It would work fine in winter or if I had better curtains.

In the end I put on a record and counted how long 10 revolutions took and did the arithmetic. Adjusted the speed (did I tell you the screwdriver is difficult to align with the speed control slot?) And repeated until good. So I didn’t actually use the strobe in the end.

A final test: ‘Oh! Wot A Dream’ by Kevin Ayers is billed as taking 2m 47s and I timed it at about 2m 46s. That’s good enough for rock and roll. Maybe someone with perfect pitch would howl in frustration — as am I waiting for the ‘Better Late…’ album.

Preparing MP3s for an Evoke 3 Radio

I use an Evoke 3 radio made by Pure to listen to music. It has a very good sound — at least to my cloth ears. One of its features is that it plays MP3s from an SD card. But its firmware is quite old-fashioned perhaps because of technical limitations. It displays the song information but can only understand ID3v1 tags. The world has moved on and ID3v2 tags are now the default for most devices. Also the Evoke displays all files even those which are hidden on computers by having a dot as the first character. This makes the display of the folders and songs messy.

I used to deal with the tagging by using a very good application called kID3 to copy the ID3v2 tags to ID3v1 tags in its GUI. I have recently been reading “The Art of Unix Programming” by Eric Steven Raymond and it prompted me to write a script to do the tagging. I’ve since seen that kID3 can be driven from a CLI so that may be a better way to do the tag copying. 

Kid3 screenshot

I looked for command-line utilities to copy tags and couldn’t find any. But the good folks in the Perl community provide a library called MP3::Tag which allows easy manipulation of MP3 tags — as long as you can write in the Perl language. The library is available on CPAN but I used the MacPorts version. Many moons ago I could write Perl in my sleep so I decided to dust off the necessary neurones and write a Perl script. 

The Perl script ‘mp3-tag-convert.pl’ is not new and exciting but may help as an example for whatever you want to do. The script looks at all the MP3 files in a folder and copies the ID3v2 tags to ID3v1 if they don’t already exist. It will also copy the ID3v1 tags to ID3v2 if they don’t already exist. 

For my purposes I needed some other scripts. I had already written a shell script ‘tidy-mp3s’ to tidy MP3 folders of extraneous files that MacOS leaves lying about for its own purposes but that show on the Evoke 3 cluttering up the display.

I also needed a script to put it all together. ‘mp3s-to-evoke.ksh’ is a script which tags the MP3s in the way that suits the Evoke 3 and then copies them to the Evoke 3.So when I decide to change the songs on the Evoke 3 (it only handles a 2GB disc) I can just call the script in each MP3 folder on my computer and it will get copied to the Evoke 3.

Screen Shot 2019 08 11 at 17 10 01

The scripts are in this compressed file: evoke-scripts.zip.

I use Korn shell (ksh) for scripts because that’s what I grew up with. I think the scripts should run under Bash if that’s what you prefer.

So now my Evoke 3 screen is nice and clean.

Evoke 3