Category Archives: Music

Tunebook generator

I’m using below scripts to generate tunebooks.
These books I can print OR view on a tablet using my DIY bluetooth page turner. ( see other post )

I often work on tunes, add notes, text or write other versions.
So i needed a fast and simple way to re-generate a tunebook. ( hence the date on the title page and in the name, so i know whats the most recent version )
Now i have a separate tunebook for each instrument, with the same looks

What does this script?

  • Generates a title page using Latex
  • Generates a tune index, with page numbers ( works with multipage tunes )
  • Adds bookmarks to the tunes, so you can use the bookmark link in your reader.
  • Merges all pdf’s into one.

Todo: embed page numbers on every page?

BASH script:


nrpdf=$(ls *\.pdf | grep ^[A-Z]  | wc -l)
echo "Tune PDFs in directory : $nrpdf"
pages=$(( $nrpdf / 126 ))
pages=$(( $pages + 1 ))
echo "Needed index pages : $pages"

# Extra pages : Number 002-099
extrapages=$( ls 0*pdf | egrep -v "001|000" | wc -l)
echo "Extra pages : $extrapages"

nr=$(( 1 +  $extrapages + $pages ))
echo "Total pages for tunes : $nr"
echo "create column page as text"
nr=$(( $nr +1 ))
ls *\.pdf | grep ^[A-Z] | sort | while read ; do
echo "$nr $REPLY"
next=$(exiftool "$REPLY" | awk -F": " '/Page Count/{print $2}')
nr=$(( $nr + $next ))
done | cut -f1,3- -d" " | cut -f1 -d. | sed s/\ a$//g | sed s/\ b$//g | pr -2 -t > /tmp/col
echo "Create Index pdf"
vim /tmp/col -c "set printfont=courier:h12"  -c":let &printheader = \" \""   -c "hardcopy > | q"; ps2pdf

echo "Create title page pdf"
pdflatex "000 title.tex" 1>/dev/null


echo -n "Add bookmarks : "
ls *\.pdf | grep ^[A-Z] | sort | while read i ; do
    bookmarkTitle=$( echo $i | cut -f2- -d" " | rev | cut -f2- -d. | rev)
    bookmarkInfo="BookmarkBegin\nBookmarkTitle: $bookmarkTitle\nBookmarkLevel: 1\nBookmarkPageNumber: 1"
    pdftk "$i" update_info_utf8 <(echo -en $bookmarkInfo) output $tempPDF >/dev/null
    mv $tempPDF "$i"
    echo -n "."
echo ""
set +x
#ls *\.pdf | grep ^[A-Z] | sort > /tmp/pdflist
pdftk *pdf cat output ../tunebook_$(date +%Y%m%d).pdf

Needed tex file (named “000 title.tex”)

\usepackage[a4paper, total={6in, 8in}]{geometry}



    {\fontsize{50}{60}\selectfont Irish Tunes Test Tunebook}
	{\large Tunebook}\par
    {\itshape Henri - Exampletunes\par}
    {\scshape generated:} \\

File naming:

000 title
001 index
002 – 099 xyz (extra pages, not in index)
AAA – ZZZ Tunes (i take te first letters from the tune name)
example “BOR I was born for sports.pdf” is sorted under BOR from born

000 title.pdf
002 tuneinfo.pdf
BAT The Battle of Aughrim.pdf
BOR I was born for sports.pdf
CER Cerlew Jig.pdf
CHA Chanters Song.pdf
GAN Gander at the Pratie Hole.pdf
HON honeymoon.pdf
KIT Kitty Goes a-Milking.pdf
TER Terribus.pdf

51st highlanders I will name "AAA51 51st highlanders.pdf"

Output from the script

Tune PDFs in directory : 8
Needed index pages : 1
Extra pages : 1
Total pages for tunes : 3
create column page as text
Create Index pdf
Create title page pdf
Add bookmarks : ........

Needed software:

pdftk, pdflatex, vim, exiftool, texlive-fonts-recommended

Automating the h*ll out of windows applications using linux

I’m using a windows program for typesetting bagpipe music.
Luckily this runs on Linux using wine.

