View Github
Hear the quantum sound version 1
Hear the quantum sound version 2 (generated from MuseScore with different instrumental color)
Hear the quantum sound version 3 (generated from MuseScore with different instrumental color)
This week I and other qiskitters have been working on something great and profound for 24 hours , eventually my team received community choice award in IBM Qiskit Hackathon Global. This is the first immersive and real time 24 hour virtual hackathon experience hosted by the community and my first hackathon in my life. I was so thrilled to take part in the event and got such achievement.
Working with people of diverse potential and capability around the world sharpen my concepts, technical skills, teamwork, time management, self-directed learning in a very fast pace. This project broadens my horizon on the fusion of cutting-technology and humanity. It is a very impressive experience working with the exceptional talents below:
How can we map quantum states and operations to create music notes with different instruments?
Our project is to deliver a program, like Jupyter Notebook as interactive interface, capable of receiving a quantum circuit and return an audio file of different sound properties with a music sheet. This is a very cool combination of music with quantum knowledge. What’s more, we will potentially produce a paper in the future. Before that, we need to understand the principle of superposition and entanglement as it relates to quantum operations with sounds.
Here is some notes for the project.
Qubit is the core component of quantum computing. A qubit represent a quantum state of a particle.
We define the basis states as |0> and |1>, which represents the physical state of a particle. Both are orthonormal (orthogonal and normalised). These column vectors are called ket and the row vectors are called bra.
In quantum mechanics, both states happen at the same time, which is a linear combination of different basis state with a proportional probability.
To apply quantum operation of quantum note, we need quantum gate for the transformation. The quantum gate helps us to manipulate the data stored in it. A basic quantum circuit operate on a small number qubits, they are the building blocks of quantum circuits. Pauli gate, like X, Y, Z can perform transformation on qubits. So a model for quantum computation in which a computation is a sequence of quantum gates, which are reversible transformation on a quantum mechanical analog of an n-bit register.
Let's think of wire as one instrument that plays a note. But this is not an ordinary note, it has superposition with exponential amount of information, i.e. it can play multiple notes at the same time, unless you measure it. Think of the above diagram chronologically, all the notes are played at the same time, just like all instruments play one note in the orchestra simultaneously.
For this project, we think of various qubits resemblance different instrument playing notes. However, we need to think about their relative position for the harmonics in chord, that's why the notes need to be entangled. We can observe this practice in piano in the left hand side. Green notes and purple notes form in pair correspondingly, so they are entangled. If we have an A5, then we will have an E4 (purple); if we have a E4 then we will have a A5 (green). We formulate this phenomenon into entangled state.
In this this interface, user can select each gate ( no gate, X gate, Y gate, Z gate) per instrument. For this example, we have 5 wires so we have 5 options. After choosing the option, we can have result on the right.
So we make the chosen of gate for operation that generate some random "noise". Due to randomness in quantum mechanics, we will receive different phrase each time. In the above diagram, we apply H gate to the 4 qubits for superposition. Up to this extent of operation, user can submit 5 gates to any of the 4 wires.
Now, it's time to map music to quantum realm. As we have applied gates. We read the quantum state vector of the circuit and then we map the imaginary and real values to the music notes. In the above diagram, we transform the values to music note by setting criteria. These notes have to be played in entanglement for harmonics.
After that, the above variables will store a list of musical notes.
To generate a sound of specific frequency, we call the .wav file for the note manipulated during operation.
After extracting an audio file, can we generate a sheet music? The answer is yes and we can make use of the the great and convenient database called music21.
We make use of the value found form the quantum operation to find the notes. After that, we assign the notes with the appropriate frequency corresponding value to the software default variable and the order of the notes generated. We translate back the values into note, for simplicity, we assign all the notes are just a quarter notes, and we only get the length of 14 beats. Finally, we use streamGuitar.show() to print music sheet!
Similarly, we can show the music for other instruments. However, all these generated music notes are only one colour, we need the following code to call the specific sound of the instruments.
Finally, we group all the parts together, and it becomes a little OrQestra! Tutti!
The last step is, how we can print the sheet music, we need another software to help us: MuseScore.
This software can help us to transform the above data in .xml to the following
To export the sheet music to .pdf file and you can export the midi sound as .wav. That's all for the project.
However, more elements should be added to the program:
- Quantum neural network and processing should be added for optimisation and improvisation.
- In music, not only do we consider harmonics, melody is equally important. So we plan to make a piece with different duration and rest for melody.
- User can input as many gate as possible for quantum operation.
- A wider range of musical notes corresponding to the quantum values should be selected for more pitch. Another thing is to investigate the pitch number in the database music21.
- Number of wires should be freely chosen by the user to create orchestra tutti for more dynamics.
- More set of rules should be investigated. Besides counterpoint composition, can we generate classical music and even jazz?
- We are now using Jupyter Notebook as interface, can we use another more use-friendly one like Unity or app?
- A project website can be built to showcase our works, explanation, etc.
We are looking forward to making something more brilliant in the future!