This page provides access to the source code of the Quantum Gate Music Generator, a system that translates quantum gate operations into musical output using Qiskit and Python.
The tool features a GUI interface for designing quantum circuits and hearing their musical interpretation in real time.
Citation:
Souma, S. (2022). Exploring the Application of Gate-Type Quantum Computational Algorithm for Music Creation and Performance. In: Miranda, E.R. (eds) Quantum Computer Music. Springer, Cham. https://doi.org/10.1007/978-3-031-13909-3_5
A Graphical Interface for Quantum Music Creation :This visual interface enables users to design quantum circuits using buttons, sliders, and gate selections, and instantly hear their musical outputs. Multiple modes are supported, including note-based playback, chord progression, and quantum game strategies. Designed as part of an exploratory project on quantum-based musical expression, this system bridges quantum computation and real-time sound synthesis.
Mode 1–5: These are the mode selection buttons. The parameter Nbit_note shown here indicates the number of qubits used per note, depending on the selected mode. (For details, see the explanation for each mode below.)
Nnotes: The number of notes along the time axis. In Modes 1–4, this corresponds to the number of active columns of radio buttons in the center of the GUI.
In Mode 5 (which applies quantum game theory to two-player music generation), two players each play a note at every time step. Therefore, for example, if Nnotes = 4, the number of radio button columns used becomes Nnotes × 2 = 8. (Further details are provided in the Mode 5 section.)
Nshots: The number of measurement shots.
Measurement: Executes quantum measurement.
Playback: Plays back the notes corresponding to the latest measurement results.
Stop Playback: Stops playback during multiple-shot playback. Playback halts at the end of the current shot sequence.
Save GUI State: Saves the current GUI configuration.
Load GUI State: Loads a previously saved GUI configuration.
The radio buttons and sliders below the main controls configure the quantum gates applied to each note along the time axis (i.e., column-wise, from left to right).
The function and interpretation of these gates vary depending on the selected mode, and are explained within the individual mode descriptions.
The white panel at the bottom displays the measured bitstrings.
The rightmost digit in each bitstring corresponds to the first note in time.
The horizontal length of each bitstring is given by Nbit_note × Nnotes, depending on the mode.
Vertically, each row corresponds to a distinct measurement result among the Nshots performed.
Mode 1
In Mode 1, each musical note is encoded using a single qubit. The quantum state of the qubit is measured along a time-varying axis on the Bloch sphere, with the measurement angle around the Y-axis (in x-z plane) specified by the user through the GUI.
The measurement outcome determines which note is played:
If the result is 0, the note corresponds to one of the following: G, G, D, or E.
If the result is 1, it corresponds to F♯, D♭, A♭, or E♭, which are tritone pairs to the former on the circle of fifths.
Transitions between notes are mediated by CNOT gates, linking each note to the next. This design allows for entangled and superposed quantum states along the timeline, depending on the chosen measurement axes.
Upon measurement, one of the superposed possibilities is realized and played as sound. When increasing the number of shots, the sequence of non-equivalent measurement outcomes is played serially, producing a probabilistically-generated melody.
Example of GUI settings in Mode 1.
Here, Nnotes is set to 4, so the first four columns of radio buttons in the center are active. Gates 1, 2, 3, and 4 are selected, corresponding to G/F♯, G/D♭, D/A♭, and E/B♭, respectively. Nshots is set to 10, and in this case, six non-equivalent measurement outcomes are obtained (displayed in the lower panel of the GUI). The notes corresponding to these outcomes are played in serial order, with the rightmost digit played first.
The quantum circuit shown above corresponds to the settings configured in the GUI for Mode 1.
When the "Use circuit drawer" option is enabled in the interface, this circuit diagram is automatically generated and saved as a file named circuit_diagram.png.
Example musical score generated using the quantum circuit in Mode 1.
Mode 2
In Mode 2, each musical note is encoded using two qubits.
The first qubit corresponds to the note duration (note value). If the measurement result of this second qubit is:
0, the note is assigned a quarter note (♩)
1, the note is assigned a half note (𝅗𝅥)
The second qubit determines the pitch of the note in the same way as in Mode 1—by measuring the qubit state along a time-varying axis on the Bloch sphere (around the Y-axis), resulting in one of two complementary notes related by a tritone interval.
As in Mode 1, transitions between qubits are mediated by CNOT gates, but in this case the sequence is structured as follows:
Duration of note 1 → Pitch of note 1 → Duration of note 2 → Pitch of note 2 → ..., with a chain of CNOTs connecting them in time.
This arrangement creates quantum entanglement not only between pitches but also between pitch and duration, resulting in complex quantum correlations between musical parameters.
Upon measurement, one of the superposed possibilities is realized and played as sound. When increasing the number of shots, the sequence of non-equivalent measurement outcomes is played serially, producing a probabilistically-generated melody.
Example of GUI settings in Mode 2:
Here, Nnotes is set to 4, so the first four columns of radio buttons in the center area of the GUI are active—just as in Mode 1. The user has selected Gates 1, 3, 4, and 6, which correspond to the note pairs C/F♯, D/A♭, E/B♭, and G/D♭, respectively. Nshots is set to 10, and in this particular case, all 10 measurement results were non-equivalent, as shown in the lower panel of the GUI (although in general, the number of unique outcomes tends to be smaller than the number of shots).
Unlike Mode 1, each note in Mode 2 is represented by two qubits—one for pitch and one for duration—so each bitstring obtained from measurement contains Nnotes × 2 = 4 × 2 = 8 bits.
For example, in the first measurement result, the rightmost 6 bits (representing the first three notes in time) are:
The quantum circuit shown above corresponds to the settings configured in the GUI for Mode 2.
Example musical score generated using the quantum circuit in Mode 2.
Mode 3
Mode 4
Mode 5