The Sound of Quantum: Unveiling New Dimensions in Music through Quantum Computing

Author: Lucas Krippendorff
Mentor: Roberto dos Reis
Gulliver Prepatory School

Abstract

Though not typically at the forefront of technological advances, musicians have always implemented advanced technology. Technologies continue to self-integrate with music, inevitability expanding the bounds of self-expression. As quantum computers and their capabilities are utilized more by large industries such as cybersecurity and quantum chemistry, a smaller but ever-present inclination appears to adopt this emerging technology into music.

Cross-disciplinary research is already emerging within the field of quantum computing; multiple experimentations exploring the various methods of integrating science and art can be found in the literature (Katz 2010). A primary example is Quantum Computer Music: Foundations, Methods and Advanced Concepts, which culminates various papers and articles into a book (Miranda 2022). Some leverage quantum computers to “solve” music as an optimization problem, balancing various components that define music (Arya et al. 2022). Others approach implementation by developing quantum tools to aid music composed with human ingenuity rather than trying to replicate it (Hamido 2022).

In this experiment, we attempt to create a functioning program through the Qiskit and Python learning languages within IBM’s Quantum Lab. Unlike their classical counterparts, the advantage of using quantum computers to generate music rather than classical computers is that qubits display true randomness when measured. More often than not, this generates a random assortment of notes without any form or inclination to a sort of musical pattern, resulting in unpleasant music.

This article outlines the first phase of this research, which ultimately seeks to utilize quantum computing to create technically “perfect” music based on traditional music theory.

Introduction

Recent explorations of quantum computing’s potential within the arts, particularly music theory and composition, have made significant strides in generating visual arts based on quantum algorithms as well as music sequences (Arya et al. 202). Examples of advancements include the means to control an inverse Fast Fourier Transform (FFT) sound synthesizer and an adaptive musical sequencer, culminating in the composition “Zeno” as a practical demonstration of this technology’s capabilities (Miranda 2021). Others in the field represent music composition as an optimization problem and attempt to solve it using quantum annealing via adiabatic quantum computing to craft melody, rhythm, and harmony. An example of music generation through this method is using D-Wave quantum annealers (Arya et al. 2022.) Another further suggests the development of Quantum-computing Aided Composition (QAC) and the QAC Toolkit Max package, reflecting on Quantum Computing’s role in enhancing creative music practice and addressing the integration challenges and opportunities (Hamido 2022.) While the fields of physics, computer science, and music have been interconnected for decades with the rise of electronic sound boards and synthesizers, quantum computation within the musical industry is fairly new, and possibilities for composition and sound realization are many.

The objective, as a Quantum Music Composer, is to create a foundation in which developing advanced quantum algorithms capable of generating complex sequences of notes and chords can be made more simple by constructing a base from which additions to the composer are easy to implement. This long-term and multiphasic project has two objectives: (1) to contribute to the theoretical understanding of quantum music through exploring quantum circuits and how to prepare the input data and (2) to provide practical tools that composers and musicians can use to explore new auditory landscapes. Doing so, we aspire to open up new dimensions in music composition, where quantum-induced variability and complexity introduce a novel sound aesthetic.

In what follows, we will delve into the background of quantum music, outline the quantum algorithms designed for our Quantum Music Composer, and discuss our work’s potential implications and applications in both the scientific and artistic communities.

History of Quantum Music

Quantum computing, characterized by its ability to process complex calculations at unprecedented speeds due to principles like superposition and entanglement, has found applications across various fields, from cryptography to drug discovery (Bains 2023). Recently, this cutting-edge technology has ventured into the realm of music, birthing the concept of quantum music. Quantum music explores how quantum computing can revolutionize music composition, synthesis, and even performance, pushing the boundaries of creativity and technology.

The pioneering efforts in quantum music have sought to harness quantum algorithms for generating novel musical compositions that may be impossible with classical computing methods (Basak 2022). These endeavors include the generation of sequences of notes or chords that reflect the probabilistic nature of quantum measurements, leveraging quantum randomness for creativity, and modeling musical structures using quantum states (Basak 2022).

Methods

Basics of Quantum Algorithms

To better understand what quantum computing is, one needs first to understand the qubit. A classical bit can be in two states of either 0 or 1, but the qubits can be expressed in any state of 0, 1, or a quantum superposition of both (Watrous 2022). This allows quantum computers to essentially browse possible answers with an inclination to the correct one (Watrous 2022). In theory, quantum entanglement takes this property further. As a single qubit can form a unique connection with every other qubit in a computer, computing power increases exponentially (Watrous 2022). This makes quantum computing faster, and the processing power tackles problems that are currently intractable by classical computers (Watrous 2022).

