Compute Spittah

An Interactive Songwriting Tool by Brendan Larkin



Brendan Larkin | December 11, 2019
Music 256A / CS476a, Stanford University Fall 2019

Sceenshots





Demo

Compute Spittah Demo.mov



Design

Compute Spittah is a friendly interactive songwriting partner who draws his inspiration from the great Mute Spittah as seen here:

Compute Spittah is designed to aid the lyrics to rhythm process when writing a song. The user has complete control over the text and rhythm when they want, but Compute Spittah helps out by generating new rhythmic ideas and spitting them back to you in rhythm.

 

Interface

 

 The user inputs one line of lyrics at a time, and a rhythm is generated probabilistically based on the number of syllables in the line and the meter.   

  The user can input a desired tempo (in bpm), which is global, and a desired meter, which is unique to each line of the song, so it can vary from line to line. Each line spans one bar or measure musically.

The user can also modify the generated rhythm by horizontally dragging the stars, which represent the placement of each syllable in time. Downbeats are indicated with blue stars, and upbeats are indicated by red stars for convenience.

Meter Specification

Meter is specified by 2 values:

1.     Beats — the number of beats per bar

2.    Ticks — the number of subdivisions of each beat

 

Rhythm Generation

A rhythm is generated on line insertion or when the “Generate Rhythm” button is pressed. This is done by counting the number of syllables in the line, and then choosing placements for each syllable from the possible choices determined by the meter. Each syllable will be associated with an index from 0 to Beats*Ticks -1 inclusive.

 

The rhythm is chosen probabilistically based on the meter, so that downbeats are more likely to be chosen than off-beat sixteenth-notes, for example. Specifically, we calculate downbeats based on Beats and upbeats based on Ticks/2. Downbeats are 4x more likely than others, and upbeats are 2x more likely than others.

 

For example, if Beats=4 and Ticks=4, the probability mass function for each choice from [0..15] is

[0.125, 0.03125, 0.0625, 0.03125,

0.125, 0.03125, 0.0625, 0.03125,

0.125, 0.03125, 0.0625, 0.03125,

0.125, 0.03125, 0.0625, 0.03125]

 

If the number of syllables exceeds Beats*Ticks, then no rhythm is assigned to that line.

 

Line Insertion

A new line of text is inserted when the user inputs non-empty text and clicks the “Insert” button. It is always inserted after the currently shown line. If you wish to change the very first line, you can use the “Edit Lyrics” button and then re-insert the old lyrics after it.

 

The user can delete a line of text with the “Delete” button.

 

 

Editing a Line

 

The “Edit Lyrics” button updates the lyrics for the line and generates a new rhythm, since the number of syllables may have changed. This is particularly useful if the syllable counter incorrectly estimates the syllables for one word.

 

When syllable count is wrong

The user can hyphenate the word to explicitly tell the program how many syllables the word has. Exactly where the hyphens are placed does not affect how the word is spoken, as long as the word is broken up into N chunks of letters. For example,

 

1.     The word “bikes” has 1 syllable, but the computer estimates 2, so we can input “bikes-“ to specify that it is 1 syllable.

2.     The word “extraterrestrial” can be specified as “ex-tra-ter-res-tri-al” to indicate that it is 6 syllables.

 

 

Credits

The text to speech in this program is powered by espeak-ng, an open source TTS engine. This must be installed separately on your machine.
See https://github.com/espeak-ng/espeak-ng.

The "syllables" Python package was used to count syllables.
See https://pypi.org/project/syllables/

IronPython allowed me to run Python from C# in Unity.
See https://ironpython.net/download/
See https://mikalikes.men/use-python-with-unity-3d-the-definitive-guide/

Unity Project

Unfortunately, this project depends on an external program called "espeak-ng" being installed, so there is a hard-coded path to it in the code. There may be a way to incorporate it into the Unity build, but I could not muster the strength to fight with path names any longer...



Here are all the files:
Songwriter.zip