quantumaudio
This package provides Quantum Audio Representations of Digital Audio and necessary utilities.
Using Schemes
Schemes can be directly accessed from quantumaudio.schemes or by using the
load_scheme method.
- quantumaudio.load_scheme(name, *args, **kwargs)[source]
Load and instantiate a quantum audio representation (or scheme) class from a string.
- Parameters:
name (str) – The name of the scheme to load. It can be one of the following: qpam, sqpam, qsm, msqpam, or mqsm.
*args – Optional positional arguments to pass to the scheme class.
**kwargs –
Optional keyword arguments to pass to the scheme class such as:
qubit_depth(int): For qsm and mqsm to manually set the number of qubits to represent the amplitude of audio.num_channels(int): For msqpam and mqsm to manually set the number of channels to represent.
By default, these values are set to None, which means they adapt flexibly to the input data.
- Returns:
An instance of the Quantum Audio Scheme.
- Return type:
Top-level Functions
The quantumaudio.interfaces.api module provides easy access to some of the core functions without explicitly instantiating a Scheme class. They are made directly accessible from quantumaudio.
- quantumaudio.encode(data, scheme=None, **kwargs)[source]
Encodes data and prepares circuit using a specified quantum scheme.
- Parameters:
data (np.ndarray) – The data to encode.
scheme (str | Scheme | None) – Name of the encoding scheme or a scheme object to use. Defaults to “qpam”.
**kwargs – Additional keyword arguments passed required for encoding method and scheme initialisation.
- Returns:
Qiskit circuit encoding the data.
- quantumaudio.decode(circuit, **kwargs)[source]
Decodes a quantum circuit using the scheme it was encoded with.
- Parameters:
circuit (qiskit.QuantumCircuit) – Qiskit circuit object to decode.
**kwargs – Additional keyword arguments passed to the decoding method. Refer to the scheme’s decode method.
- Returns:
Decoded data from the quantum circuit.
- quantumaudio.stream(data, scheme=None, **kwargs)[source]
Streams data through a quantum encoding scheme for longer arrays.
- Parameters:
data (np.ndarray) – Data to be streamed.
scheme (str | Scheme | None) – Name of the quantum scheme to use for streaming.
**kwargs – Additional keyword arguments passed to the streaming method. Refer to
quantumaudio.tools.stream.stream_data()for all arguments.
- Returns:
Processed stream data based on the quantum scheme.
- quantumaudio.calculate(data, scheme=None, **kwargs)[source]
Estimates and Prints the resources required (number of qubits) according to a scheme.
- Parameters:
data (np.ndarray) – The data to encode.
scheme (str | Scheme | None) – Name of the encoding scheme or a scheme object to use. Defaults to “qpam”.
**kwargs – Additional keyword arguments passed to the scheme class.
- quantumaudio.decode_result(result, **kwargs)[source]
Decodes a quantum result object using the scheme it was encoded with.
- Parameters:
result (qiskit.result.Result | qiskit.primitives.PrimitiveResult | qiskit.primitives.SamplerPubResult) – Qiskit result object to decode.
**kwargs – Additional keyword arguments passed to the decoding method. Refer to the scheme’s decode_result method.
- Returns:
Decoded data from the result object.
- quantumaudio.decode_counts(counts, metadata, **kwargs)[source]
Decodes Quantum circuit measurement counts using metadata.
- Parameters:
counts (dict) – Counts dictionary to decode.
metadata (dict) – Metadata dictionary associated with the circuit that was executed.
**kwargs – Additional keyword arguments passed to the decoding method. Refer to the scheme’s decode_counts method.
- Returns:
Decoded data from the counts.