Linux CLI Raspberry Pi Stuff

Podcasts at the Command Line with Ecasound

Recently I’ve been tasked with mixing a few podcasts – and me being me (in other words reluctant to bother using a mouse if I don’t have to… and only possessing 50usd raspberry pi computers) I decided to try using command line utils. Really a raspberry pi 3 is easily up to the task – haven’t tried it on my zero, I’m not that much of a masochist!

Happily, a combination of ffmpeg and ecasound has seemed to do a pretty good job. It was fiddly to set up but as tends to be the case with CLI setups, it holds the potential for mixing future episodes to be very fast indeed to mix.

Recording and File Prep

The two ladies recording the podcast are situated on opposite sides of the Atlantic. Therefore each has a mic and recording device and also a phone. That way the call is conducted over the phone and two pristine recordings are made locally so we get the highest possible quality.

Then I need to mix the two recordings at a later date. One of the recordings actually gets saved as m4a (odn’t ask why:) and at 48khz while the other is a wav at 44.1khz. Seeing as I like to mix at 44.1 and ecasound can only really seek effectively with wavs, I used ffmpeg to convert the m4a to a wav at the correct frequency.

  ffmpeg -i input.m4a -ar 44100 output.wav

Synch and Volume

Then I need to synch the two files from the two podcast participants. I’ve used ecasound’s simple cli syntax for this:

  ecasound -c \
  -a:1 -chcopy:1,2 -ea:70 -i:playat,$1,input_A.wav \
  -a:2 -chcopy:1,2 -ea:100 -i:input_B.wav \
  -a:1,2 -o alsahw,1,0

Let’s break that down.

  • ‘-c’ means to go into interactive mode – more on that in a moment…
  • The ‘-a:x’ bits mean an effect chain (ie input followed by a load of cables, followed by output). In this case we’re specifying multiple chains going to the same output so we have to put them in one line (ie the last one). I couldn’t really tell you why, but as long as you only mention any input or output once in the file then it seems happy connecting them to as few or many chains as you like!
  • The ‘-chcopy:1,2’ bits are simply there because the input files are mono and I have headphones and two ears! Therefore I want to be able to hear the mono channel through both sides of my headphones.
  • ‘-ea:’ is an amplifier. The value is a percentage of the natural amplitude of the file.
  • The ‘-i’ part means specifying an input. ‘playat’ means we’ve got an offset for one of the files to get them in synch. It also happens that I’ve made the offset a parameter for the bash script. In this way I can do ‘bash ./ 4’ to start input_A.wav after 4 seconds.
  • The ‘-o alsahw,1,0’ is to play through alsa to my soundcard.

But wait, what if my guess of 4 seconds turns out to be wrong??!:-)

Well if we run our command we’ll have ecasound’s interactive mode which serves as a control surface and more. Unfortunately, pretty much the only thing it can’t edit easily is that little parameter in ‘playat’ that tells it at what point to play the sample.

Therefore we press ‘t’ to start ecasound playing – then probably a whole lot of ‘fw 30’, ‘rw 10’ etc to send the transport back and forward to understand if our guess of 4 seconds to synchronise was close or not. If so then cool… If not then we simply press ‘q’ and start our script with 5.5 seconds etc…

The other thing you’ll want to do is balance the volumes between the files. This is easy interactive mode.

Just type:


You should see something like this:

  ecasound ('h' for help)> cop-status
  ### Chain operator status (chainsetup 'untitled-chainsetup') ###
  Chain "1":
          1. Channel copy: [1] from-channel 1.000, [2] to-channel 2.000
  	2. Amplify: [1] amp-% 70.000
  Chain "2":
          1. Channel copy: [1] from-channel 1.000, [2] to-channel 2.000
  	2. Amplify: [1] amp-% 100.000

Volumes are a percentage – so to change that volume from 70 to 90:

  c-iselect 1
  cop-set 2,1,90

In other words, select chain 1, then set chain-operator 2, parameter 1 to 90.

The beauty of this is you can press the up arrow and change the 90 to 95 etc then press return and execute the command again with a different value.

In this instance you’ll have to note down the two volumes you used as ecasound doesn’t edit the ‘playat’ command interactively unfortunately. When they’re noted down just press ‘q’, edit the two vols in the original script and start up ecasound again (by pressing up arrow a couple of times and return given were in bash…)

Then when you’re done just note down the number you used to synchronise and edit the last line of your script so that the output is ‘output.wav’ instead of alsa.


Everyone’s human and I’ve been asked to cut bits out…

Here I tend to fire up jack so I can have multiple outputs. (something like this: jackstart -d alsa -p 128 -n 2 -r 44100) and set up a screen or tmux session with one terminal showing:

  ecasound -c -i podcast.wav -o jack,system,notransport

