You are on page 1of 44

FACULTY OF ECONOMICS AND BUSINESS

Fingers to frets - A Mathematical Approach


Optimizing Finger Assignment for Guitar Tablature

Bernd Tahon
r0377485

Thesis submitted to obtain


the degree of

Master in de toegepaste economische wetenschappen:


Handelsingenieur
Major Data science en business analytics

Promotor: Prof. Dr. Frits Spieksma


Assistant: Bart Vangerven

Academic year: 2016-2017


Contents

Preface v

1 Introduction 1

2 Literature review 5

3 Problem description 9
3.1 Model 1: Scale-based guitar music . . . . . . . . . . . . . . . . . . . . . . 10
3.1.1 Mathematical Model . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2 Model 2: Chord-based guitar music . . . . . . . . . . . . . . . . . . . . . . 17
3.2.1 Mathematical Model . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4 Implementation and Results 23

5 Conclusion 29

Appendix 33
A.1 Python Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

iii
Preface

To hell with the rules. If it sounds right, then it is. - Eddie Van Halen

As Eddie Van Halen, considered one of the world’s best guitarists, points out: rules,
especially in the art of music, have their limitations. In this thesis, we try to model the
left-hand finger assignment of a right-handed guitarist through the use of certain rules.
Yet, just as Van Halen points out, sometimes the rules don’t apply. Sometimes, for some
notes, an experienced guitar player would opt for another finger assignment than the
one the model returns. Sometimes, what may look wrong can sound right.

This does not mean that the models are not useful - it rather reinforces what this thesis
is meant to be: first off, a tool for beginners, who are about to embark on the wonderful
journey of becoming a guitar player; secondly, a building block, a piece of work that
can be built on, that can be improved and that can be incorporated in more complex
models with different aims; lastly, and maybe most importantly, a thought process, that
gives insight into decisions that experienced guitarists make unconsciously and why they
make them. This insight can make you a better guitarist.

Personally, writing this thesis has taught me many things. Not only have I honed my
research, mathematical and programming skills, and have I gained the insight described
above, most of all I was amazed by the power of the human mind. I was surprised
to learn that something that is relatively easy and happens unconsciously for a semi-
experienced guitarist like myself, can be so challenging to write down and ‘explain’ to a
computer. What sometimes seems trivial for the trained human mind is often a rather
complex process.

Throughout my writing of this thesis, many people have supported me. First of all,
I would like to thank my promotor, prof. dr. Frits Spieksma, and his assistant, Bart
Vangerven, who were of great help in showing me the world of linear optimization and
in decomposing the thought process of guitar finger assignment into mathematical equa-
tions. Secondly, I would like to thank my parents and friends for their unconditional
support and help over the years that brought me to this point in life, finishing the chap-
ter of my studies. Thirdly, I would like to thank you, the reader, for taking the time for
going through this work. I wish you an interesting journey, hopefully not to hell, with

v
the rules for optimal finger assignment that are developed throughout this thesis. Let’s
hope it sounds right.

Leuven, 19/05/2017.
Chapter 1

Introduction

Guitar tablature 1 allows musicians to play musical pieces without having to read stan-
dard musical (“staff”) notation. Tablature consists of six parallel lines representing a
guitar’s six strings2 with the bottom string (i.e. the thinnest one which produces a high
e) at the top. Numbers on these lines indicate the frets that should be pressed down
on the respective strings, chronologically ordered from left to right. As a consequence,
notes that need to be played simultaneously are situated on one vertical line. In the
remainder of this thesis, we will call each moment in time at which a note or multiple
notes should be played a ‘timestamp’.

Figure 1.1 shows an example: the first two bars of the intro of Eric Clapton’s acoustic
version of ‘Layla’. During the first timestamp, the A-string should be plucked without
pressing down a fret (this is called an ‘open string’), followed by the third fret on the
same A-string. Subsequently, during the third timestamp, the second fret on the G-
string is played simultaneously with an open D-string, and so on.

Figure 1.1: The tablature for the first two bars of the intro of the acoustic version of
Layla by Eric Clapton [1]
1
We use ‘tablature’ to indicate guitar tablature in the remainder of this thesis
2
A standard guitar has six strings, that produce, in standard tuning, the following notes from top to
bottom: low E, A, D, G, B, high e

1
2 CHAPTER 1. INTRODUCTION

Consequently, tablature tells a guitarist which strings and frets to play at each point in
time. It does not, however, give the finger assignment, i.e. which left-hand3 finger should
be used to press down a string and fret. For more advanced guitarists, this finger assign-
ment is an acquired skill and happens unconsciously for the majority of guitar pieces.
On the other hand, beginning guitarists often struggle with this, adding another layer of
complexity to their learning. To cope with this, a guitar teacher would typically write
the fingers to be used at each point in time under the tablature. Nowadays, however,
more and more people try to teach themselves how to play the guitar using the internet.
One can find tablature for virtually every song on the world wide web, but they seldom
include the finger assignment.

Therefore, a tool that calculates and displays the optimal finger assignment for a given
piece of tablature, could offer significant gains in guitarists’ learning curves and take
away motivational hurdles that beginners often face. A good tool would also take into
account the personal preferences and the physical characteristics of the player. More-
over, a functioning model could be implemented in models for automatic transcription
of audio signals or for translating staff notation into tablature4 .

In this thesis, we make use of the software package Guitar Pro 7 to generate tabla-
tures. For the majority of popular songs, free Guitar Pro tablature files can be found
on the internet. In addition, Guitar Pro is able to parse the common ASCII-format for
tablature. Guitar Pro enables the user to manually write the left-hand finger assignment
below the tablature with a number: number 1 refers to the index finger, 2 to the middle
finger, 3 to the ring finger and 4 to the pinky finger. In the remainder of this thesis, we
will use that convention. Two examples of different finger assignments are depicted in
Figures 1.2 and 1.3 .

Figure 1.2: A good finger assignment for the first two bars of the intro of the acoustic
version of Layla by Eric Clapton

In order to illustrate the importance of a good finger assignment, consider those two
3
We assume, without loss of generality, a right-handed player
4
These concepts are further explained in Chapter 2
3

Figure 1.3: A bad finger assignment for the first two bars of the intro of the acoustic
version of Layla by Eric Clapton

examples. In the first case (Figure 1.2), the ring finger plays the third fret during the
second timestamp, whereas the middle finger plays the following note on the second fret.
Until the last depicted timestamp, the left-hand wrist does not move and all fingers are
kept in position on the same fret. At the seventh timestamp, the index finger plays the
first fret and the ring finger plays the third fret simultaneously, keeping the distance
between fingers comfortable.

Consider now the bottom case (Figure 1.3), where the wrist is required to move around:
the index finger jumps around from the third fret to the second, back to the third and
finally, at the seventh timestamp, to the first fret. In addition, between the second and
third timestamp, it needs to move down two strings, complicating the ease as well as the
fluency of playing. Lastly, playing the frets at the seventh timestamp with the index and
middle finger requires the player to stretch his fingers and makes it hard to play this.
In conclusion, the upper finger assignment would be preferred by most guitarists as it
implies no wrist movement, limited movement across strings and comfortable inter-finger
distances.

While there exist good and bad finger assignments, as demonstrated in the example
above, there is no such thing as THE optimal finger assignment for a given song. Con-
sider the example in Figure 1.4 on page 4. A guitarist with large fingers could opt for the
first finger assignment, where the middle finger stays on the A-string, the pinky finger
on the B-string and the index finger on the e-string. He can play all the notes by just
sliding over these strings, minimizing the effort required. Someone with small hands and
fingers, however, will have trouble stretching the middle finger and the pinky finger far
enough from each other to cover the distance required between the third and the fifth
fret. Consequently, this guitarist could choose for the second finger assignment, which
requires the index finger to jump around from the A-string to the e-string and back, but
allows the relatively wide spread between the third and the fifth fret to be played with
4 CHAPTER 1. INTRODUCTION

