Using ChatGPT as a Creative Writing Partner — Part 2: Music



Original Source Here

Using ChatGPT as a Creative Writing Partner — Part 2: Music

How the latest language model from OpenAI can help you compose chords for new songs, with music by Band-in-a-Box

“two pianists playing, a person and a friendly robot, digital art,” Midjourney Image by Author

In my previous post, I discussed using ChatGPT, the large language model from OpenAI [1], as a writing partner for various types of prose. In this article, I will show how the system can be used to help compose music by generating chords from text prompts.

After a brief overview of ChatGPT, I will show the results of my experiments in writing music with the new system in the following styles: jazz, country rock, and reggae. I’ll finish by giving my general observations on using the model for composing music with some next steps for future exploration. Note that the third and final installment of this series will be about using the system to create picture books with help from Midjourney.

ChatGPT

ChatGPT is the latest language model from OpenAI that was designed and trained to interact with people via a chat user interface. GTP stands for Generative Pre-trained Transformer, where a transformer is a type of AI model. You can read a complete background on the system in this series’ first article.

OpenAI made ChatGPT available for free here, and there is a waitlist for a pro version here. Once you sign up, you can ask the system any question or tell it to generate something by typing in a prompt and hitting enter. For example, I asked it to create a chord progression for a blues song.

ChatGPT Generated Chords for a Blues Song, Image by Author

The system responded with a series of 12 chords, a typical sequence in blues songs. Next, I wanted to see if ChatGPT could generate a melody to go along with the chords. I prompted the system to write a tune using ABC music notation, representing notes as letters and other metadata as text. Here’s what it composed.

ChatGPT Generated Melody for a Blues Song, Image by Author

OK, that seems to be a lot of notes. But is the melody any good? To play the song, I used a program called EasyABC, an open-source ABC notation editor and player. I pasted the notes into EasyABC and saved the song as a MIDI file. Here’s what the melody sounds like. (Fair warning, it’s not very good.)

Blues Melody by ChatGPT, Video by Author

Yikes! Although the melody is demonstrably bad, the chords are just fine for a blues song. I ran several more experiments with generating chords and melodies using the ChatGPT system. In almost all cases, the generated chords were at least decent and sometimes very good, but the generated melodies were always bad.

I suspect that ChatGPT is good with chords because of the relatively large amount of text on the Internet showing songs with chords and discussions of chord progressions. Conversely, only a few sites show melodies in ABC or any other text-based format. As a result, it generally knows what a melody is and clearly understands the ABC format, but apparently, this is not enough for the system to compose decent melodies.

The remainder of this article recounts my experiments using ChatGPT to compose chord progressions for songs in different musical styles. To create melodies and musical accompaniment, I used the commercial software from PG Music called Band-in-a-Box (BiaB).

For each song, I first interacted with ChatGPT to compose the chords. I then ran BiaB, typed in the generated chords, and chose a style like Texas Blues. BiaB wrote the melodies and backing tracks based on the chords, and I rendered the song as a video. For example, here is the blues song again. (A note to all audiophiles: To hear the bass line, use headphones or external speakers.)

Blues Chords and Melody, by ChatGPT, Video by Author

Ahh! Much better. BiaB uses a dataset of MIDI recordings from real musicians as the basis for putting the song together, so the tunes have a more human feel. It also set the parameters like the instrumentation (drums, bass, and two guitars) and playing groove (swing 8th notes) that were appropriate for the blues-rock style.

Using ChatGPT for Composing Music

Based on my interactions with ChatGPT, it knows quite a bit about music. It knows music theory well, and it knows about various genres and styles. The following sections show how I used the system to create chord progressions for multiple styles of tunes, jazz, polka, and country rock.

a grand piano in a jazz club,” Midjourney Image, Edited by Author

Jazz Music

Here’s how I coaxed ChatGPT into writing the chords for a new jazz tune. I started by getting it to discuss the general framework for a jazz song and then asked it to compose the chord progressions for different song parts. Note that ChatGPT’s responses to my commands are in italics in the following interactions.

Create the framework for a new jazz song.

Sure! Here is a basic framework for a jazz song:

Introduction: This is typically a short section at the beginning of the song where the melody is introduced by a solo instrument, such as the saxophone or trumpet. The rest of the band may join in with simple chordal accompaniment.

Head: The head is the main theme of the song and is typically played by the entire band. This is where the chord progression of the song is introduced. Jazz songs often use complex chord progressions, such as ii-V-I or iii-vi-ii-V.