This way I can whizz back and forth in playing the file and find the places I want. The ‘notransport’ bit means it doesn’t impact the whizzing back and forth I’ll be doing on the editted copy…

Then I have another tab with an sh script open which will look something like this:

  ecasound -c \
  -a:1 -i:playat,0,select,0,30,podcast.wav
  -a:2 -i:playat,30,select,35,60,podcast.wav
  -a:1,2,<and more...> -o jack,system,notransport

Above I just removed a 5 second gap.

Again, when I’m done I just replace the output for ‘podcast_edited.wav’.

Add the Intro and Outro

The last thing you’ll need to do is stick an intro and outro on it:

  ecasound -c \
  -a:1 -ea:60 -i intro.wav
  -a:2 -ea:130 -i playat,30,podcast_edited.wav
  -a:3 -ea:190 -i playat,5030,outro.wav
  -a:1,2,3 -o final.wav

And we’re done!

Raspberry Pi Stuff

A twitch chatroom display that appears on an e-ink screen at the press of a button.

I’ve been trying recently to get a twitch video broadcast system that I can just push a button and we’re go. As usual I’m working with a raspberry pi and its basic (but more than adequate) camera.

One of the annoying things I’m running into is firing up my twitch chat server on my phone and picking it up between songs etc. I don’t like having to press/swipe a load more things and I don’t honestly like an lcd screen flashing away at me or a mobile phone/wifi device right next to me while I’m playing (yes I’m sensitive to them – both the blue light and the wifi – I know you probably think I’m crazy but no amount of the government/manufacturers telling me this stuff is safe is ever going to stop me feeling like sh*t when I’m exposed to them too much!).

My pi gives me the potential to eliminate all this and have a wifi/mobile/lcd free device where I literally just have to press one button and the chat server appears on the screen! Cool huh!

Problem is… Twitch lets you into its chatroom with oauth tokens. This means when you disconnect from the chatroom you have to get another token! Really annoying if you do not have a permanent internet connection. Therefore I’ve got a VPS that is permanently logged into my twitch chatroom:-)

So what do we do? Well… Step number one is to actually get twitch to accept me into its chatroom. I’m using weechat as my irc.

Steps are:

  • Log into twitch in your browser
  • Go here: and press to generate a token, then copy it.
  • then ssh into your vps and run ‘screen’ – this way it’ll stay even if you disconnect
  • then run ‘weechat’ in your screen session
  • then in weechat: server add twitch -password=<pasted oauth token> -nicks=<username> -username=<username>
  • then connect to twitch with: /connect twitch
  • then join your channel with: /join #<username>
  • save your settings: /save

Now if you ssh back into your VPS you can type ‘screen -r -d’ and your twitch chat server will appear again!

Oh and I find Ctrl A – F really useful if I’ve used it on the wrong screen size and now it looks silly – it’ll have a good look at wherever you’re ssh’ing from and figure out what size screen you’re using now and modify itself…

Great, but what happens when your vps host has to reboot to do some security updates? (happened to me recently…) or you manage to completely gum up your vps with zombie processes to the point where you have to reboot from the hosting panel (ah… I errr… once heard a friend of mine did that…) Well then, here’s your set of instructions to sort out your chat screen if it disconnects:

  • go back here and get a new token: Didn’t you know there is an infinite supply!
  • start screen again then weechat
  • back in weechat: /set irc.server.twitch.password <paste it here!>
  • /connect twitch
  • join #<username> and you’re back in!

But what about the e-ink screen I told you about? It’s a waveshare 800*450 one. Terrible refresh rate (we’re talking seemingly endless thumb-twiddling seconds…) But really cheap, good enough for displaying chat messages and has this excellent software for it:

Essentially what I’ve done is set up my old pi3 (aw I love the lil’ thing – I actually used it as my main work machine for the best part of a year – no kidding… Recorded a load of music on it too…) ummm where was I? Ah yes I set up the pi with the PaperTTY terminal command loading at startup.

In fact I messed with the config of the tty1 systemd process so that instead of coming up with a login screen, it shows tmux right from boot.

And then… And here’s the cool bit – I’ve got a script on my main machine (a pi4 in case you were wondering) that is triggered by xbindkeys so I press one keypress to:

  • log into the pi3 via ssh
  • trigger a local script on the pi3 that does a ‘writevt /dev/tty1 bash’

And does exactly that. It has an RSA key to log in so no password and it autoloads shell from the .bashrc on login.

Voila! One keypress and I’ve got a twich chat server on a reasonably sized e-ink screen.