the index and the pinky finger. This example illustrates the need for personalization,
allowing user-specific inputs.

In summary, the aim of this thesis is to develop a user-specific model that gives good
finger assignments for any given guitar tablature. The remainder of this thesis is struc-
tured as follows. In chapter 2, we discuss the existing literature on similar problems
for both guitar and other musical instruments. In chapter 3 we give a precise problem
description. Chapter 4 discusses the implementation and its results. Chapter 5 gives the
main conclusions and possible steps for subsequent research.

1 Finger assignment 1: for a guitarist with large fingers

2 Finger assignment 2: for a guitarist with small fingers

Figure 1.4: The importance of user-specific inputs: different finger assignments for dif-
ferent people. (From “The Beatles - Blackbird”)
Chapter 2

Literature review

Concerning guitar pieces, little has been written on finger assignment. Most work focuses
on automatic transcription of audio signals or, more specifically, the determination of
optimal fret-string combinations for a given piece of music. This is due to the fact that
several fret-string combinations (so called ‘fingering’1 ), are possible for a given guitar
piece since the same note can be played on multiple combinations of frets and strings: a
given note can have up to six different positions on the fretboard [2]. Despite the differ-
ent and wider focus, this work is still useful for this paper, as they attempt to model and
minimize the difficulty of certain finger movements and make an implicit assumption of
finger assignment in their model. We will now discuss the most relevant literature on
this fingering decision.

Radisavljevic and Driesen [3] make use of dynamic programming with cost functions
to map music score into playable fret-string combinations. Each set of simultaneously
played notes is broken down into a set of corresponding fingering alternatives, which
they refer to as different ‘states’. These states are represented by matrices with one row
(string, fret, finger) for each note. Subsequently, they split their cost function in a static
cost and a transition cost. The static cost function models the cost of one single state, or
thus the cost of playing one chord. The transition cost function models the cost of tran-
sitioning from one state to the following state. To avoid assigning a cost to each single
state or transition and in this way reduce computational memory requirements, they use
features to uncover desired states. Static cost is based on features such as “number of
frets between consecutive fingers”. Transition cost, in turn, is based on features such as
“numbers of frets traversed by a specific finger” or “finger changes from used to unused”.

Additionally, they developed a technique called ‘path difference learning’ to automati-


cally select cost function weights by using a training set of published tablatures. In this
way, they avoid lengthy interviews with guitarists and manual adjustment of cost func-
1
‘Fingering’ or ‘fingering decision’ needs to be discerned from ‘finger assignment’. In this thesis, the
former indicates the choice of fret and string to play a note, while the latter refers to the choice of
left-hand finger to play this note with.

5
6 CHAPTER 2. LITERATURE REVIEW

tions leading to rather subjective weightings. In their experiments, they shorten songs
by removing repeated sections such as a returning chorus. Radisavljevic and Driesen
remark that a complete convergence between the model and the published tablatures
can never be reached, due to personal preferences of guitarists, the features of the cost
function not being exhaustive and the limited flexibility of the linear cost functions.

Yazawa, Itoyama and Okuno [4] developed a dynamic programming method for au-
tomatic transcription of tablature from audio signals, taking into account the player’s
skill. In this method, acoustical reproducibility (i.e. how similar are the pitches and
timbres to the original piece) and fingering easiness are balanced and can be attributed
different weights. For example, beginners will generally favor fingering easiness and
thus allocate it a higher weight. This fingering easiness is broken down into the cost of
playing a fingering configuration and the cost of changing fingering configuration. The
former is determined by finger spread, number of fingers used, the fret position of the
index finger and whether or not it is a barre chord2 . The cost of changing fingering
configuration is, in turn, broken down into the distance the player’s wrist travels during
a transition (i.e. the distance the index finger travels) and the Manhattan distances of
the fingers thereafter. Each of these cost drivers can again be assigned different weights
based on a player’s preferences. The model is solved by finding the longest path in a
weighted acyclic graph where the vertexes represent potential fingering configurations.
These configurations are enumerated through a standard guitar chord book.

Miura and Yanagida [5] created S2T (Score to tablature) software to automatically
translate a musical score to a playable tablature. Again, the cost of finger position pat-
terns is split up in the weighted sum of left hand movements and finger movements. In
this system, they automatically assign a placing finger to each note as follows: if the
fret span is lower than four, each of the fingers is assigned to the corresponding fret,
index to little finger from left to right. If the fret span is higher (i.e. five or six), the
index or little finger should be stretched to reach one fret further. After allocating the
fingers, the appropriate position is obtained as the one which minimizes the total sum
of left hand movements. Their software outperforms current commercial software but is,
in turn, still outperformed by a trained guitarist. The S2T software is the only tool in
this literature review that explicitly outputs left-handed finger assignment. It does this
with a number below the notes on the tablature: 1 for the index finger, 2 for the middle
finger, 3 for the ring finger and 4 for the little finger.

Hori, Kameoka and Sagayama [6] make use of an Input-Output Hidden Markov Model to
find the most probable sequence of forms (i.e. string-fret combinations) given a certain
melody. They assume that beginner guitarists want to minimize left hand movement
along the neck of the guitar while avoiding difficult left hand forms. The probability
of a form being selected as the next form in a sequence depends on the previous form,
2
When a guitarist uses one finger to simultaneously press down multiple strings in one fret, it is called
a barre chord.
7

characterized by the distance the index finger travels, and on the time interval between
the two. Moreover, the difficulty of the form is characterized by the index finger po-
sition, the width (i.e. the maximum distance between two fingers) and the number of
active fingers (i.e. fingers that are being pressed down on a string). ‘Idling fingers’ (i.e.
non-active fingers) are assumed to be on consecutive frets with active fingers. They
compare their model to existing commercial tools Power Tab Editor and Guitar Pro,
and conclude with a clearly better performance, but they do note that future studies
should include the possibility to tailor the model to personal preferences.

Tuohy and Potter [2] developed a genetic algorithm (“GA”) to map sequences of music
notes in staff notation to positions on the fretboard for tablature. Their fitness function
consists out of two main components: hand movement and hand manipulation. Hand
movement means that the more the hand and fingers move across the strings and fret-
board, the lower the fitness of this fingering will be. Hand manipulation, on the other
hand, assesses whether a chord is an open chord (i.e. each finger presses down maximally
one string) or a barre chord, but also how long a position can be held without moving
the hand.
Tuohy and Potter compare their GA with commercial software such as Guitar Pro 4,
which tends to underperform their GA since it creates tablature note by note without
looking ahead, while a GA looks at the piece as a whole and tries to improve the whole
piece simultaneously.

Lastly, we consider the finger assignment for another instrument: Balliauw [7] presents
the problem of determining the optimal finger assignment for a piano piece as a com-
binatorial optimization problem, picking a finger for every note that has to be played.
The objective is to minimize a cost function based on rules that penalize certain finger
combinations and sequences. Rules include, for example, “add 2 if the piano key distance
between two consecutive notes exceeds the ‘comfortable distance’ (i.e. a parameter) be-
tween the finger pair concerned” or “add 1 if the pinky finger is used”. To model the
penalties for distances between fingers, Balliauw makes use of three types of parameter
matrices that represent minimum and maximum distances between finger pairs: firstly,
relaxed distances which can be easily played; secondly, practical distances which are the
absolute minimum and maximum inter-finger distances that are possible to play; and
thirdly, comfortable distances which can be played without hamper. These distance ma-
trices are user-specific and can thus be tailored to a single user. As Balliauw points out,
the use of rules allows to identify multiple origins of difficulties resulting from a specific
finger assignment, assign weights to them and allow trade-offs. He does not, however,
give an explicit integer programming formulation in the paper.