Sometimes i just want a PDF version of a tune, for example for my tunebook compiler. (Other post)
Or i want to batch convert a lot of bww files.

A long time ago i used a virtual machine with automation software for this.
Why not automate the process on my Laptop?

So i made this script, with a workaround for the xdotool wine problem.
(wine window needs to be active to accept key strokes, other linux xwindows you can use the ID of the window)

# use c for close at the end, without c bgplayer wont be shut down
# bww2pdf path/to/music.bww c
# make tmp file
cat "$1" > /tmp/deze.bww
# start bgplayer if not started .. if not started wait 3 secs
pgrep BGPlayer.exe >/dev/null || slp=3
pgrep BGPlayer.exe  >/dev/null|| ( nohup wine ~/.wine/dosdevices/c\:/Program\ Files\ \(x86\)/Bagpipe\ Player/BGPlayer.exe & )
sleep $slp
# get program id
pid=$(pgrep BGPlayer.exe)
# get xwindow id using pid
winid=$(xdotool search --limit 1 --all --pid $pid)
# activate window
xdotool search --desktop 0 --class "BGPlayer.exe" windowactivate
# open file menu and Open file
xdotool key --window $winid "alt+f"
xdotool key --window $winid "o"
# give program time to execute
sleep 1
# open our tmp file
xdotool type '\tmp\deze.bww'
xdotool key KP_Enter
sleep 2
# open file menu select Print and PDF as output
xdotool key "alt+f"
xdotool key "p"
xdotool key "P"
sleep 2
# execute
xdotool key KP_Enter
sleep 1
# File close
xdotool key "alt+f"
xdotool key "c"
sleep 2
# close program when c was added to commandline
mv ~/PDF/deze* "$1.pdf"
if [ "$2" == "c" ] ; then 
	xdotool key "alt+f"
	xdotool key "x"
I’m not touching the keyboard when the program is running, all handled by the script

A afternoon music with Irmgard

Missing playing music with our Folkband.
So i drove to Irmgard (our Harp player) to practice playing Concertina together!

Playing songs like:

  • Óró Sé do Bheatha Bhaile
  • The Rathlin Bog
  • Donegal Mazurka
  • Lucy Farr’s Barndance
  • Primrose Lass
  • Planxty Irwin

Talked about methods of music notations for Concertina.
In ireland most folk is being taught by ear.

Some examples of notation

Most of these we learn using lessons from Caitlín Nic Gabhann

At the end of the afternoon i replaced some strings on her harp.
Made someone happy again.

Spotify export

Nice .. you can request a data export from spotify, much like google’s takeout.

I wil export your streaming history, playlists, library and more.

Login spotify on a desktop, goto privacy settings and request data.

Nice to generate some statistics from this data.

For now the top 50 played artists (nr of times, artist)

790     "Rammstein"
507     "Fred Morrison"
478     "Lincoln Hilton"
437     "Avicii"
420     "Shooglenifty"
347     "Treacherous Orchestra"
323     "Battlefield Band"
321     "Breabach"
295     "Nightwish"
254     "The Fraser Shaw Trust"
236     "Michael McGoldrick"
207     "Peatbog Faeries"
207     "Calum Stewart"
203     "Lúnasa"
197     "Martyn Bennett"
194     "Jeff Wayne"
193     "The Prodigy"
173     "Kíla"
172     "Ross Ainslie and Jarlath Henderson"
170     "Buena Vista Social Club"
153     "Ross Ainslie"
150     "Dàimh"
138     "Bliss"
125     "Hans Zimmer"
124     "Rare Air"
118     "Michael McCann"
107     "Kyle Tuttle"
107     "Beinn Lee"
105     "Bourne & Macleod"
 89     "Wolfstone"
 88     "Ímar"
 83     "Afro Celt Sound System"
 81     "Gordon Duncan"
 81     "Armin van Buuren"
 80     "Face The West"
 79     "Tyurgen Kam"
 79     "Aly Bain"
 72     "Keltik Elektrik"
 71     "Duncan Chisholm"
 66     "Liz Carroll"
 63     "Project Smok"
 63     "Blazin' Fiddles"
 62     "Dagda"
 61     "Trail West"
 59     "Julian Winding"
 57     "Solar Fields"
 57     "Dougie McCance"
 56     "John McSherry"
 56     "AES DANA"
 52     "Gaelic Storm"