Basic quantum operations: Bloch Sphere and primitive gates

Quantum algorithms are founded on basic quantum operations as well as the basics of quantum mechanics (Watrous 2022). Still, the heart of quantum computing is formed by operations manipulating qubits, the foundational units of quantum information that can exist in many states simultaneously due to the principle of their superpositions (Watrous 2022).

Below are relevant concepts pertinent to the understanding of the algorithms developed in this experiment.

Quantum Operations: Quantum operations are the processes that manipulate a qubit’s state, whether in superposition or not. These processes are executed using quantum gates, similar to the logical gates used in classical computing. However, unlike those found in classical computers, quantum gates create and handle superpositions and entanglements, forming computation’s exponential power. A Bloch sphere is a three-dimensional representation of the probability that a qubit will likely output when measured (Watrous 2022).

Superposition: In superposition, quantum gates allow qubits to represent 0 and 1 simultaneously. This gives quantum computing power due to the parallel processing ability it grants to a problem’s solution (Watrous 2022).

Entanglement: Another key operation is entanglement, a quantum property in which the ability of one qubit depends on that of another, no matter the distance. This phenomenon allows quantum computers to make certain calculations more quickly than their classical counterparts (Watrous 2022).

Measurement: Measuring a qubit process causes it to jump into one of the classical states (0 or 1) called its measured state. This operation is not only required to retrieve the result of treatment on quantum computing but also provokes the problem of quantum decoherence, a phenomenon in which the quantum state loses its quantum properties of superposition (Watrous 2022).

Resources

This research introduces a previously untested approach to music composition by leveraging quantum computing’s inherent “true randomness:” randomness that does not rely on a key and an algorithm to generate random numbers like that seen in a classical computer. Utilizing the IBM Quantum Lab, a comprehensive platform accessible via the IBM Quantum website, quantum simulators were used to conduct these experiments (IBM 2024). The IBM Quantum Lab was chosen for its seamless integration with IBM’s quantum devices, offering a robust environment for developing and testing quantum algorithms.

Basics of Musical Composition

Our aim is to create a quantum music composer that employs the stochastic nature of qubit measurements to generate random notes and chords. This gives our composer the means of coming up with music reflecting this complexity and the nuanced nature of natural sounds in a closer way than it has ever been. The combination of precision technology and the organic unpredictability of nature would give birth to innovative and dynamic musical pieces, and through quantum computing, the organic aspect of this would be authentic.

Implementation

At the core of our implementation is the use of IBM Qiskit, a versatile quantum computing framework that applies quantum mechanics principles in innovative ways, notably in music creation. Our process begins with establishing a musical scale, such as the C Major scale, for its simplicity, involving only white piano keys. We then designed a quantum circuit with a calculated number of qubits, ensuring that each note in our scale corresponds to a unique quantum state. This setup allows for the random selection of notes upon qubit measurement.

Execution involves repeatedly generating random notes to form chords, thus creating a sequence of musical expressions over time. The outcome of this quantum-inspired composition process is visualized in a “piano roll” format. This graphical representation, akin to a piano roll (a digital grid that shows music notes with pitch/note on the y-axis and time on the x-axis) for composing and editing in a DAW (Digital Audio Workstation), offers an intuitive view of the quantum-generated music sequence, making it accessible and understandable for musicians and composers.

Figure 1. Piano Roll Visualization without chords.

By combining the principles of quantum computing with musical creativity, this research not only explores new frontiers in music composition but also demonstrates the practical application of quantum randomness in artistic endeavors.

Code

The following is the code used to create the quantum music composer. Notes are placed throughout the code to provide critical context.

The Sound of Quantum: Unveiling New Dimensions in Music through Quantum Computing | Submission

Python 

# Importing standard Qiskit libraries 
from qiskit import QuantumCircuit, transpile 
from qiskit.tools.jupyter import * 
from qiskit.visualization import * 
from ibm_quantum_widgets import * 

# qiskit-ibmq-provider has been deprecated. 
# Please see the Migration Guides in https://ibm.biz/provider_migration_guide for more detail. 
from qiskit_ibm_runtime import QiskitRuntimeService, Sampler, Estimator, Session, Options 

# Loading your IBM Quantum account(s) 
service = QiskitRuntimeService(channel="ibm_quantum")

# Invoke a primitive. For more details see
https://docs.quantum-computing.ibm.com/run/primitives
# result = Sampler().run(circuits).result()