Balliauw introduces a variable neighborhood search (“VNS”) algorithm to solve the


problem in a reasonable amount of time. While the performance of this VNS algorithm
is satisfying, Balliauw suggests two potential improvements with regards to the algo-
rithm and the objective function. The algorithm could, for example, be improved by
8 CHAPTER 2. LITERATURE REVIEW

reducing the calculation time through splitting the music piece in smaller parts (e.g. at
a rest). Improving the objective function, on the other hand, could be done through
parameter training.

Compared to Balliauw’s model for piano, certain complicating factors arise in the case
of the guitar. First, in contrast with one-dimensional piano keys, guitars have both
multiple strings and multiple frets, making it a two-dimensional exercise. Second, frets
get smaller when one moves up the neck of the guitar, making it easier to stretch fingers
across multiple frets the more you move up the fretboard. Finally, while typically one
finger can play at most one key on the piano, the use of barre chords allows guitar players
to press down multiple strings across one fret.
Chapter 3

Problem description

The aim of this thesis is to develop a model which outputs ‘good’ finger assignments.
A good finger assignment is one that would be picked by trained guitarists, and can be
personalized for different users.

We introduce two concepts to differentiate between two types of guitar pieces: scale-
based and chord-based guitar music. Scale-based1 music includes mainly lead gui-
tar pieces such as solos and electric guitar intros, that consist of mostly single notes
(monophony) or notes on adjoining strings that can be strummed with a pick rather
than plucked with one’s right-hand fingers. Chord-based music, on the other hand, in-
cludes mainly guitar pieces that contain various notes that are played simultaneously on
non-adjoining strings and are often plucked with one’s right-hand fingers (‘fingerpick-
ing’). In this kind of guitar pieces, certain finger positions (‘chords’) are held for a longer
period of time while the different strings are being plucked. Note that the distinction
between scale-based and chord-based pieces is not straightforward, and one guitar piece
can include both scale-based and chord-based parts.

We will build two slightly different integer programming models that accommodate for
the different needs of these types of guitar music. Both models consist of minimizing a
cost function that penalizes different components of difficult finger assignments. Their
components are the same, but they differ in the way some of these components are build
up.

For both models, two simplifying assumptions are used:

• One finger plays at most one note (i.e. one string and one fret): no (partial) barre
chords.

• The thumb cannot be used to press down a string


1
Guitar scales are standard patterns of notes that sound well together and that can be used to write
music or to improvise

9
10 CHAPTER 3. PROBLEM DESCRIPTION

3.1 Model 1: Scale-based guitar music


The scoring of a specific finger assignment is based on both static and transitional
components [3, 4]. The static component measures the difficulty of a finger assignment
at one timestamp and consists of inter-finger distances [3, 4, 5, 6, 7] and the use of
the pinky finger [7]. The transitional component, on the other hand, measures the
difficulty of transitioning from one timestamp to the next, given the finger assignment,
and consists of the wrist movement (i.e. a horizontal component) [2, 4, 5, 6] and the
movement across the strings (i.e. a vertical component) [2, 4]. Figure 3.1 summarizes
the different components of the objective function. Each of these components is discussed
in detail below.

Figure 3.1: The different components of the objective function.

Inter-Finger Distances This component of the objective function is used to avoid


impossible finger combinations and to penalize uncomfortable ones. This includes having
to stretch fingers too far, or squeezing them together too much. Similar to Balliauw [7],
we make use of parameter sets of comfortable and absolute distances between each
finger pair, uniquely defined for each user. Distances that fall outside of the minimal
and maximal comfortable distances are penalized while distances that fall outside the
absolute bounds are excluded through a high cost.

Use of the pinky finger Beginning guitarists often struggle with using their pinky
finger. The user can personalize the weight of this component in the objective function
to obtain a finger assignment of their liking. Some beginning guitarists prefer limiting
the pinky finger’s use to be able to play a certain guitar piece more fluently, while others
might want to train their pinky finger to become a better guitarist and thus not penalize
it (heavily).

Wrist movement Since fingers are interconnected and moving one finger over the
fretboard implies moving the others too, the movement of the wrist is the most impor-
tant horizontal determinant of the ease of playing. In order to play a guitar piece fluently
and easily, one should aim to keep their hand as much as possible in the same position.
3.1. MODEL 1: SCALE-BASED GUITAR MUSIC 11

The wrist position is usually determined through the fret position of the index finger.
When, however, the index finger is not used at a certain point in time (i.e. not pressing
down a string), an assumption needs to be made. In this model for scale-based guitar
pieces, we will use the hypothesis that non-active fingers are on consecutive frets, called
“in-place performance” [5, 6]. For example, if the middle finger on the sixth fret is the
only finger being used at one point in time, the index finger and thus the wrist position
is assumed to be one fret lower, i.e. on the fifth fret.

Movement across strings A good finger assignment is one that limits the move-
ment of fingers. While the most important horizontal movements are covered in the
wrist movement component, this second transitional component penalizes (large) verti-
cal movements across strings. It is easier to slide one’s finger across the fretboard than to
lift it to move across strings. Moreover, this component can be tuned to reward staying
on the same string with one finger: evidently, when the same string and fret needs to
be played two times in a row, this should be done with the same finger - but also when
the fret changes, it is still easier to slide one’s finger to this fret.
12 CHAPTER 3. PROBLEM DESCRIPTION

3.1.1 Mathematical Model


A piece of music consists of a sequence of notes to be played at a specific moment in
time. To that end, we define T as the set of timestamps. It follows that we have to make
decisions at every moment t ∈ T : what finger(s) do we use to play the required notes?
Note that there is one exception: no finger is required to play open strings. A guitar
usually has six strings, which are contained in the set S = {E, A, D, G, B, e}2 . The set
of frets is denoted by G. The number of frets is fixed at n and equal for every string
s ∈ S. In order to identify each fret-string combination (i.e. location on the fretboard)
uniquely, we give all frets a unique number, as depicted in Figure 3.2 for a guitar with
12 frets. In this example for a guitar with n = 12 frets, the first fret on the A-string

Frets: 1 2 3 4 5 6 7 8 9 10 11 12
Strings:
e

61 62 63 64 65 66 67 68 69 70 71 72

49 50
14 51
15 52
16 53
17 54
18 55
19 56
20 57
21 58
22 59
23 60
24

37 38 39 40 41 42 43 44 45 46 47 48

25 26 27 28 29 30 31 32 33 34 35 36

13 14 15 16 17 18 19 20 21 22 23 24

1 2 3 4 5 6 7 8 9 10 11 12

Figure 3.2: From strings and frets to identifiers: position numbering starts on the thick
E string and continues on to the A, D, G, B, and e strings respectively.

would have number, or “identifier”, 13. We denote the set of these position identifiers
by P = S × G. Note that we do not include open strings in this set. The reason for
this is simple: no finger is needed to play an open string. The set of fingers, available
to play the guitar, is F = {1, 2, 3, 4}3 , where the first finger corresponds to the index
finger, the second finger to the middle finger, the third finger to the ring finger, and the
fourth finger to the pinky finger. The different sets are summarized below:
• T is the set of timestamps, i.e. the set of all points in time during which a note is
played.
2
We assume, without loss of generality, the guitar to be in the standard tuning. Moreover, this set
can be customized for, for example, 12-string guitars or 4-string bass guitars.
3
If necessary, the set F can be adapted for people with injured fingers
3.1. MODEL 1: SCALE-BASED GUITAR MUSIC 13

• S = {E, A, D, G, B, e} is the set of strings.

• F = {1, 2, 3, 4} is the set of fingers available to play the guitar.

• G = {1, .., n} is the set of frets for a guitar with n frets.

• G 0 = {−2, .., n} is the set of ‘extended frets’, as the wrist position can be located
left of the first fret based on the consecutive fret assumption.

