Description of Irish Whistle Tabs
Irish Whistle Tabs is an open-source Android tool to learn and improve your tin whistle skills. It features hundreds of traditional Celtic tunes (jigs, reels, polkas, ballads, etc.).
To play along, you can change the whistle key (D by default) and the tempo. It can play tunes and show the sheet music.
Here are some screenshots from the Google Play listing:
Irish Whistle Tabs is available on the Google Play store, for free, with no ads. Its source-code is on GitHub (see below).
This video showcases the app:
Source-code and technical details
In this section, I will be doing a technical overview of the implementation of Irish Whistle Tabs: how it works, what I used, etc.
It is the second Android app I release on the Google Play Store, after ElectroDB.
Like my previous app, the most critical part is getting a sufficiently large database. We need to find an open database in a format we can easily store and parse. There are two popular open formats that immediately come to mind: MIDI and MusicXML.
Fortunately, there is a much simpler format that is extensively used for folk music (including Irish/Scottish music): the ABC notation. It is a human-readable ASCII that uses the letters A through G, letter notation, to represent the given notes, with other elements used to place added value on these – sharp, flat, the length of the note, key, ornamentation.
This is an example of ABC notation:
|:E2BE dEBE|E2BE AFDF|E2BE dEBE|BABc dAFD:| d2fd c2ec|defg afge|d2fd c2ec|BABc dAFA| d2fd c2ec|defg afge|afge fdec|BABc dAFD|
This will be rendered as:
Sheet music for Drowsy Maggie rendered from ABC notation
TheSession.org is a fantastic community website dedicated to Irish traditional music. They provide a database of over 30,000 traditional jigs, reels, etc. under ODbL license, in ABC notation.
I made a Python pre-processor to combine a subset of those tunes plus an assortment of popular song in a JSON database. It also automatically transposes the music to the D whistle if necessary. My app must simply parse this file at run time.
The tabs are shown with the Tin Whistle Tab Font by Blayne Chastain. Once the ABC file are parsed, this conversion is trivial. Using a font to perform this task is a very convenient solution: it is lightweight, vector graphics, and is well supported by the Android text components.
The tempo and transpose settings in the app simply applies a modifier to the notes duration/pitch.
Because ABC notation is so compact, this system is very scalable.
A big part of this app is the ability to play the tunes. Thank to the ABC format parsing, we get a list of notes. However, we still need to convert it to sound we can play on the device. To keep the app very light (under 2 Mo), this must be done at run time.
Any flute is essentially an open air column, whose resonant frequencies are integer multiples proportional to half the length of the instrument. Closing holes is a way of increasing the effective length of the instrument and decreasing the fundamental resonant frequency.
The resonant frequencies of an open air column by Dave Pagurek.
The physical caracteristics of the instruments gives it a unique sound. This is known as the timbre.
To show this, this spectrogram plots a recording of a D5 note of a D whistle (Feadóg, brass). This is our baseline.
Spectrogram of a real whistle recording. The harmonics and vibrato are very noticeable. At the start of the note, we also see additionnal noise caused by the tonguing.
The most basic way to achieve synthesis is, for each note, to generate a sine with a frequency matching the note's pitch. This does play the music. The issue is that it does not render the timbre of the instrument, which makes its very unnatural sounding.
The graph below shows the waveform and spectrum of a real whistle recording compared to a pure sine (for a D5, 587 Hz):
Comparison between waveform and spectrum of a tin whistle recording versus a sine wave.
Therefore, we need to put a bit more work into this to get a better imitation. There are some additional considerations we need to take into account to get a natural sound: vibrato, "breathyness", envelope, reverb, etc.
The technique I implemented in the Java code is known as "modular synthesis". This idea is to feed the signal through a network of functions to get the desired sound. This is inspired by analog synth and is also very well suited for programmatic implementation.
This block diagram sums up my tin whistle synthesis:
Whistle synthesis block diagram
Input parameters are the pitch of the note and its duration. From left to right, the signal flow is:
- A bank of sine wave oscillators generates the fundamental frequency and harmonics. The amplitude for each harmonic is the most important factor. Interestingly, doing it by ear give better results than extracting the peaks in the recorded spectrum.
- Some noise is added to simulate the breath. Pink noise (1/f) gives slightly more realistic results, but it is more computationally expensive because it is generated by low-pass filtering Gaussian (white) noise.
- An ADSR (Attack, Decay, Sustain, Release) envelope shapes the note and feathers it. A powerful attack parameter simulates the tonguing.
- Several delayed and attenuated lines of the signal are added to simulate reverb. This trick makes the sound more natural without costing more computation time.
The way we configure the parameters of those blocks and how they are connected is key to get a realistic whistle synthesis. Mine should get better with future updates.
The user interface follows Google's Material design guidelines for the following reasons:
- The app's style is consistent with the Android UI/UX,
- It is very intuitive and efficient,
- The layout is easier to develop and maintain (using Android default elements),
- The design language is well defined with strict rules.
Some vectors assets I drew for Irish Whistle Tabs
The color palette is the official Irish flag's colors (green #169B62, orange #FF883E for contrast and white).
Two custom fonts are used: Tin Whistle Tab font (© Blayne Chastain, https://www.blaynechastain.com) and Uncial Antiqua font (SIL Open Font License, Version 1.1).
The full source-code of this app is on Github: https://github.com/CGrassin/tinwhistletabs
It is released under GNU GPL-2.0 license.
- Sølvi Ystad (2000, September). Sound Modeling Applied to Flute Sounds, from https://www.researchgate.net/publication/288349152_Sound_modeling_applied_to_flute_sounds
- Gordon Reid (2003, October). Practical Flute Synthesis, from https://www.soundonsound.com/techniques/practical-flute-synthesis
- Dave Pagurek (2019, March). Flute Synthesis, from https://www.davepagurek.com/programming/flute-synthesis/
Author: Charles Grassin
What is on your mind?
on May 30 2020, 23:59
#2 Elemental Impressions
on January 25 2021, 12:44
#3 Author Charles
on January 25 2021, 13:06