For each quantum measurement of all seven qubits, we will get one note. We can perform this measurement, get the outcome, and play the note with the following code:
import qiskit
def quantum_play_notes(qc,shots):
"""
qc: the quantum circuit of 7 qubits
shots: the number of times to prepare and perform the circuit computation
The quantum state is prepared <shots> number of times.
The result of the measurement each time is played as a single note.
"""
midi_conversion_tables=pickle.load(open(
'midi_conversion_tables.p','rb'))
midi_to_note_bin=
midi_conversion_tables['midi_to_note_bin']
midi_to_frequency_bin=
midi_conversion_tables['midi_to_frequency_bin']
for i in range(shots):
# Note shots=1 may result in a deprecation warning,
# which will go away in a future code version.
sim = qiskit.execute(qc, "local_qasm_simulator",shots=1)
result = sim.result()
final=result.get_counts(qc)
[print(midi_to_note_bin[k]) for k in final.keys()]
play_notes([float(midi_to_frequency_bin[k])
for k in final.keys()],[1.0])