• P = S × G is the set of unique fretboard position identifiers.

• Pt denotes the set of fretboard positions to be played at timestamp t, based on the


tablature of the concerned song.

• Th denotes the set of (t, p)-vectors that give the timestamp t ∈ T when, and posi-
tion p ∈ Pt where, a hammer-on4 starts, based on the tablature of the concerned
song.

• Tp denotes the set of (t, p)-vectors that give the timestamp t ∈ T when, and
position p ∈ Pt where, a pull-off5 starts, based on the tablature of the concerned
song.

• Ts denotes the set of (t, s)-vectors that give the timestamp t ∈ T when, and string
s ∈ S on which, a slide6 starts, based on the tablature of the concerned song.

Decision variables

• Ft, p, f is a binary variable which is one iff at timestamp t ∈ T , position p ∈ Pt is


pressed by finger f ∈ F.

• St, s, f is a binary variable which is one iff at timestamp t ∈ T , string s ∈ S is


pressed by finger f ∈ F.

• Gt, g, f is a binary variable which is one iff at timestamp t ∈ T , fret g ∈ G is pressed


by finger f ∈ F.

• ∆g, g0 , f, f 0 , t is a binary variable which is one iff distinct fingers f and f 0 ∈ F are
both used on respectively frets g and g 0 ∈ G at time t ∈ T .
4
A hammer-on is a special guitar playing technique where a left-hand finger is ‘hammered’ on the
fretboard, causing the note of that string and fret to sound without the string being plucked with the
right hand. A hammer-on is denoted on tablature by an arc with the letter ‘H’ above
5
A pull-off is a special guitar playing technique where a left-hand finger is pulled off a position on
the fretboard, causing a lower fret that is being pressed down with another finger to sound without the
string being plucked with the right hand. A pull-off is denoted on tablature by an arc with the letter
‘P’ above
6
A slide is a special guitar playing technique where a string is plucked by a right-handed finger and
subsequently the left-hand finger on this string slides (up- or downwards) to a different fret. A slide is
typically denoted on tablature by a slash (‘/‘) symbol for upward slides and a backslash (‘\‘) symbol for
downward slides
14 CHAPTER 3. PROBLEM DESCRIPTION

• µs, s0 , f, t is a binary variable which is one iff finger f ∈ F moves from string s to
string s0 ∈ S from timestamp t − 1 to t ∈ T \ {1}.

• wg, t is a binary variable which is one iff at timestamp t ∈ T the wrist position is
at fret g ∈ G 0 .

• Wg, g0, t is a binary variable which is one iff the wrist moves from fret g to g 0 ∈ G 0
from timestamp t − 1 to t ∈ T \ {1}.

Constants

• Ip, s is a binary constant which is one iff fretboard position p ∈ P is located on


string s ∈ S.

• Ip, g is a binary constant which is one iff fretboard position p ∈ P is located on fret
g ∈ G.

Parameters

• ag, g0 , f, f 0 is the cost of using both fingers f and f 0 ∈ F simultaneously on respec-


tively frets g and g 0 ∈ G. Three instances exist: (i) the distance between fingers
f and f 0 is comfortable: no cost is imposed; (ii) the distance between fingers f
and f 0 is uncomfortable but playable: a cost is imposed; (iii) the distance between
fingers f and f 0 is impossible to play: a high cost is imposed to prevent the model
from selecting this finger assignment.

• b is the cost of using the pinky finger. This cost is independent of time, fret or
string.

• cg, g0 is the cost of moving the wrist from position g to position g 0 ∈ G. Shorter
movements should have a lower cost, longer movements should have a higher cost.

• ds, s0 is the cost of moving a finger from string s to s0 ∈ S.


3.1. MODEL 1: SCALE-BASED GUITAR MUSIC 15

Integer programming model


X X X X
min ag, g0 , f, f 0 ∆g, g0 , f, f 0 , t + b Ft,p,4 + cg, g0 Wg, g0, t + ds, s0 µs, s0 , f, t
g, g 0 ∈G t∈T g, g 0 ∈G 0 s, s0 ∈S
f,f 0 ∈F :f 6=f 0 p∈Pt t∈T \{1} f ∈F
t∈T t∈T \{1}
(3.1)
X
Ft,p,f = 1 ∀t ∈ T , p ∈ Pt (3.2)
f ∈F
X
Ft,p,f ≤ 1 ∀f ∈ F, t ∈ T (3.3)
p∈Pt
X
St,s,f = Ip, s Ft,p,f ∀f ∈ F, t ∈ T , s ∈ S (3.4)
p∈Pt
X
Gt,g,f = Ip, g Ft,p,f ∀f ∈ F, t ∈ T , g ∈ G (3.5)
p∈Pt

Gt,g,f + Gt,g0 ,f 0 − 1 ≤ ∆g, g0 , f, f 0 , t ∀t ∈ T , g, g 0 ∈ G, f, f 0 ∈ F : f 6= f 0 (3.6)


0
St−1,s,f + St,s0 ,f − 1 ≤ µs, s0 , f, t ∀s, s ∈ S, f ∈ F, t ∈ T \ {1} (3.7)
0
µs, s0 , f, t ≤ St−1,s,f ∀s, s ∈ S, f ∈ F, t ∈ T \ {1} (3.8)
0
µ s, s0 , f, t ≤S t,s0 ,f ∀s, s ∈ S, f ∈ F, t ∈ T \ {1} (3.9)
X
wg,t = 1 ∀t ∈ T (3.10)
g∈G 0

wg,t ≥ Gt,g,1 ∀t ∈ T , g ∈ G (3.11)


X
wg−1,t + Gt,g0 ,1 ≥ Gt,g,2 ∀t ∈ T , g ∈ G (3.12)
g 0 ∈G
X
wg−2,t + Gt,g0 ,f ≥ Gt,g,3 ∀t ∈ T , g ∈ G (3.13)
g 0 ∈G,f ∈{1,2}
X
wg−3,t + Gt,g0 ,f ≥ Gt,g,4 ∀t ∈ T , g ∈ G (3.14)
g 0 ∈G,f ∈{1,2,3}

wg,t−1 + wg0 ,t − 1 ≤ Wg,g0,t ∀g, g 0 ∈ G 0 , ∀t ∈ T \ {1} (3.15)


X X
0 0
f × Ft,p,f ≤ f × Ft,p0 ,f ∀t ∈ T , p, p ∈ P, k ∈ {1, .., 5} : p = p + nk (3.16)
f ∈F f ∈F

Ft,p,f + Ft+1,q,f ≤ 1 ∀(t, p) ∈ Th ∪ Tp , q ∈ Pt+1 , f ∈ F (3.17)


X X
f × Ft,p,f ≤ f × Ft+1,q,f ∀(t, p) ∈ Th , q ∈ Pt+1 (3.18)
f ∈F f ∈F
X X
f × Ft,p,f ≥ f × Ft+1,q,f ∀(t, p) ∈ Tp , q ∈ Pt+1 (3.19)
f ∈F f ∈F

St,s,f = St+1,s,f ∀(t, s) ∈ Ts , f ∈ F (3.20)


Ft,p,f , St,s,f , Gt,g,f ∈ {0, 1} ∀t ∈ T , p ∈ Pt , f ∈ F, s ∈ S, g ∈ G (3.21)
0 0
wg,t ∈ {0, 1} ∀g, g ∈ G , t ∈ T (3.22)
Wg,g0,t , µs, s0 , f, t ∈ {0, 1} ∀g, g 0 ∈ G 0 , s, s0 ∈ S, f ∈ F, t ∈ T \ {1} (3.23)
0 0 0 0
∆g, g0 , f, f 0 , t ∈ R≥0 ∀g, g ∈ G , f, f ∈ F : f 6= f , t ∈ T (3.24)
16 CHAPTER 3. PROBLEM DESCRIPTION

