Package: qmuvi
An open-sourcequantumMusicVideo toolqMuVi is a python library that can be used in yourqiskitproject to transform quantum circuits into music videos.Quantum computing is notorious for being unintuitive and difficult to imagine. This tool attempts to create a connection between a human observer and the complex workings of quantum computation. By transforming quantum circuits into music videos, it allows you to "hear" and "see" how a quantum state evolves as it is processed by a quantum algorithm.Showcase video:SetupTo install qMuVi, you can usepip:pipinstallqmuviLinuxFor Linux, qMuVi requires timidity to be installed separately. Instructions for common distributions:pacman-Stimidity++# Arch Linuxdnfinstalltimidity++# Fedoraapt-getinstalltimidity# Debian and Ubuntuzypperinstalltimidity# OpenSUSEUsageimportqmuvifromqiskitimportQuantumCircuitcirc=QuantumCircuit(2)# Barrier gates tell qMuVi where to sample the state in the circuitcirc.barrier()circ.h(0)circ.barrier()circ.cx(0,1)circ.barrier()qmuvi.generate_qmuvi(circ,"bell_state")Running the script will output the generated files, including the MP4 video, into a folder with the specified name "bell_state".Examples can be found in theexamplesfolder with rendered outputs displayed inqmuvi_gallery.Documentation:https://garymooney.github.io/qmuviPropertiesProperties in qMuVi can be customised using optional arguments in thegenerate_qmuvimethod.qMuVi provides simple customisation options such asinvert_colours,fps,smooth_transitions, andshow_measured_probabilities_only, along with more advanced options which are described below.noise_modelAQiskit NoiseModelobject. A simple depolarising noise model can be obtained using theget_simple_noise_modelmethod in theqmuvi.quantum_simulationmodule, or you can make your own.How it works:To sample quantum states, qMuVi uses the qiskit AerSimulator to simulate the circuits. A noise model can be
passed to the simulator to include noise in the computations, which is translated to the generated output in qMuVi.Example:importqmuvifromqmuvi.quantum_simulationimportget_simple_noise_model# define quantum circuit ...noise_model=get_simple_noise_model(gate_error_rate_1q=0.01,gate_error_rate_cnot=0.02)qmuvi.generate_qmuvi(circ,"simple_qft3",noise_model=noise_model)rhythmA list of tuples in the form(sound_time, rest_time).How it works:Each tuple(sound_time, rest_time)in the list corresponds to a sampled quantum
state in the circuit. Thesound_timeis how long the sound will play for and therest_timeis the wait
time afterwards before playing the next sound. Times are in units of ticks where 480 ticks is 1 second.Example:importqmuvi# define quantum circuit ...rhythm=[[200,40]]*7+[[960,0]]qmuvi.generate_qmuvi(circ,"simple_qft3",rhythm=rhythm)instrumentsA list of instruments as _int_s defined by the General MIDI standard. Premade instrument collections can be obtained using theget_instrument_collectionmethod, or you can make your own.Instrument collections'piano''tuned_perc''organ''guitar''bass''strings''ensemble''brass''reed''pipe''synth_lead''synth_pad''synth_effects''ethnic''percussive''sound_effects''windband'How it works:An instrument collection is assigned to each pure state in the quantum state decomposition and the phase of the basis state determines the instrument in the collection.Example:importqmuvi# define quantum circuit ...instruments=[qmuvi.get_instrument_collection("pipe"),qmuvi.get_instrument_collection("reed"),qmuvi.get_instrument_collection("brass"),qmuvi.get_instrument_collection("organ")]qmuvi.generate_qmuvi(circ,"simple_qft3",instruments=instruments)note_mapA callable object that maps state numbers to note numbers. Premade note maps can be found in theqmuvi.musical_processingmodule, or you can make your own.Note Mapsnote_map_chromatic_middle_cnote_map_c_majornote_map_f_minornote_map_c_major_arpeggioHow it works:The note map is used to convert the basis state numbers to the note numbers when generating the MIDI. A note number of 60 is middle C. You can make your own by for example defining a lambda function:note_map = lambda n: n+60or a method with the signiturenote_map(n: int) -> int.Example:importqmuvifromqmuvi.musical_processingimportnote_map_c_major_arpeggio# define quantum circuit ...qmuvi.generate_qmuvi(circ,"simple_qft3",note_map=note_map_c_major_arpeggio)FeaturesGenerate a music video from a Qiskit quantum circuit.