Solo: After the head is played a few times, one or more musicians will typically take a solo turn, improvising over the chord progression of the song.

Bridge: The bridge is a contrasting section that provides relief from the main theme of the song. It may feature a different chord progression and melody than the head.

Outro: The outro is the closing section of the song and may feature a shortened version of the head or a reprise of the introduction.

This is just a basic outline, and jazz songs can take many different forms. The instruments may enter at different points in the song and the structure can be varied to suit the needs of the musicians and the style of the song.

This seems like a good explanation of the various parts of a jazz tune. Notice how it used Roman numeral analysis (i.e., “ii-V-I”) to describe the chord sequences, which composers often use. I then asked it to write chord progressions for a new song, continuing the chat thread.

What would the chord progressions be for the various parts?

The chord progressions for the various parts of a jazz song will depend on the specific song and the style of jazz being played. Jazz songs often use complex chord progressions that may include multiple chords per measure, and the chords used can vary widely depending on the style of jazz and the preferences of the musicians.

Here are a few examples of common chord progressions that may be used in a jazz song:

Head: ii-V-I: This is a very common chord progression in jazz and is often used to create tension and resolution. It consists of a minor chord (ii), followed by a dominant chord (V), and then a major chord (I). For example, in the key of C, the ii-V-I progression would be Dm7-G7-Cmaj7.

Bridge: iii-vi-ii-V: This chord progression uses a series of minor chords to build tension and then resolves with a dominant chord. In the key of C, the iii-vi-ii-V progression would be Em7-Am7-Dm7-G7.

These are just a few examples, and there are many other chord progressions that may be used in a jazz song. The important thing is to choose chord progressions that support the melody and create the desired mood and atmosphere for the song.

This time it gave me both progressions in the Roman numeral format and specific chords in the key of C major. I got a little kick out of this because I, too, transposed all of the training data for my earlier AI-Tunes project into C maj for simplicity.

For the new jazz tune, I used the suggested Dm7-G7-Cmaj7 progression for the head and solos and the Em7-Am7-Dm7-G7 progression for the bridge. For the intro and outro parts, I just stayed on Cmaj7 for four bars. The only thing left to do was to give the song a name, which I got from ChatGPT.

What’s a good name for this tune?
“A Night at the Speakeasy”

OK. To hear the music, I used the technique described above. I fired up BiaB, pasted in the generated chord sequences, chose a jazz style, and, voilà, it composed a new tune with melodies played on the sax with backing tracks (drums, bass, and piano). And here it is.

“A Night at the Speakeasy,” Chords by ChatGPT, Music by BiaB, Video by Author

Not bad! It’s a little bland, maybe OK to accompany a pleasant ride in an elevator, but it seems to be above average for computer-generated music. This is faint praise, I know, and BiaB did most of the heavy lifting. But ChatGPT’s chord progressions appear to be solid. Note that I intentionally made the tune short (1:10) for demo purposes. An actual jazz song would come back to the head multiple times and have more extended solos with different instruments. Up next is some polka music.

an accordion an empty stage with other instruments,” Midjourney Image, Edited by Author

Polka Music

For my next experiment, I just jumped right in and asked ChatGPT to write some chords for a polka tune.

Write the chord progressions for parts of a polka song.

Sure! Here are some chord progressions that you could use in a polka song:

The most basic polka chord progression is a simple I-IV-V progression, using the key of C major as an example:

C — F — G

Here’s a variation on that progression that adds in the ii chord (D minor):

C — Dm — F — G

Another common polka progression is to start with the iii chord (E minor) and then move to the IV chord (F major) and the I chord (C major):

Em — F — C

You could also try a more complex progression that involves the ii chord and the vi chord (A minor):

C — Dm — A7 — F — G

Remember that these are just a few examples, and you can get creative with your chord progressions in a polka song. The most important thing is to keep a bouncy, energetic feel to the music and to keep the rhythms driving and lively.

Again, ChatGPT suggested chords for the song parts in the key of C major. I found that if I didn’t specify a key in my initial request, it always resorted to being in C. As a side note, the system does know how to transpose songs; you just have to ask it (i.e., “Transpose this song to B flat.”)

I liked the chord patterns it suggested for the song, along with some helpful commentary. However, there was a minor error (pun intended 😉) with the final progression, in that it mentioned A minor in the commentary but showed A7 in the sequence, which is a dominant chord. It turns out that A7 actually sounds good there.

I then asked the system to write specific chord progressions for the various parts of the new tune.