Get top 50 script

 cat  *json | grep artistName  | sort | uniq -c | sort -nr | head -50 | cut -f1,4,5 -d\" | sed s/,$//g

Music notation programs

I play several instruments, and know a lot of tunes by heart. But for some instruments i’d like to have a music sheet in front of me.
When playing new tunes or from my old stash, i need it on paper also.
And when i do, I’d like my music nicely printed and in the same style.

So i’ve been using multiple programs and tools to get a result i can live with.
I’ve got a huge collection of pipe and folk tunes, but whenever i decide that i’m going to play it more often then i’m going to re-create the music sheet.
The musicsheet will be printed and put in a folder. But also as PDF wil be placed in my calibre server, with i use to provide my tablets and phones with a digital version.
For automatically generating a PDF musicbook i’ve written some scripts.
These PDF’s i can use with my DIY bluetooth page turner.

For my bagpipe tunes i started a long time ago with a dos version of Bagpipe Music Writer. Getting a decent result from your printer was a b*tch. But it was do-able.

Several other programs i’ve tried but few stuck.
CelticPipes, Ceol Mor, Bagpipe (French), MusicTex, Lilypond for example.
I don’t like to click a symbol and place it on the bars, i like typing .. so i’m a little biased.
For midi and printing multi bar/staff music i also used Cakewalk Pro.

So i’ve been using the following software:

ABC Music notation :

X: 1
T:After the Battle of Aughrim
E2A2 ABcd | e2d2 c3A | B2G2 GFGA | B2AG E2D2 |
E2A2 ABcd | e2d2 e2ag | e2d2 BedB | A4 A4 :|
a2e2 e2fg | abag e2fg | abaf g3e | dedB G4 |
a2e2 e2fg | abag e2d2 | B2e2 d2B2 | A4 A4 :|
  • I use this mainly for Whistle and skeletal melody lines for Uilleann pipes (no ornaments)
  • Bagpipe IS possible but hard and ugly.
  • Multiple voices (harmony) is possible.
  • Chord names can be places above bars, as well as vocals.
  • I’ve made scripts with headers and footers to get the same output result.
  • Creating the music is typing the notes and ornaments in a text file.
  • Little chords for guitar mandoline are also possible.
# Edit/createing a abc music file
vi ; edit with plain editor
abcm2ps ; convert to ps
ps2pdf14 musicpiece.pdf ; ps convert to pdf
Also EasyABC i use occasionally

Bagpipe music:

I still use Bagpipe Music Writer, but the free Player, which is a full version also. (Long story)
Using wine on linux it is usable.

In the past i made a virtual machine which could be controlled by a web form and some CGI scripts.
I could paste a “bmw” score in a webform which would be send to the virtual machine, a BMW program would be started, printed the tune as a PDF that was send to the website again.

For a long time i also had a abc music to PDF convertor on my website.

I like the way of writing the tunes .. just type abbreviations of ornaments to print.
When you know these you are faster than using a mouse!

& sharpf sharpc
I!	hdbe Er_8 'e LAl_16		gbr LA_4					dbe Er_8 'e LAl_16			gg Fr_16 El_16 Dl_8
!	dbe Er_8 'e LAl_16		gbr LA_4					dbhg HG_4					tg Fr_16 HAl_8 'ha
!	hdbe Er_8 'e LAl_16		gbr LA_4					dbe Er_8 'e LAl_16			gg Fr_16 El_16 Dl_8
!	dbb Br_8 'b LAl_16	gg LGr_8 'lg dg Bl_16					dbhg HG_4					tg Fr_16 HAl_8 'ha			!t

There is no way to write harmonies.
In the past i’ve been using a pdf editor to merge music bars and align those by hand.
I’ve stopped doing that. I just print 2 versions.
Sometimes i use MuseScore for harmonies and multiinstrumental sheets

I wil post my MusicBook compiler here, when i’ve cleaned up the code.