The objective function, Equation 3.1, minimizes the cost due to difficult inter-finger
distances, the use of the pinky finger, wrist movement and movement across strings.
Constraints 3.2 make sure that all positions p ∈ Pt are actually played, i.e. are assigned
a finger, while constraints 3.3 ensure that at all timestamps, one finger can only play
one position. Constraints 3.4 and 3.5 translate the position identifiers to respectively the
strings and the frets that are being played by a specific finger. Constraints 3.6 activate
the inter-finger distance variables when appropriate: if two fingers are used in the same
timestamp. Note that this is done for all possible pairs of fingers 42 = 6. Also note that
the ∆ variables, while not restricted to be binary, will only take values 0 or 1 due to the
minimization of the objective function and the nature of these constraints. Similarly,
constraints 3.7 activate the inter-string distance variables µ when a finger moves from
one string to the other. Constraints 3.8 and 3.9 are necessary in case the parameters
include a profit (i.e. a negative cost) - for example to reward fingers for staying on the
same string - since these constraints prevent the µ variables from taking value 1 unless
the concerned finger effectively travels from string s to string s0 .

Constraints 3.10 ensure that a wrist position is determined at all times. Constraints 3.11-
3.14 take care of setting this wrist position as follows: if the index finger is active , then
constraints 3.11 set the wrist position to the index position. In this case, the summation
of the G variables in constraints 3.12-3.14 makes these constraints non-binding for the w
variables. If, however, the index finger is not active at timestamp t, constraints 3.12-3.14
implement the assumption that non-active fingers are on consecutive frets with active
fingers and thus determine the position of the index finger and by extension the wrist
position: if the middle finger is active, constraints 3.12 set the wrist position one fret
lower than the fret the middle finger is on. If the middle finger is not active, we look at
the ring finger using constraints 3.13 and finally at the pinky finger with constraints 3.14.
Constraints 3.15 then take care of the wrist movement.

Constraints 3.16 eliminate awkward hand positions by forbidding a finger to be on a


physically lower (thinner) string in the same fret as a higher numbered finger. Con-
straints 3.17-3.20, in turn, take care of the special techniques as follows: first, con-
straints 3.17 prevent the finger that starts a hammer-on or pull-off to be used during the
following timestamp. Second, constraints 3.18 state that a hammer-on should start with
a lower numbered finger than the one it ends with (e.g. starting with your index finger
and ending with your ring finger is allowed, but the opposite is not), and constraints 3.19
state the opposite for pull-offs. Lastly, constraints 3.20 make sure the same finger is used
for the starting and the ending position of a slide.

Constraints 3.21-3.23 restrict the F , S, G, w, W and µ variables to be binary, and


constraints 3.24 restrict the ∆ variables to positive real numbers.
3.2. MODEL 2: CHORD-BASED GUITAR MUSIC 17

3.2 Model 2: Chord-based guitar music


In this model for chord-based guitar pieces, the composition of the objective function re-
mains the same, as again depicted in Figure 3.3. The static components remain identical,

Figure 3.3: The different components of the objective function.

but the transition components are determined differently, since in chord-based music one
typically keeps the same finger position throughout multiple timestamps, thus affecting
transitions.

Wrist movement The consecutive fret assumption is typically too restrictive for
chord-based pieces. As an example, consider the small part of Eric Clapton’s Tears
in Heaven depicted in Figure 3.4.

Figure 3.4: Why the consecutive fret assumption is too restrictive for chord-based guitar
pieces: an excerpt from Tears in Heaven.

In this case, the guitarist would keep on pressing down the second fret on the E-string
with his index finger, the second fret on the G-string with his middle finger and the third
fret of the B-string with his ring finger during the first four timestamps, even when the
string does not need to be played. Consider now using the consecutive fret assumption
here: for the first two timestamps, the index finger is used and thus determines the wrist
18 CHAPTER 3. PROBLEM DESCRIPTION

position to be on fret 2. When we move to the third timestamp, however, the index fin-
ger is not used and, in that case, the middle finger determines the wrist position. When
assuming fingers to be on consecutive frets, the index finger is assumed to be on fret
1 and thus the theoretical wrist position changes, even though the guitarist keeps the
exact same form as before. This illustrates the need for a less restrictive determination
of the wrist position.

In this second model, we let the model determine the wrist position endogenously by
requiring the index finger to be assigned to a fret at all times, even when it is not ac-
tually playing a position on the fretboard. The wrist position is then set equal to the
position of the index finger. The determination of this ‘floating’ index finger is subject
to the inter-finger distances, just like the determination of the index finger is subject to
them for positions p ∈ Pt that actually need to be played.

Movement across strings Due to the fact that a player would keep its fingers in
position for a longer time (playing a ‘chord’ with repeated notes), the horizon for the
movement across strings is extended from t+1 to t+2.

3.2.1 Mathematical Model


The whole chord-based model is given below, and the differences with the scale-based
model are explicitly highlighted at the end of this chapter.

Sets

• T is the set of timestamps, i.e. the set of all points in time during which a note is
played.

• S = {E, A, D, G, B, e} is the set of strings.

• F = {1, 2, 3, 4} is the set of fingers available to play the guitar.

• G = {1, .., n} for a guitar with n frets is the set of frets.

• P = S × G is the set of unique fretboard position identifiers.

• Pt denotes the set of fretboard positions to be played at timestamp t, based on the


tablature of the concerned song.

• Th denotes the set of (t, p)-vectors that give the timestamp t ∈ T when, and
position p ∈ Pt where, a hammer-on starts, based on the tablature of the concerned
song.

• Tp denotes the set of (t, p)-vectors that give the timestamp t ∈ T when, and
position p ∈ Pt where, a pull-off starts, based on the tablature of the concerned
song.
3.2. MODEL 2: CHORD-BASED GUITAR MUSIC 19

• Ts denotes the set of (t, s)-vectors that give the timestamp t ∈ T when, and string
s ∈ S on which, a slide starts, based on the tablature of the concerned song.

Decision variables
• Ft, p, f is a binary variable which is one iff at timestamp t ∈ T , position p ∈ P is
pressed by finger f ∈ F.

• St, s, f is a binary variable which is one iff at timestamp t ∈ T , string s ∈ S is


pressed by finger f ∈ F.

• Gt, g, f is a binary variable which is one iff at timestamp t ∈ T , fret g ∈ G is pressed


by finger f ∈ F.

• ∆g, g0 , f, f 0 , t is a binary variable which is one iff distinct fingers f and f 0 ∈ F are
both used on respectively frets g and g 0 ∈ G at time t ∈ T .

• µhs, s0 , f, t is a binary variable which is one iff finger f ∈ F moves from string s to
string s0 ∈ S from timestamp t − h to t ∈ T \ {1, .., h} with h ∈ {1, 2}.

• Wg, g0, t is a binary variable which is one iff the wrist moves from fret g to g 0 ∈ G
from timestamp t − 1 to t ∈ T \ {1}.

Constants
• Ip, s is a binary constant which is one iff fretboard position p ∈ P is located on
string s ∈ S.

• Ip, g is a binary constant which is one iff fretboard position p ∈ P is located on fret
g ∈ G.

Parameters
• ag, g0 , f, f 0 is the cost of using both fingers f and f 0 ∈ F simultaneously on frets
g and g 0 ∈ G respectively. Three instances exist: (i) the distance between fingers
f and f 0 is comfortable: no cost is imposed; (ii) the distance between fingers f
and f 0 is uncomfortable but playable: a cost is imposed; (iii) the distance between
fingers f and f 0 is impossible to play: a high cost is imposed to prevent the model
from selecting this finger assignment.

• b is the cost of using the pinky finger. This cost is independent of time, fret or
string.

• cg, g0 is the cost of moving the wrist from position g to position g 0 ∈ G. Shorter
movements should have a lower cost, longer movements should have a higher cost.