OK, please write the chords for an intro, verse, and bridge of a polka song.

Sure! Here’s an example of a chord progression for an intro, verse, and bridge of a polka song, using the key of C major:

Intro: C — F — G (x2)

Verse: C — Dm — A7 — F — G (x2)

Bridge: Em — A7 — Dm — G

Again, these are just examples, and you can get creative with your chord progressions in a polka song. You could also try adding in additional chords or modulating to a different key in the bridge to add some variety to your song. Just be sure to keep the rhythms lively and energetic to capture the feel of a polka song.

I liked the results! It chose example progressions from the initial suggestions and specified how many times to repeat the sequences with the “x2” indicators. Notice how it kept the A7 chord in the verse and, as a bonus, added that chord to the bridge pattern as well. I had to make some creative decisions on the timing of the chords in the intro and the verse, so I made them go like this, with a quick F-G turnaround at the end for both.

Intro: C-C-F-G (x2)
Verse: C-C-Dm-Dm-A7-A7-F-G (x2)

I kept the bridge as originally written. I then asked it to give the song a name.

What’s a good name for this song?

That’s entirely up to you! You might consider giving your song a fun, playful name that reflects the lighthearted nature of the polka genre. Some ideas could be “Polka Party,” “Dancing Shoes,” “The Happy Polka,” or “The Polka Waltz.” Alternatively, you could choose a more descriptive name that reflects the theme or lyrics of your song, such as “The Love Polka,” “Spinning with Clara,” or “The Polka of Despair.” Ultimately, the name of your song is a matter of personal preference, so choose something that you think represents your song well and captures its spirit.

Wow. Unlike the previous example, it gave me a lot of names to choose from. ChatGPT is quirky this way. Sometimes it comes back with a simple answer, but sometimes it gets chatty. Note that I could have asked for more suggestions if needed. Of the seven recommendations, I liked “Spinning with Clara” the best, as it was the most unique.

I then pasted the chords into BiaB, including the repeated patterns, chose a polka style, and it rendered the song. Here is “Spinning with Clara.”

“Spinning with Clara,” Chords by ChatGPT, Music by BiaB, Video by Author

Nice! Cool and catchy! I really like the intro riff, which is all BiaB. The instrumentation features bass, drums, guitar, and accordion, with a clarinet taking the lead. Ha! Clara? But I also like the chord progression from ChatGPT, especially when it hits the A7 chord in both the verse and the bridge. It adds some chromatic tension, which seems to fit the polka style.

There is a little bit of a collision of tones between the clarinet and the accordion in bars 9 thru 12, but once the horn gets up an octave, it’s okay. I could always drop the accordion down in the mix for that stretch, but I wanted to see what it sounded like right out of the box (as it were 😏). Up next is some country rock.

country rock instruments on an empty stage,” Midjourney Image, Edited by Author

Country Rock Music

My final experiment was generating chords for a country rock song. Country rock is a hybrid that combines elements from both music styles. I’m not sure if The Byrds started this sub-genre or not, but their frontman certainly thinks they did.

When The Byrds started country-rock, we had no idea there would be such a thing. We were just trying to honor the music. We started listening to country radio. We went to Nudie’s and got cowboy clothes. — Roger McGuinn of The Byrds

In any event, ChatGPT seems to know what country rock is, as it provided some nice chord progressions and commentary when I asked.

Write chord progressions for a country rock song, with a verse, chorus, and bridge.

Here’s an example of a chord progression for a country rock song with a verse, chorus, and bridge:

Verse: E — B — A — B (I — V — IV — V)

Chorus: E — A — B — E (I — IV — V — I)

Bridge G#m — F# — B — E (iii — ii — V — I)

This progression provides a strong sense of tonality and movement, and it can be used as the foundation for a country rock song. The verse uses the I — V — IV — V progression, which is a common progression in country rock and provides a sense of tension and release. The chorus then resolves that tension with the I — IV — V — I progression, which is a strong, driving progression that’s often used in rock and pop music. The bridge adds some variety to the song by using a different progression, the iii — ii — V — I progression, which adds a sense of contrast and can help to build excitement and tension leading into the final chorus.

Of course, this is just one example, and there are many other chord progressions that could be used in a country rock song. The important thing is to find a progression that works well with your song and helps to create the desired mood and feel.