Python
from qiskit import QuantumCircuit, Aer, execute from qiskit.visualization import plot_histogram
# Step 1: Define the Musical Scale and Notes # Example: C Major scale
notes = ['C', 'D', 'E', 'F', 'G', 'A', 'B']
# Step 2: Create a Markov Chain
# This is a simplified example with equal probabilities
# In a real scenario, you would define these based on musical theory or
existing compositions
# Step 3: Quantum Circuit
# Creating a basic quantum circuit
qc = QuantumCircuit(3) # 3 qubits for 8 possible states (2^3 = 8, including one extra state)

# Apply quantum gates to represent transitions (this is a simplification)
# In a full implementation, the gates would correspond to the probabilities in the Markov chain
qc.h(range(3)) # Applying Hadamard gate for superposition
# Step 4: Measurement and Note Selection
qc.measure_all()
# Execute the circuit
service = QiskitRuntimeService(channel="ibm_quantum")
backend = service.least_busy(operational=True, simulator=False) print(backend.name)
result = execute(qc, backend, shots=1).result()
counts = result.get_counts()

# Selecting the note based on the measurement
measured_state = list(counts.keys())[0] # Get the binary string
note_index = int(measured_state, 2) % len(notes) # Convert to integer and map to the scale

selected_note = notes[note_index] print(f"Selected note: {selected_note}")
# Step 5: Repeat the process to compose a sequence of notes
# This would involve looping the process and potentially updating the Markov
chain based on previous selections

Python
import matplotlib.pyplot as plt
import numpy as np
from qiskit import QuantumCircuit, Aer, execute
# Define the Musical Scale and Notes
notes = ['C', 'D', 'E', 'F', 'G', 'A', 'B']
note_indices = {note: i for i, note in enumerate(notes)}
# Create a Quantum Circuit
qc = QuantumCircuit(3) # Using 3 qubits for this example qc.h(range(3))
qc.measure_all()
# Execute the circuit multiple times to generate a sequence
backend = Aer.get_backend('qasm_simulator')
sequence_length = 8 # Define the length of the music sequence sequence = []

for _ in range(sequence_length):
result = execute(qc, backend, shots=1).result() counts = result.get_counts()
measured_state = list(counts.keys())[0] note_index = int(measured_state, 2) % len(notes) sequence.append(notes[note_index])
# Function to plot a piano roll
def plot_piano_roll(sequence, note_indices): fig, ax = plt.subplots(figsize=(12, 6))
  # Creating a piano roll matrix
piano_roll = np.zeros((len(notes), len(sequence))) for t, note in enumerate(sequence):
piano_roll[note_indices[note], t] = 1

# Plotting the piano roll
ax.imshow(piano_roll, aspect='auto', cmap='Blues', interpolation='nearest')
     # Setting the labels and titles
     ax.set_yticks(np.arange(len(notes)))
     ax.set_yticklabels(notes)
     ax.set_xlabel('Time Step')
     ax.set_ylabel('Notes')
     ax.set_title('Quantum Music Composer - Piano Roll Visualization')
plt.show()
   # Plotting the sequence of notes
plot_piano_roll(sequence, note_indices)

Results

Building the quantum music composer went smoothly. Aside from a handful of typos that produced bugs during the programming phase, there were no significant hurdles. The composer accomplished the task of putting a series of qubits into superposition and measuring them to choose a musical key at random with no resistance. It could also do so in quick succession. Initially, the program was configured to choose a single note for each time slot, but upgrading from this was simple. By repeating the note selection multiple times for each time slot, chords could be generated, enhancing the musical ability of the composer.

However, because the resulting notes were random at this stage of the experiment with no musical arrangement or form (like that of standard chords), more often than not, the composition produced by the program sounded objectively wrong.

Discussion:

Hypothetical Upgraded Quantum Composer

Figure 2. Piano Roll Visualization with chords.

The first stage of this research resulted in creating a truly random chord generator. While rudimentary with a lack of rules to preference chords that create harmony (how well chords work together), the program developed has strength in its ability to also act as a template from which more complex features may be added, like music theory concepts, to provide direction to the process of composition. A method to accomplish this is through Markov Chains, where each key’s chance to be selected depends only on the state immediately before it.

The second phase of research will implement music theory principles to govern the program’s decisions. This will theoretically allow the quantum computer to create technically perfect compositions using Markov chains to model transitions between chords, which is a promising avenue to advance the efficacy and usability of this program (Basak 2022).

In the music industry today, music theory acts more as guidelines than set rules. Examples are commonplace in genres like jazz when notes that “shouldn’t” go together according to traditional theory create tension,a built-up of anticipation with a satisfying resolution that sounds and feels surprisingly good. However, this technicality is difficult to accomplish, so, for simplicity, a hypothetical program that involved music theory through Markov chains would stick strictly to music theory guidelines to ensure that “technically perfect” music is composed, even if the results are arguably uncreative.