• dhs, s0 is the cost of moving a finger from string s to s0 ∈ S for a horizon of h ∈ {1, 2}.
20 CHAPTER 3. PROBLEM DESCRIPTION

Integer programming model


X X X X
min ag, g0 , f, f 0 ∆g, g0 , f, f 0 , t +b Ft,p,4 + cg, g0 Wg, g0, t + dhs, s0 µhs, s0 , f, t
0 t∈T 0 0
g, g ∈G g, g ∈G s, s ∈S
f,f 0 ∈F :f 6=f 0 p∈Pt t∈T \{1} f ∈F
t∈T h∈{1,2}
t∈T \{1,..,h}
(3.25)
X
Ft,p,f = 1 ∀t ∈ T , p ∈ Pt (3.26)
f ∈F
X
Ft,p,f ≤ 1 ∀f ∈ F, t ∈ T (3.27)
p∈Pt
X
St,s,f = Ip, s Ft,p,f ∀f ∈ F, t ∈ T , s ∈ S (3.28)
p∈Pt
X
Gt,g,f = Ip, g Ft,p,f ∀f ∈ F, t ∈ T , g ∈ G (3.29)
p∈P

Gt,g,f + Gt,g0 ,f 0 − 1 ≤ ∆g, g0 , f, f 0 , t ∀t ∈ T , g, g 0 ∈ G, f, f 0 ∈ F : f 6= f 0 (3.30)


0
St−h,s,f + St,s0 ,f − 1 ≤ µhs, s0 , f, t ∀s, s ∈ S, f ∈ F, h ∈ {1, 2}, t ∈ T \ {1, .., h} (3.31)
0
µhs, s0 , f, t ≤ St−h,s,f ∀s, s ∈ S, f ∈ F, h ∈ {1, 2}, t ∈ T \ {1, .., h} (3.32)
0
µhs, s0 , f, t ≤ St,s0 ,f ∀s, s ∈ S, f ∈ F, h ∈ {1, 2}, t ∈ T \ {1, .., h} (3.33)
X
Gt,g,1 = 1 ∀t ∈ T (3.34)
g∈G

Gt−1,g,1 + Gt,g0 ,1 − 1 ≤ Wg,g0,t ∀g, g 0 ∈ G 0 , ∀t ∈ T \ {1} (3.35)


X X
0 0
f × Ft,p,f ≤ f × Ft,p0 ,f ∀t ∈ T , p, p ∈ P, k ∈ {1, .., 5} : p = p + nk (3.36)
f ∈F f ∈F

Ft,p,f + Ft+1,q,f ≤ 1 ∀(t, p) ∈ Th ∪ Tp , q ∈ Pt+1 , f ∈ F (3.37)


X X
f × Ft,p,f ≤ f × Ft+1,q,f ∀(t, p) ∈ Th , q ∈ Pt+1 (3.38)
f ∈F f ∈F
X X
f × Ft,p,f ≥ f × Ft+1,q,f ∀(t, p) ∈ Tp , q ∈ Pt+1 (3.39)
f ∈F f ∈F

St,s,f = St+1,s,f ∀(t, s) ∈ Ts , f ∈ F (3.40)


0
Ft,p,f , St,s,f , Gt,g,f , Wg,g0,t ∈ {0, 1} ∀t ∈ T , p ∈ P, f ∈ F, s ∈ S, g, g ∈ G (3.41)
0
µhs, s0 , f, t ∈ {0, 1} ∀h ∈ {1, 2}, s, s ∈ S, f ∈ F, t ∈ T \ {1, .., h} (3.42)
0 0 0
∆g, g0 , f, f 0 , t ∈ R≥0 ∀g, g ∈ G, f, f ∈ F : f 6= f , t ∈ T (3.43)

Compared to the scale-based model, the wg,t variables disappear, together with their
accompanying constraints 3.11-3.14. Constraints 3.10 are replaced by constraints 3.34,
requiring the index finger to be assigned to a fret at all times. To make this possibe, the
Ft,p,1 variables now need to be defined for all p ∈ P and not just p ∈ Pt (3.41), which
is also reflected in the determination of the G variables in constraints 3.29. The wrist
movement is now directly determined through the Gt,g,1 variables in constraints 3.35.

In addition, the µs,s0 ,f,t variables are replaced by µhs,s0 ,f,t variables, indicating the horizon
3.2. MODEL 2: CHORD-BASED GUITAR MUSIC 21

of the movement across strings, just like the dhs, s0 parameters that determine their cost.
The relevant constraints 3.31-3.33 are likewise updated.
22 CHAPTER 3. PROBLEM DESCRIPTION
Chapter 4

Implementation and Results

We implement the model in IBM ILOG CPLEX Optimization Studio 12.7.1.0. The
parameters were determined as follows:
• The ag,g0 ,f,f 0 parameters are determined based on matrices that indicate the min-
imum and maximum comfortable and absolute distances between fingers. These
distances are expressed in centimeters, to account for the different widths frets
have. Note that these comfortable and absolute distances are personal and should
be tailored to the guitarist. Inter-finger distances that fall below or exceed the
comfortable distances are penalized with a cost of 5 while those that fall below
or exceed the absolute distances are penalized with a cost of 100. We use a semi-
acoustic guitar (LAG Tramontane T222DCE) with 20 frets to map the distances
to frets.

• The b parameter for penalizing the use of the pinky is set to 0.25

• The cg,g0 parameters are set to 1 for a wrist movement of 1 fret, 2 for a movement
of 2 frets and 3 for all larger movements. Again, a guitar of 20 frets is assumed.

• The d1s,s0 parameters are set to the distance between the two concerned strings.
For example, a movement from the first to the third string equals a cost of 2.
When, however, a finger stays on the same string, a profit of 1 (i.e. a cost of -1) is
assigned.

• The d2s,s0 parameters are set to 0.5 for a movement of one string, and 1 for all larger
movements (2 to 5 strings). When, however, a finger stays on the same string, a
profit of 0.5 (i.e. a cost of -0.5) is assigned.
In order to avoid the long manual work of converting the tablature to useable CPLEX
inputs, i.e. an array of sets of position identifiers and frets that are used at each times-
tamp, we created a small Python preprocessing program that parses Guitar Pro tabs
and produces the required format for CPLEX. In addition, we developed another Python
postprocessing program to process the output of CPLEX back into a Guitar Pro file and
automatically print the left-hand finger assignment on the tablature. These programs

23
24 CHAPTER 4. IMPLEMENTATION AND RESULTS

were written using PyGuitarPro [8], a freeware python package, and can be found in the
Appendix. This way, one can download any Guitar Pro Tab from the internet, quickly
parse it to useable CPLEX inputs, solve the model, and parse it again to a Guitar Pro
file with the finger assignment below the tablature.

We selected a sample of nine songs in different genres, to test the performance of the
model. Four songs were directly ruled out as the Python preprocessing program flagged
they included barre chords. Table 4.1 gives the different songs, the number of times-
tamps the guitar track includes and whether or not they include barre chords.

Barre
Artist Song # Timestamps Chords?
Kansas Dust In The Wind 1079 N
Eric Clapton Tears in Heaven 675 N
Eric Clapton Layla 575 Y
The Beatles Blackbird 489 N
Led Zeppelin Stairway To Heaven 1140 Y
Santana Samba Pa Ti (Intro) 230 N
Chuck Berry Johnny B Goode (Intro) 215 N
Jimi Hendrix Purple Haze 726 Y
John Williams Cavatina (Theme 399 Y
from The Deer Hunter)

Table 4.1: The list of songs that were parsed through the Python implementation

The instances that do not include barre chords were run in CPLEX on a laptop with an
Intel(R) Core(TM) i5-2430M CPU @ 2.40Ghz (4 CPUs) processor with a RAM memory
of 6144MB, running on Windows 10.