i2c and cap1188 Musical instrument (from vga to esp32?)

Way back in 2018 i was playing around with i2c and touch.

CAP1188 Multi touch sensor

I remembered that VGA was using i2c to get information from monitors like brand/type and connection information.

I managed to access the cap1188 up to my Laptop via VGA.

2018 Schematic i used to abuse vga …

The final python code i used to play with the variables and playing sound i can’t find.
But below is the test code


# NOTE: i did a address scan, now i have 3v3 connected to AD, so probably the address is 0x28 !!

import smbus

bus = smbus.SMBus(1)    # 0 = /dev/i2c-0 (port I2C0), 1 = /dev/i2c-1 (port I2C1)

DEVICE_ADDRESS = 0x29      
DEVICEx = 0x10      

#Write a single register
bus.write_byte_data(DEVICE_ADDRESS, 0x1f, 0x3F)

#Write an array of registers
#ledout_values = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff]
#bus.write_i2c_block_data(DEVICE_ADDRESS, DEVICE_REG_LEDOUT0, ledout_values)
while True:

        print bus.read_byte_data(DEVICE_ADDRESS,0x10), bus.read_byte_data(DEVICE_ADDRESS,0x11) , bus.read_byte_data(DEVICE_ADDRESS,0x12), bus.read_byte_data(DEVICE_ADDRESS,0x13), bus.read_byte_data(DEVICE_ADDRESS,0x14), bus.read_byte_dat
a(DEVICE_ADDRESS,0x15), bus.read_byte_data(DEVICE_ADDRESS,0x16), bus.read_byte_data(DEVICE_ADDRESS,0x17)

Today i connected the cap1188 to a ESP32 and a piezo buzzer.

/*** Based on below library ***/
/*** Changed pins and added sound ***/

  This is a library for the CAP1188 I2C/SPI 8-chan Capacitive Sensor

  Designed specifically to work with the CAP1188 sensor from Adafruit

  These sensors use I2C/SPI to communicate, 2+ pins are required to  
  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_CAP1188.h>

const int TONE_OUTPUT_PIN = 26;
const int TONE_PWM_CHANNEL = 0; 
int freq = 0;

// Reset Pin is used for I2C or SPI
#define CAP1188_RESET  9

// CS pin is used for software or hardware SPI
#define CAP1188_CS  10

// These are defined for software SPI, for hardware SPI, check your 
// board's SPI pins in the Arduino documentation
#define CAP1188_MOSI  11
#define CAP1188_MISO  12
#define CAP1188_CLK  13

// For I2C, connect SDA to your Arduino's SDA pin, SCL to SCL pin
// On UNO/Duemilanove/etc, SDA == Analog 4, SCL == Analog 5
// On Leonardo/Micro, SDA == Digital 2, SCL == Digital 3
// On Mega/ADK/Due, SDA == Digital 20, SCL == Digital 21

// Use I2C, no reset pin!
Adafruit_CAP1188 cap = Adafruit_CAP1188();

// Or...Use I2C, with reset pin
//Adafruit_CAP1188 cap = Adafruit_CAP1188(CAP1188_RESET);

// Or... Hardware SPI, CS pin & reset pin 
// Adafruit_CAP1188 cap = Adafruit_CAP1188(CAP1188_CS, CAP1188_RESET);

// Or.. Software SPI: clock, miso, mosi, cs, reset
//Adafruit_CAP1188 cap = Adafruit_CAP1188(CAP1188_CLK, CAP1188_MISO, CAP1188_MOSI, CAP1188_CS, CAP1188_RESET);