Implementing “guides” formatted as music theory represented through Markov Chains presents a problem: music theory is a grand topic with no particular starting point, so what would act as the foundational principles for the program? Ultimately, our next generation of code wille begin with broad music theory guidelines: staying within a key. Once a key is selected, the next step will select different types of chords that best match with one another within the chosen key. Then, notes can be selected for each chord.

It is possible to introduce some probability gradient that lessens as the possible notes in the key stray further from the base note, resulting in the likelihood, but not certainty, that chords will remain within the same one or two octaves. For instance, if the base key of a chord is C4, say C major, which includes the keys C, E, and G, then it would be unlikely for the key of E7 to be selected to be a part of the chord because they are three octaves apart in a piano keyboard. Allowing E7 to remain possible limitedly is an example of an engineered stray feature with a low likelihood of occurring, but is appreciated for enhancing the music arrangement.

It should be mentioned that for most musicians, this is arguably a “boring” way to go about composition. Such experimentation, when following the rules of music theory strictly, is not often seen at the forefront of the music industry. However, an advantage to no experimentation is the lower likelihood of messing up the composition in pursuit of something pleasant, resulting in a process that would create something pleasant to listen to more often than not.

Conclusion

The program constructed and it’s previously laid out hypothetical further advanced version are purposefully simple quantum music composer algorithms because they directly assign an individual note to a collective qubit measurement. Our quantum circuit primarily uses qubit superposition to generate randomness that classical computers cannot reproduce. However, this does little to tap into the enormous potential quantum computing holds, as it does not yet access the quantum potential qubits that superposition offers. In the future, their forms may expand within the domain of music composition to encompass more niche elements of music, becoming increasingly complex in the process.

Current efforts in the field lack a general understanding of leveraging quantum computing’s extensive computational power for artistic creation, a pursuit I’d like to expand. The question remains: can the application of quantum music create structures as sophisticated as those of human composers? On this frontier, quantum computing could minutely appreciate and apply the principles of music theory for crafting compositions that are not merely original but, most crucially, sonically attractive. Creating “perfect music” for many is counterintuitive to the definition of music: an expression of emotion that all humans experience distinctively. However, the idea posits an intriguing possibility: that one-day quantum computing might yield universally moving compositions and proof of the transcendent capabilities of this burgeoning new music, free from any limitations.

Works Cited

A. Arya, L. Botelho, F. Canete, D. Kapadia, and O. Salehi. 2022. Music Composition Using Quantum Annealing.” in Quantum Computer Music: Foundations, Methods and Advanced Concepts. Pp 373-406.

E. Miranda, S. Basak. (2022). “Quantum Computer Music: Foundations and Initial Experiments”. In: E.R. Miranda (Ed.), Quantum Computer Music: Foundations, Methods and Advanced Concepts. (pp. 43-54)

Hamido, O.C. (2022). QAC: Quantum-Computing Aided Composition. In: Miranda, E.R. (eds) Quantum Computer Music: Foundations, Methods and Advanced Concepts. Pp 159-196.

IBM. (n.d.). IBM Quantum. Retrieved from https://www.ibm.com/quantum

S. Bains, S. Gupta, K. Joshi, B. Kothapalli, S. Sharma and A. Dutt, “Quantum Computing in Cybersecurity: An in-Depth Analysis of Risks and Solutions,” 2023 3rd International Conference on Advance Computing and Innovative Technologies in Engineering (ICACITE), Greater Noida, India, 2023, pp. 1651-1654, doi: 10.1109/ICACITE57410.2023.10183060.

keywords: {Neuroimaging;Vocabulary;Quantum computing;Human intelligence;Standards organizations;Organizations;Search problems;AI;TF-IDF;Data Analysis;TF-GFP;NLP Method;Data Interpretation and IQ},

Watrous, J. (2022). Lesson 01: Single Systems | Understanding Quantum Information & Computation [Video playlist]. Qiskit by IBM. Retrieved from https://www.youtube.com/playlist?list=PLOFEBzvs-VvqKKMXX4vbi4EB1uaErFM SO

Arya, A., Botelho, L., Canete, F., Kapadia, D., & Salehi, O. (2022). Music Composition Using Quantum Annealing. In Quantum Computer Music: Foundations, Methods and Advanced Concepts (pp. 100-145). Springer. https://doi.org/10.1007/978-3-030-72116-9_34

Ableton. (n.d.). Ableton. Retrieved from https://www.ableton.com

Katz, Mark. Capturing Sound: How Technology Has Changed Music. United Kingdom: University of California Press, 2010.


About the author

Lucas Krippendorff

Lucas is currently a senior at Gulliver Prep High School. He enjoys physics, mathematics, engineering, and music. He participates in his school robotics team or composes music in his free time.