Total Root + Branch & Cut Time (Seconds)


Song Type Model 1: Scale-Based Model 2: Chord-Based
Dust In The Wind Chord-based 711 125
Tears in Heaven Chord-based 50 40
Blackbird Chord-based 229 124
Samba Pa Ti Scale-based 39 333
Johnny B Goode Scale-based 166 201*

Table 4.2: The results of the experiments: for each instance, the type of the song is
given and the solving time for both models. An asterisk (*) indicates that the instance
was stopped at a 2% optimality gap because it could not be solved to optimality within
30 minutes.

The results are given in table 4.2. For each song, the assumed ‘type’ is given, together
with the solving time (Total Root + Branch & Cut Time) in both models. As can be
25

seen from the table, the chord-based songs are solved significantly faster in the chord-
based model, and vice versa for the scale-based songs. Chuck Berry’s Johnny B Goode
can even not be solved to optimality in the chord-based model within 30 minutes, but
solves relatively fast in the scale-based model.

Concerning the quality of the outputs of the model, it is not possible to give one ob-
jective metric. This is due to the fact that, as expressed in the introduction, there is
no such thing as THE optimal finger assignment. For example, how Paul McCartney
plays Blackbird might not be the easiest or preferred way for a beginning guitarist and
even an experienced guitarist might opt for another finger assignment, due to different
preferences. To illustrate, however, the difference in quality of both models for differ-
ent pieces, we will discuss some extracts of the output of the songs in the table above.

Firstly, consider the finger assignment for the first two bars of “Dust in the wind” for
both models in Figure 4.1 on page 26. Note that there are a lot of repeated notes (i.e.
the same fret and string) in this song, which is typical for a chord-based guitar piece.
Consequently, in the chord-based model at the bottom, the first three fingers can stay
on their position during the whole part: the index finger on the first fret of the B-string,
the middle finger on the second fret of the D-string and the ring finger on the third fret
of the A-string. For the first half of the second bar, the guitarist can simply add its
pinky finger on the third fret of the B-string and remove it again for the last part. This
finger assignment requires very little effort. In the scale-based model on top, however, at
the 13th timestamp, the index finger moves to the D-string and all fingers assume a new
position, only to return to their original position at the second half of the last bar. Ev-
idently, this finger assignment requires more effort and the chord-based one is preferred.

Secondly, consider the finger assignment for the first bar of “Blackbird” for both models
in Figure 4.2 on page 26. In the chord-based model at the bottom, the same fingers
stay on the same frets and can effortlessly be slid over the fretboard. In the scale-based
model, the finger used for these two strings constantly switch, increasing the necessary
effort and decreasing the comfort of the guitarist. Again, the chord-based finger assign-
ment is preferred over the scale-based finger assignment.

Lastly, consider the finger assignment for the first bar of “Samba Pa Ti” for both models
in Figure 4.3 on page 27. Notice the lack of repeated notes, typical for scale-based guitar
pieces. In the scale-based model on top, the fingers can stay in the same fret during the
whole bar, and the wrist does not need to move. In the chord-based model, however,
the pinky finger jumps around from fret to fret, requiring the wrist to constantly move
around. Evidently, the scale-based finger assignment is preferred for this song.
26 CHAPTER 4. IMPLEMENTATION AND RESULTS

1 Model 1: Scale-based

2 Model 2: Chord-based

Figure 4.1: The finger assignment for the first two bars of Kansas’ “Dust in the wind”
for both models.

1 Model 1: Scale-based

2 Model 2: Chord-based

Figure 4.2: The finger assignment for the first two bars of The Beatles’ “Blackbird” for
both models.
27

1 Model 1: Scale-based

2 Model 2: Chord-based

Figure 4.3: The finger assignment for the first two bars of Santana’s “Samba Pa Ti” for
both models.

Based on the descriptive examples above, it can be seen that the scale-based model
is preferred for scale-based songs and the chord-based model for chord-based songs.

In the existing literature on automatic transcription and fingering decisions discussed in


Chapter 2, Hori et al. [6] and Miura and Yanagida [5] use the consecutive fret assumption
while Yazawa et al. [4] enumerate fingering configurations through a guitar chord book,
thus focusing on chords. The results in this thesis point out that the area of applicabil-
ity of their work potentially could be expanded or the quality of their results improved
through explicitly modeling the distinction between chord-based and scale-based songs.

The remaining question is: how to discern scale-based from chord-based pieces? While
this is relatively easy for the human eye or ear, it is less evident to explain this to a
computer program. Typically, scale-based pieces have mostly single notes per timestamp
(monophony), have limited repeated notes, and the movements across the fretboard tend
to be larger than in chord-based pieces. In addition, these songs typically contain more
28 CHAPTER 4. IMPLEMENTATION AND RESULTS

special techniques such as hammer-ons, slides, pull-offs and bends. Future work could
focus on finding objective metrics to discern the two different types, even for different
parts within songs.

In addition, another improvement point is a current lack of consistency in repeated


parts: identical parts are sometimes assigned different fingers. This can be explained
through a multitude of equivalent optimal solutions. Table 4.3 gives the size of the so-
lution pool for the instances above.

Solution Pool
Song Model 1: Scale-Based Model 2: Chord-Based
Dust In The Wind 22 19
Tears in Heaven 20 14
Blackbird 20 24
Samba Pa Ti 19 41
Johnny B Goode 25 24*

Table 4.3: The solution pool of the instances solved. An asterisk (*) indicates that the
instance was stopped at a 2% optimality gap because it could not be solved to optimality
within 30 minutes.

This solution pool could be reduced by introducing additional rules for ordering so-
lutions in terms of preference. For example, a rule could be “in case of equivalence, a
lower numbered finger should be preferred over a higher numbered finger”. Moreover,
adding these rules could potentially reduce processing time.
Chapter 5

Conclusion

A tool for automatic finger assignment can bring significant advantages for beginning
guitarists. In this thesis, two user-specific models to assign fingers for tablature were
developed and implemented in CPLEX. Moreover, a Python program was developed to
parse Guitar Pro tablatures (which can be found on the world wide web for the majority
of existing songs), produce the necessary inputs for CPLEX and, after solving, output
it back into Guitar Pro tablature, this time including the finger assignment.

In this thesis, we discovered an important distinction in model composition for two


different types of guitar pieces, with an impact on both processing time and the quality
of the resulting finger assignment. The existing literature on automatic transcription
and translation of staff notation into tablature implicitly focuses on either one of these
types but not on both. Therefore, including this distinction could potentially improve
the quality of the models suggested as well as expand their applicability.

Potential future work includes three key focal areas: first, refining the distinction be-
tween the two different types of songs and finding objective metrics to differentiate
between them, even for different parts within songs; second, expanding the model to
include barre chords; and lastly, reducing the solution pool through additional rules to
improve the quality and potentially decrease processing time for finding solutions.

29
30 CHAPTER 5. CONCLUSION
Bibliography

[1] Mikkel Winther Jensen. Layla acoustic (ver 2) guitar pro. https://tabs.ultimate-
guitar.com/e/eric clapton/layla acoustic ver2 guitar pro.htm, 2006. Accessed: 2017-
05-03.

[2] D.R. Tuohy and W.D. Potter. A genetic algorithm for the automatic generation of
playable guitar tablature. Proceedings of the International Computer Music Confer-
ence, 2005.

[3] Aleksander Radisavljevic and Peter Driesen. Path difference learning for guitar fin-
gering problem. Proceedings of the International Conference on Music Perception
and Cognition, 2004.

[4] Kazuki Yazawa, Katsutoshi Itoyama, and Hiroshi G. Okuno. Automatic transcrip-
tion of guitar tablature from audio signals in accordance with player’s proficiency.
Proceedings of the IEEE International Conference on Acoustic, Speech and Signal
Processing (ICASSP), 2014.

[5] Masanobu Miura and Masuzo Yanagida. Finger-position determination and tablature
generation for novice guitar players. Proceedings of the 7th International Conference
on Music Perception and Cognition, 2002.

[6] Gen Hori, Hirokazu Kameoka, and Shigeki Sagayama. Input-output HMM applied
to automatic arrengement for guitars. Journal of Information Processing Vol. 21 No.
2, 2013.

[7] Matteo Balliauw, Dorien Herremans, Daniel Palhazi Cuervo, and Kenneth Sorensen.
A variable neighborhood search algorithm to generate piano fingerings for polyphonic
sheet music. International Transactions in Operational Research, 2015.

[8] Sviatoslav Abakumov. Pyguitarpro. https://pypi.python.org/pypi/PyGuitarPro,


2014.

31
32 BIBLIOGRAPHY
Appendix A

A.1 Python Programs


On the next pages, the Python programs that were written for this thesis can be found:
first, the preprocessing program that parses Guitar Pro tabs and produces the required
format for the CPLEX inputs; second, the postprocessing program that processes the
output of CPLEX back into a Guitar Pro file and automatically prints the left-hand
finger assignment on the tablature.

33
1 import sys
2 import guitarpro
3 from os import path
4
5 gp5_version=(5,1,0)
6
7 MAPPING = {
8 1: 100,
9 2: 80,
10 3: 60,
11 4: 40,
12 5: 20,
13 6: 0
14 }
15
16 def main(tab_file):
17
18 song = guitarpro.parse(tab_file)
19
20 if song.versionTuple[0]==3: # fingering not possible on gp3-files with this
version of pyguitarpro; therefore first converting to gp5
21 dest = '%s-conv.gp5' % path.splitext(tab_file)[0]
22 guitarpro.write(song, dest,gp5_version)
23 print("GP3 input file converted to GP5-format : " + dest)
24 print("")
25 song = guitarpro.parse(dest)
26
27 print(song.title + " - " + song.artist)
28
29 for track_nr, track in enumerate(song.tracks, start=1):
30 print("track " + str(track_nr) + " = " + track.name)
31 if track.isPercussionTrack:
32 print("Percussion ==> skipping")
33 break
34 if track.is12StringedGuitarTrack:
35 print("12 string ==> skipping")
36 break
37 if track.isBanjoTrack:
38 print("Banjo ==> skipping")
39 break
40 time_cnt=0
41 notes_not_0=0
42 outstr=""
43 outstr_real=""
44 barrestr=""
45 for measure_nr, measure in enumerate(track.measures, start=1):
46 for voice_nr, voice in enumerate(measure.voices, start=1):
47 for beat_nr, beat in enumerate(voice.beats, start=1):
48 tmpstr=""
49 tmpstr_real=""
50 isfirst=1
51 note_cnt=0
52 for note_nr, note in enumerate(beat.notes, start=1):
53 if note.value > 0 and note.type.name != "tie": # open
string and tie notes will not be outputted
54 if isfirst:
55 isfirst=0
56 tmpstr=tmpstr+str(MAPPING[note.string] + note.value)
57 tmpstr_real=tmpstr_real+str(note.value)
58 else:
59 tmpstr=tmpstr+","+str(MAPPING[note.string] +
note.value)
60 tmpstr_real=tmpstr_real+","+str(note.value)
61 notes_not_0=1
62 note_cnt=note_cnt+1
63 if outstr=="":
64 outstr="{"+tmpstr+"}"
65 outstr_real="{"+tmpstr_real+"}"
66 else:
67 outstr=outstr+",{"+tmpstr+"}"
68 outstr_real=outstr_real+",{"+tmpstr_real+"}"
69 time_cnt=time_cnt+1
70 if note_cnt > 4: # more than 4 notes in a one timestamp, must
be a barre
71 if barrestr=="":
72 barrestr="{"+tmpstr+"}"
73 else:
74 barrestr=barrestr+",{"+tmpstr+"}"
75 if notes_not_0:
76 print(outstr)
77 print("times = " + str(time_cnt))
78 if barrestr != "":
79 print("ATTENTION - This track contains barre chords: " + barrestr)
80 print("\nOutput with just fret values:")
81 print(outstr_real)
82 else:
83 print("No playable notes in this track")
84 print("")
85
86 if __name__ == '__main__':
87 import argparse
88
89 parser = argparse.ArgumentParser(description="Preprocessor for adding left-hand
fingering positions into a Guitar Pro tablature. Output is written to standard
output")
90 parser.add_argument("tab_file",help="path to the Guitar Pro tablature file")
91 args = parser.parse_args()
92 kwargs = dict(args._get_kwargs())
93 main(**kwargs)
1 import sys
2 import guitarpro
3 from os import path
4 import re
5
6 gp5_version=(5,1,0)
7
8 MAPPING = {
9 1: 100,
10 2: 80,
11 3: 60,
12 4: 40,
13 5: 20,
14 6: 0
15 }
16
17 FINGERMAPPING = {
18 1: guitarpro.models.Fingering.index,
19 2: guitarpro.models.Fingering.middle,
20 3: guitarpro.models.Fingering.annular,
21 4: guitarpro.models.Fingering.little,
22 }
23
24 def main(tab_file, track_num, finger_file):
25
26 song = guitarpro.parse(tab_file)
27 print(song.title + " - " + song.artist)
28
29 if song.versionTuple[0]==3:
30 print("GP3 tab-file not allowing finger positions! Quiting...")
31 exit()
32
33 dest_file = '%s-LHF.gp5' % path.splitext(tab_file)[0] # we will always write in
GP5-format
34
35 list_of_fingerings = list()
36 ff=open(finger_file)
37 line=ff.readline()
38 cline=re.sub("\}\,","}|",line).strip() # this can be removed if the |-delimiter
is used in the inputfile
39 list_of_fingerings=cline.split("|")
40
41 track = song.tracks[track_num - 1]
42 print("track " + str(track_num) + " = " + track.name)
43 if track.isPercussionTrack or track.is12StringedGuitarTrack or track.isBanjoTrack:
44 print("Invalid track")
45 exit()
46
47 time_cnt=0
48 notes_not_0=0
49 outstr=""
50
51 for measure_nr, measure in enumerate(track.measures, start=1):
52 for voice_nr, voice in enumerate(measure.voices, start=1):
53 for beat_nr, beat in enumerate(voice.beats, start=1):
54 tmpstr=""
55 isfirst=1
56 fingerpos=list_of_fingerings[time_cnt]
57 if fingerpos=="{}": # no finger positions on this timestamp
58 time_cnt=time_cnt+1
59 else:
60 fingerpos=fingerpos.strip("{}")
61 list_of_pos=[int(x) for x in fingerpos.split(",")]
62 fnr=0
63 for note_nr, note in enumerate(beat.notes, start=1):
64 if note.value > 0 and note.type.name != "tie": # open
string and tie notes have been ignored
65 notes_not_0=1
66 note.effect.leftHandFinger=FINGERMAPPING[list_of_pos[fnr]]
67 fnr=fnr+1
68 time_cnt=time_cnt+1
69 if notes_not_0:
70 guitarpro.write(song, dest_file ,gp5_version)
71 print("%s has been created with left-hand fingering added" % dest_file)
72
73 if __name__ == '__main__':
74 import argparse
75
76 parser = argparse.ArgumentParser(description="Merge left-hand fingering
positions into a Guitar Pro tablature")
77 parser.add_argument("tab_file",
78 help="path to the Guitar Pro tablature file")
79 parser.add_argument("track_num",
80 type=int,
81 help="number of the track that will get the left-hand
fingering")
82 parser.add_argument("finger_file",
83 help="path to the file that has the fingering")
84 args = parser.parse_args()
85 kwargs = dict(args._get_kwargs())
86 main(**kwargs)

You might also like