What is Music Hacking? We’ve asked ChatGPT

Much is said about OpenAI’s ChatGPT tool, the conversational AI search engine. You can ask it to write an FM synthesiser embedded in a web page, or a conversation between the Dalai Lama and Donal Trump. 

We were curious about its understanding of Music Hacking. We were not disappointed by the result!

Prompt on ChatGPT

“Music hacking is the practice of using technology to manipulate or create music in innovative ways. This can include using software to remix existing songs, creating new music from scratch using synthesizers and other electronic instruments, or even using unconventional devices such as hacked game controllers to make music.

One of the key principles of music hacking is the idea of open source and collaboration. Many music hackers share their creations and techniques with others, and often work together to build upon each other’s ideas. This has led to the creation of a vibrant online community of music hackers, who share their work and provide feedback and support to each other.

One of the most popular tools for music hacking is the digital audio workstation (DAW), which allows users to record, edit, and produce music using a computer. DAWs often come with a wide range of virtual instruments and effects, making them ideal for creating electronic music. Another popular technique in music hacking is the use of chiptunes, which are songs created using the sound chips of old video game consoles. By using emulators or actual hardware, music hackers can create nostalgic, 8-bit style tunes that have become popular in their own right.

 

Music hacking has also been used to create experimental and avant-garde music. By using unconventional methods and technologies, music hackers are able to push the boundaries of what is considered “music” and create unique and interesting sounds.

Overall, music hacking is a fascinating and growing field that is constantly evolving. Whether you’re a seasoned musician looking to try something new, or just a curious technologist, there are many ways to get involved and explore the world of music hacking. So, if you have a passion for music and technology, why not give it a try?”

A web-based synth

write javascript code for an FM synthesiser inside an html page

The initial response was missing the buttons to start/stop the synth, and the controls to change the modulation and frequency, so we asked :

write fully functional javascript code for an fm synthesiser inside an html page

What’s amazing is that it picked up the new requirements and added the UI code. We haven’t tested the code, but let us know on Discord if it works!

				
					<!DOCTYPE html>
<html>
<body>

<!-- Create a start/stop button for the synthesizer -->
<button id="startStop">Start</button>

<!-- Create faders for the modGain and modOsc values -->
<label for="modGain">Modulation Gain:</label>
<input type="range" id="modGain" min="0" max="10" step="0.1" value="1">
<label for="modOsc">Modulation Frequency:</label>
<input type="range" id="modOsc" min="0" max="1000" step="1" value="220">

<script>
  // Create an audio context
  var audioCtx = new AudioContext();

  // Create sine wave oscillators for the carrier and modulator
  var carOsc = audioCtx.createOscillator();
  var modOsc = audioCtx.createOscillator();

  // Set the frequencies of the oscillators
  carOsc.frequency.value = 440;
  modOsc.frequency.value = 220;

  // Set the modulation index of the modulator
  var modGain = audioCtx.createGain();
  modGain.gain.value = 1;

  // Use the output of the modulator to modulate the frequency of the carrier
  modOsc.connect(modGain);
  modGain.connect(carOsc.frequency);

  // Set the gain of the carrier oscillator
  var carGain = audioCtx.createGain();
  carGain.gain.value = 0.5;

  // Connect the oscillators to the DAC
  carOsc.connect(carGain);
  carGain.connect(audioCtx.destination);

  // Function to start/stop the synthesizer
  function toggleSynthesizer() {
    if (carOsc.state === "running") {
      carOsc.stop();
      modOsc.stop();
      startStop.innerHTML = "Start";
    } else {
      carOsc.start();
      modOsc.start();
      startStop.innerHTML = "Stop";
    }
  }

  // Function to update the modGain and modOsc values from the faders
  function updateValues() {
    modGain.gain.value = modGainFader.value;
    modOsc.frequency.value = modOscFader.value;
  }

  // Get the UI elements
  var startStop = document.querySelector("#startStop");
  var modGainFader = document.querySelector("#modGain");
  var modOscFader = document.querySelector("#modOsc");

  // Set the event listeners for the UI elements
  startStop.addEventListener("click", toggleSynthesizer);
  modGainFader.addEventListener("input", updateValues);
  modOscFader.addEventListener("input", updateValues);

  // Start the oscillators
  carOsc.start();
  modOsc.start();
</script>

</body>
</