void setup() {
  Serial.println("CAP1188 test!");

  // Initialize the sensor, if using i2c you can pass in the i2c address
  if (!cap.begin(0x28)){
  //if (!cap.begin()) {
    Serial.println("CAP1188 not found");
    while (1);
  Serial.println("CAP1188 found!");

void loop() {
  uint8_t touched = cap.touched();

  if (touched == 0) {
    // No touch detected
  for (uint8_t i=0; i<8; i++) {
    if (touched & (1 << i)) {
      Serial.print(touched); Serial.print("\t");
      freq = (i * 100);
      ledcWriteTone(TONE_PWM_CHANNEL, freq);


Finding the right pins or above pinout was the hardest part.
The sketch reads the pins binary so value 129 is first and last bit.

Now i have to get the sound sounding a little better and add frequencies and fingersettings to the sketch to get a minimal electronic bagpipe. (V3 it is .. )

To be continued ..

Bought some tunebooks in Scotland

While visiting the Ardbeg dristiller on Isle of Islay, i notished a tunebook with CD in the whiskyshop. Tunes for multiple instruments and pipe settings .. interesting! Fraser Shaw, didn’t know who he was. The tunes in the book looked interesting. I bought both .. we will see.

While reading more about him, i learned he was a driving force on the islands when it comes to folk music. Sadly he died by a illness .. far to soon. While on holiday we drove by some places he was know to play.
Tunes for whistle with guitar chords and pipe settings. Some tunes are in a complex time measure. I lost the CD but it is on spotify .. favourites: £50 Cashback and Air Chall

While visiting the Kildonan Museum in South Uist, i found a tunebook which was compiled of tunes from a piper named: Calum Campbell.

This oldskool piper wrote some amazing tunes. The book was made after he, his daughter and her two children lost their lives in a heavy storm in 2005.
2005 Was a bad year .. we lost John D Burgess, Martyn Bennett and Gordon Duncan the same year.

On our way home we visited the Morpeth Chantry Bagpipe Museum.

Most of the pipes here where Northumbrian bagpipes and some borderpipes ( even a shuttlepipe )

Our Northumbrian pipes

In the touristy shop i found these books, amoung others.

Last two are Duets/Trios also for different instruments .. nice!

Portable Logitech Media Server again

See post:

In the past i’ve used a home build Logitech Squeezebox server (as it was called then), Picore player and tried volumio.
Picore player has been sitting in my livingroom for ages, but was converted to a Node-Red Dashboard and recently Home Assistant Dashboard. (Has been a dasticz daskboard also)

Today i build another version, smaller and with a screen.
Why? .. because of being ‘offline’ or ‘offgrid’ on our holidays.
The car we are driving only has a Aux input.

Most of the installation is as mentioned on:

I edited  /opt/
to get /dev/sda1 mounted persistent
use pcp br after editing.

Default user/pass : tc piCore

Controlling the thing is via touch or a app on my phone using wifi hotspot.

  • Audio cable 3.5mm
  • Raspberry 3
  • Large usb thumbdrive
  • 3.5inch RPi Display – 480×320 Pixel – XPT2046 Touch Controller
  • car cigarette lighter adapter for power

PiCore uses below alliases

ceChange directory to /mnt/mmcblk0p2/tce
ceoChange directory to /mnt/mmcblk0p2/tce/optional
m1Mount the boot partition /mnt/mmcblk0p1
m2Mount the second partition /mnt/mmcblk0p2
c1Change directory to /mnt/mmcblk0p1
c2Change directory to /mnt/mmcblk0p2
vicfgEdit configuration file config.txt using vi
vicmdEdit boot file cmdline.txt using vi
u1Unmount the boot partition /mnt/mmcblk0p1
u2Unmount the second partition /mnt/mmcblk0p2

Shutting down piCore is done by cutting the power, due to everything being mounted readonly. EXEPT
When you are using LMS server installation, which uses a database.
But there is a tweak for a shutdown button.

I’m using GPIO 16 because i’ve got a screen connected.
Active LOW, means you have to connect a pushbutton/switch between GND and GPIO pin. (nearest Vcc OR Gnd)

Project mixer

I made a sound mixer controller for my applications, a while ago.

Some arduino project laying around on my desk. (OBS controller, Mqtt-sound-and-display-with-mute-acknowledge-button and Octoprint monitor, below that my dusty mixer)

I’m probably make a V2 with new functionality:

  • Switching applications which are using sound from speakers to headset and vice versa.
  • Led showing muted channels
  • Rotary buttons? Or motorized sliders?

See my other post ..

Software i use(d)

Below from a old shared document (needs editing)

  • 3D printing
    • Openscad
    • Cura
    • Meshroom
    • Blender
    • Sketchup
    • Octoprint (see esp monitor)
  • API
    • Postman
    • Flash (python) see ledserver
  • Beamer
    • Mapmap
    • LPMT
  • Brewing
    • Brouwhulp
    • Brewfather
  • Browser stuff
    • vimperator (old)
    • links/curl/dsniff/urlsnarf
  • Databases (mariadb/mongodb/influxdb/sqlite)
    • Metabase
    • Adminder
  • Drawing/Image manipulation
    • Gimp (see wacom script)
    • Hugin
    • ImageMagick
    • Krita (wacom)
    • Scrot (snapshot tool)
    • Luminace-hdr
    • Blender
    • Sketchup
    • GDlib
  • Ebook Readers
    • Calibre
    • Fbreader
  • Editors
    • Vim
    • Scribus
    • Dia (old)
    • Drawio
    • Blackmagic Fusion
  • Filemanagers
    • Ranger
    • MC
    • fdupes
    • PureRef
  • Google
    • gcalcli
    • gcalcron
    • rclone for syncing
  • Home automation
    • Domoticz
    • Node-red
    • Home assistant
    • MQTT-Explorer
    • Mosquitto
  • IDE’s
    • Android studio
    • Arduino IDE
    • Nextion IDE
    • PlatformIO
  • IRC
    • Irssi
  • Mail
    • Mutt
    • Mailcow
  • Media Players
    • Vlc
    • Kodi (openelec/xbmc)
    • Tinymediamanager
  • Monitoring
    • Check_mk (i’ve started with Netsaint (1999), Nagios,Icinga,
    • Librenms (was observium)
    • Grafana
    • Cacti (old)
  • Networking
    • Winbox (Mikrotik)
    • GNS3
    • iptraf
    • ntopng
  • Note keeping
    • Joplin
    • Twiki/Foswiki (old)
  • Password managers
    • Keepass2 (with browser plugin)
    • KeepassXC (with browser plugin)
  • Photomanager
    • Digikam
    • Darktable
    • Rawtherapy
    • Gallery2/3/Wipigo
    • Jellyfin
    • My own photo manager
    • Pureref
    • Cewe Photobooks
    • qdlsrdashboard
    • gphoto2
  • Schematics/Electronics
    • Fritzing
    • Login
    • Ktechlab
  • Sound
    • Ardour5
    • Audacity (old non-cripled-version)
    • LMMS
    • Puredata
    • Cadence
  • Video
    • Handbrake
    • Avconv/FFMpeg
    • Blender
    • Openshot
    • OBS
    • Natron
    • Vlc
    • yt-downloader
    • 4k downloader
  • Music engraving software
    • Bagpipe Music Player
    • ABCmusic (see own tools)
    • MuseScore
    • Lilypond
  • Taggers
    • Mp3tag
    • Tinymediamanager
    • MusicBrainz Picard
    • Beets
  • Music players
    • MOC
    • SoftSqueeze
    • Spotify
    • Clementine
    • Badly Designed Sound Machine
  • Server stuff
    • Namazu2
    • Netdata
    • Ntopng
    • Snort/Snortsam
  • Virtualisation
    • Opencv (old)
    • Vmware/ESX (old)
    • Xen (old)
    • VirtualBox
    • Libvirt/Kvm/Ovirt
  • Window managers (See other post)
    • Xmonad (current)
    • Gnome (current)
    • Enlightenment (old)
    • Compiz (old)
    • Fluxbox (old)
    • Ratpoison (tried)
    • Twm (tried)
    • Xfce (old)
    • Window Maker(old)
    • Sawfish (old)
    • Kde (old)
    • i3 (old)
    • IceWM (old)
    • Motif (old)
    • Flwm (old)
    • Fvwm (old)
    • Ximian desktop (bought) (old)
  • Home Drawing
    • Sweethome3D
    • Blender
    • Sketchup
    • Drawio
  • Old but cool
    • Mainactor
    • Appleshake
    • Zbruch
    • Povray
    • Lightzone

Other tools:

Git, tig, xdotool, nmon, ntop, iotop, etc etc (lijstje genereren)