Irish Whistle Tab - Android app

Code - 24-05-2020

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).

Google Play

Promotional video

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.

Database

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 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.

In the app, I render the sheet music directly with abcjs in a WebView (MIT licensed ABC renderer in JavaScript).

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.

Flute synthesis

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 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 D5 recording 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):

Waveforms and spectrum of whistle recording and sine 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:

Block diagram of 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.

User interface

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.

Assets for the app 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).

Source code

The full source-code of this app is on Github: https://github.com/CGrassin/tinwhistletabs

It is released under GNU GPL-2.0 license.

References

  1. Sølvi Ystad (2000, September). Sound Modeling Applied to Flute Sounds, from https://www.researchgate.net/publication/288349152_Sound_modeling_applied_to_flute_sounds
  2. Gordon Reid (2003, October). Practical Flute Synthesis, from https://www.soundonsound.com/techniques/practical-flute-synthesis
  3. Dave Pagurek (2019, March). Flute Synthesis, from https://www.davepagurek.com/programming/flute-synthesis/

Author:


What is on your mind?

  • #1 sagan

    Ok this is absolutely awesome. After testing the app and listening to the generated tunes maybe a little vibrato (pitch variation) could be added.
    It would depend on the actual duration of the note (so tempo should be taken in account) with a random variation of the vibrato speed, intensity and maybe tone. I hope that it should add the little imperfection that would feel more "human".
    Another thing is that a real whistle player needs to breathe. It means that the attack (start) of a phrase will be stronger.
    Maybe you can play with schemes like adding more vibrato at the end of a note, or more on the longest notes, or detect if the song is in major / minor scale and vary "human" parameters.
    Last thing is the simplest and the time/benefit ratio should be great: just add a little reverb (works best with the vibrato).
    I have other ideas concerning note sequences if you want to push the "human simulation" aspect.
    You should have seen it by now but just in case:
    http://www.tech.dmu.ac.uk/~dylan/z/dylan/project/cyberwhistle/index.html
    Thanks a lot and keep up!

    on May 30 2020, 23:59

  • #2 Elemental Impressions

    File import?
    Would be nice to import ABC files to add to tune list. (Plus jpeg for score)
    You have a great subset but it would be great to be able to add tunes I'll be using in a set.

    on January 25 2021, 12:44

  • #3 Author Charles

    Hi Elemental Impressions,
    Thank you for your suggestion ! However, to implement this idea, I have several technical challenges. I might do a website version of this app to solve those, including support for other devices.

    on January 25 2021, 13:06

  • #4 Brooche

    Thus, AI might be the most preferable option in adjuvant hormonal therapy choice <a href=https://acialis.buzz>soft tab cialis</a> becuse you abused the shit out of roids your HPTA is shot and SERM s will not work for you

    on December 13 2023, 4:39

  • #5 Caitlin Huxley

    Charles, this is really a fantastic app. I do some minor python scripting for data analysis, but you've blown me away here. As a music fan, who recently picked up the tin whistle, I've enjoyed learning easily with your app. I'd love to expand the app to include other songs, or some different ways for users to categorize the songs.

    on April 23 2024, 16:44

  Back to projects

Related articles