The results here seem good, too. However, note that the system is again confused about which chords are dominant and which are minor. In the Roman numeral format, uppercase letters indicate major chords, and lowercase letters indicate minor chords. The chords for the bridge part were specified as “G#m — F# — B — E (iii — ii — V — I),” where the ii chord should be F# minor, but it shows as F# major. It did get the G# minor chord correct. I decided to roll with the mistake, but I asked the system to use 7th chords, often used in both country and rock music. I just needed to ask.

OK, but use 7th chords.

Sure! Here’s an example of a chord progression for a country rock song with a verse, chorus, and bridge, using 7th chords:

Verse: E7 — B7 — A7 — B7 (I7 — V7 — IV7 — V7)

Chorus: E7 — A7 — B7 — E7 (I7 — IV7 — V7 — I7)

Bridge: G#m7 — F#7 — B7 — E7 (iii7 — ii7 — V7 — I7)

This progression is similar to the one I suggested earlier, but it includes 7th chords, which add a bit more complexity and color to the chords. The 7th chords add a sense of tension and dissonance, which can be particularly effective in a country rock context.

Again, this is just one example, and there are many other chord progressions that could be used in a country rock song using 7th chords. The important thing is to find a progression that works well with your song and helps to create the desired mood and feel.

And sure enough, it added a 7 to all of the chords. But it also behaved like a good writing partner when it provided positive reinforcement for my suggestion as being “particularly effective in a country rock context.” Why, thank you kindly, partner! I had one more request.

What’s a good name for this country rock song?

“Kickin’ Up Dust”

Again, it responded with just one suggestion for a name. But it seemed to fit, especially with the “g” missing at the end of kicking, so I used it.

I then put all the chords in BiaB, which I did without making any decisions because the three parts had four chords. I then chose a country rock style and generated the song. Here it is.

“Kickin’ Up Dust,” Chords by ChatGPT, Music by BiaB, Video by Author

BiaB chose drums, bass, and organ for the backing tracks and guitar for the lead melody, which is common in country rock. The guitar work was particularly lovely, although using a pedal steel guitar would have been fitting. And the chords from ChatGPT worked well once again. To my ears, the bridge part is the piece’s highlight, despite (or maybe because of) the erroneously dominant F#7 chord.

Discussion and Next Steps

As I have shown, ChatGPT knows a lot about music theory and can generate chord progressions for various styles of music and provide color commentary for its choices. It can also take feedback to create variations of the composed songs and provide additional comments. It occasionally makes mistakes, like giving contradictory and seemingly incorrect recommendations for chords. But the results sounded just fine in the two cases where that happened.

One thing I didn’t try was showing ChatGPT the chords to an original song as a work in progress and asking it to suggest some improvements or add a new part. Based on my experience with it, the results would be pretty good.

The system has a long way to go for composing melodies, however. My initial try at creating a melody for a blues song did not sound good at all.

A New Version of ChatGPT

As I was in the middle of working on this project, OpenAI released a new version of their model with improvements.

We’re excited to announce several updates to ChatGPT! Here’s what’s new:

We made more improvements to the ChatGPT model! It should be generally better across a wide range of topics and has improved factuality. … — Open AI

I then recreated my blues melody experiment with the new version, but the results were similar.

Write a 12-bar blues progression in the key of E.

E — E — E — E
A — A — E — E
B7 — A — E — B7

Write a melody for this song in ABC notation.

Unfortunately, as a AI I cannot write a melody for you as it requires creativity and inspiration, but I can give you an example of a melody in ABC notation that you can use as a starting point:

X:1
T:Example Blues Melody
M:4/4
L:1/8
K:E
“E” E2 E E2 E | “A” A2 A A2 A | “B7” B2 B2 B2 B2 | “E” E2 E E2 E |
“E” E2 E E2 E | “A” A2 A A2 A | “E” E2 E E2 E | “B7” B2 B2 B2 B2 |
“E” E2 E E2 E | “A” A2 A A2 A | “E” E2 E E2 E | “B7” B2 B2 B2 B2 |

This is just an example and you can always change the rhythm or the notes for your own preference.

The melody here is also not good, and it got the chords all wrong between interactions. But at least the newer version seems to be aware of its own limitations. Maybe it’s OK that the system suggests that “creativity and inspiration” should come from humans.

Acknowledgments

I want to thank Jennifer Lim and Néstor Nápoles for their help with this project.

References

[1] J. Schulman et al., ChatGPT: Optimizing Language Models for Dialogue (2020)

AI/ML

Trending AI/ML Article Identified & Digested via Granola by Ramsey Elbasheer; a Machine-Driven RSS Bot

%d bloggers like this: