How can I use ChatGPT to make music?

ChatGPT code for music app Sonic Pi

The artificial intelligence app ChatGPT is everywhere you look at present, and it or platforms like it probably aren’t going away. In fact, they’re likely to improve at exponential rates. As a musician, whether you love or hate stuff like this, being aware of it is important. This is a brief primer on just some examples of what’s out there at present for you to play with.

To start this off, I asked ChatGPT itself what music-related coding languages it knows. Its response:

As an AI language model, I am familiar with several programming languages related to music. Here are some of them:

  1. Max/MSP: A visual programming language for music and multimedia.
  2. SuperCollider: A platform for audio synthesis and algorithmic composition.
  3. ChucK: A strongly-timed audio programming language for real-time synthesis, composition, and performance.
  4. Pure Data (Pd): A graphical dataflow programming language designed for audio and multimedia processing.
  5. Csound: A programming language designed for sound and music synthesis.
  6. Python with music libraries such as Music21 or Pydub for audio processing.
  7. JavaScript with Web Audio API for audio manipulation and visualization.
  8. Sonic Pi: A live coding environment for music.
  9. Faust: A functional programming language specifically designed for real-time audio signal processing and synthesis.

These are just a few examples of coding languages related to music. There are many more, and each has its own strengths and weaknesses depending on the specific application.

Ok – even a novice like me recognises that there’s a few heavyweights in that list. Let’s look at one of them: Sonic Pi

Our friend Ed at Elk Elektronik has done a brilliant video showing broadly how ChatPGT and Sonic Pi work:

Until watching this video I’d never used Sonic Pi before, but it’s pretty easy to use. You can download it here, with versions available for Windows, Mac and Raspberry Pi OS. All you need to do is launch ChatGPT in your browser and type a query in plain English. For example, I asked the following:

Can you generate sonic pi code in the style of Kraftwerk?

ChatGPT then responded with an answer, including the appropriate Sonic PI code (image only shows a small amount of the total code):

Now it’s just a matter of pasting that code into the main window of the Sonic Pi app and clicking on ‘run’ to hear the result:

To save you doing all those steps yourself, you can listen to the output right here:

It’s pretty rudimentary, sure. But that’s the raw output only – Sonic Pi gives you lots of onboard tweaking options and that’s before you add your own gear to the equation. At the very least it’s a great scratchpad for ideas.

For those who worry we are about to be overrun by AI music – we may have a little breathing time as although Sonic Pi was simple to use as a non-coder, I tried all the others in the list above and couldn’t get a single one to work for me, for a variety of reasons. There’s still some work to do by our AI overlords!

Leave a Reply