“Lisl’s Stis”: Recurrent Neural Networks for Folk Music Generation

Addendum (Sep 3 2018):

If you want to link to our work, please do not link to this page. Link to the folk-rnn project: https://github.com/IraKorshunova/folk-rnn

The following links show how this work has developed.

—-

Inspired by this blog post on recurrent neural networks (RNN), and by the wonder of reproducible research and the exceptional coding of Andrej Karpathy, today I dropped exactly everything I had planned to do and trained RNNs to generate “folk music”.

Here is the first folk piece, which the system names “Lisl’s Stis”:

LislsStis

Perhaps the pickup is more of a grace note, but it is clear that the 9/8 time signature is not correct. The key signature works, and the IV-V-I resolution is good with the octave jump down.
Here is another, named “Quirch cathp’3b (The Nille L’ theys Lags Bollue’s)”

quirch


Now we have a tune in 6/8, but the last measure is missing one eighth note and has an unnecessary natural. As “Lisl’s Stis”, “Quirch” begins and resolves to the tonic specified by the key signature. I like how it fiddles around in either ii or VI before resolving.

These are of course short tunes that I have hand selected from the virually unlimited output from sampling the RNN. Here is an example of what the raw output looks like:

T:Lat canny I. the dlas.
M:C
L:1/8
Q:1/2=100
K:D
A>A|:F>DEA|F2dF|A/F/A/B/ AF|G/E/E FD |DDDG|Edec|defd |eged|fdgd|dcd2||
e|g2ef gef(e/c/)|ddfe fdAA|F3 A c4|efef g{e}d4 |
gfga afgf|eggb ad'eg|fgdB edAB|BedA BABg|fdde ddd:|

T:Eerison Chunby.
M:6/8
L:1/8
Q:3/8=88
K:G
B|GBG B2G|D2B agg|fdd g2g|dcA A3 :|

T:Quirch cathp’3b
T:The Nille L’ theys Lags Bollue’s
M:6/8
L:1/8
Q:3/8=120
K:G
dBd dGG|FAA Bcd|cAd BGG|AGF E2c|B2B cAB|c2d c2A|AAA BcA|=cBG G2:|

This format of music notation is called ABC, and provides an extremely economic and interpretable format of music (monophonic typically, but polyphony is possible too). For instance, here is Volume 1 of “A Selection of Scotch, English, Irish and Foreign Airs adapted to the Fife, Violin, or German-Flute” published by James Aird in 1778. To create the training data for the RNN, I just combined all 1180 tunes in Aird’s six volumes — digitised by the great Jack Campin. I then trained a RNN with my CPU (on my slow MacBook Air) and the default parameters set by Andrej Karpathy:

-rnn_size size of LSTM internal state [100]
-num_layers number of layers in the LSTM [2]
-learning_rate learning rate [0.002]
-decay_rate decay rate for rmsprop [0.95]
-dropout dropout to use just before classifier. 0 = no dropout [0]
-seq_length number of timesteps to unroll for [50]
-batch_size number of sequences to train on in parallel [100]
-max_epochs number of full passes through the training data [30]
-grad_clip clip gradients at [5]
-train_frac fraction of data that goes into train set [0.95]
-val_frac fraction of data that goes into validation set [0.05]
-seed torch manual random number generator seed [123]
-print_every how many steps/minibatches between printing out the loss [1]
-eval_val_every every how many iterations should we evaluate on validation data? [1000]

I sample the trained system using the CPU, some random seed and the default parameters:

-sample 0 to use max at each timestep, 1 to sample at each timestep [1]
-length number of characters to sample [2000]
-temperature temperature of sampling [1]

It is remarkable that the RNN has learned some of the rules of ABC. There are some errors however. For instance, the RNN produces the abc of “Lisl’s Stis” as

T:Lisl's Stis.
M:9/8
L:1/8
Q:3/8=120
K:D
g/|a>f) d2b |gfe dAB |G3 B2c|A2G FAc| d3 D3:|

Running abc2midi, produces the output:

writing MIDI file lislstis1.mid
Warning in line-char 7-13 : Track 0 Bar 1 has 5 units instead of 9
Warning in line-char 7-25 : Track 0 Bar 2 has 6 units instead of 9
Warning in line-char 7-32 : Track 0 Bar 3 has 6 units instead of 9
Warning in line-char 7-40 : Track 0 Bar 4 has 6 units instead of 9
Warning in line-char 7-2 : Track 0 Bar 0 has 13/2 units instead of 9 in repeat
Warning in line-char 7-13 : Track 0 Bar 1 has 5 units instead of 9 in repeat
Warning in line-char 7-25 : Track 0 Bar 2 has 6 units instead of 9 in repeat
Warning in line-char 7-32 : Track 0 Bar 3 has 6 units instead of 9 in repeat
Warning in line-char 7-40 : Track 0 Bar 4 has 6 units instead of 9 in repeat

Clearly, the time signature should not be 9/8, but 6/8. The abc2midi tool gracefully fails, and fills in what was missing. Anyhow, most of the output of the RNN begins with the preface material, and ends with the music. Increasing the temperature beyond 1, or decreasing it below about 0.45 produces a lot of gibberish though.

Here is one piece it generates that is longer than those above, but at a sampling temperature of 0.45. This one I will add to my repertoire immediately:

Drike

It is nice to see it got the pick up and durations correct.

Now I am going to increase the depth of the network, add some drop out, and get out the old squeeze box.


And a head’s up from Sid Sigtia: Modeling and generating sequences of polyphonic music with the RNN-RBM

38 thoughts on ““Lisl’s Stis”: Recurrent Neural Networks for Folk Music Generation

  1. Pingback: “Britich Peppop”: Recurrent Neural Networks for Music Genre Description Generation | High Noon GMT

  2. Pingback: Recurrent Neural Network writes W3C Semantic Web Specification | Danny Ayers' Other Alternate Weblog

  3. Pingback: Composing Music With Recurrent Neural Networks | hexahedria

  4. Pingback: The Infinite Irish Trad Session | High Noon GMT

  5. Pingback: TECNOLOGÍA » Composing Music With Recurrent Neural Networks

  6. Pingback: Composing music with coding - tech24

  7. Pingback: Deep learning for assisting the process of music composition (part 1) | High Noon GMT

  8. Pingback: Find your Dream Job! | Jeremy Karnowski

  9. Pingback: Composing music with coding - Dexterstuff

  10. Pingback: Status on human vs. machines « Finn Årup Nielsen's blog

  11. Pingback: Deep nets generating stuff | A bunch of data

  12. Pingback: Create your own Pokemons! | Melody Wolk

  13. Pingback: The Unreasonable Effectiveness of Recurrent Neural Networks | Open Data Science

  14. Pingback: How to take AI far beyond gaming - XcessPress

  15. Pingback: How to take AI far beyond gaming - LI Tech News

  16. Pingback: How to take AI far beyond gaming – Marketmonitor

  17. Pingback: How to take AI far beyond gaming

  18. Pingback: How to take AI far beyond gaming - Posting 'em

  19. Pingback: How to take AI far beyond gaming - Briefing 'em

  20. Pingback: How to take AI far beyond gaming | VentureBeat | AI - Artificial Intelligence Online

  21. Pingback: How to take AI far beyond gaming

  22. Pingback: How to take AI far beyond gaming - JP Quotes

  23. Pingback: DL 작곡 관련 research – kakalab

  24. Pingback: Composing music with recurrent neural netwroks – kakalab

  25. Pingback: クリエイティブなサービスにAIを活用する方法 - THE BRIDGE(ザ・ブリッジ)

  26. Pingback: クリエイティブなサービスにAIを活用する方法 – THE BRIDGE(ザ・ブリッジ) – THE BRIDGE,Inc. / 株式会社THE BRIDGE (プレスリリース) (登録) (ブログ) – 経営学

  27. Pingback: クリエイティブなサービスにAIを活用する方法 – THE BRIDGE(ザ・ブリッジ) – THE BRIDGE,Inc. / 株式会社THE BRIDGE (プレスリリース) (登録) (ブログ) – 経営.biz

  28. Pingback: クリエイティブなサービスにAIを活用する方法 – THE BRIDGE,Inc. / 株式会社THE BRIDGE (プレスリリース) (登録) (ブログ) – 経営学

  29. Pingback: テキストで音楽を表現する方法を調べた | Futurismo

  30. Pingback: A Rosuflem by Any Other Name | Something of the Marvelous

  31. Pingback: Asking RNNs+LTSMs: What Would Mozart Write? – Wise.io

  32. Pingback: France

  33. Pingback: The Unreasonable Effectiveness of Recurrent Neural Networks – Andrej Karpathy – Deep in Thought

  34. Pingback: リカレントニューラルネットワークの理不尽な効力(翻訳) - YUEDY

  35. Pingback: Composing Music With Recurrent Neural Networks · hexahedria - Actionable Insights

Leave a comment