Miscellaneous functions
=======================

.. currentmodule:: pitchmeld

.. function:: lin2db(value:float) -> float

    Convert a linear amplitude value to a decibel value.

    :arg value: on a linear scale.

    :return:
        - `float` - The value on a decibel scale.


.. function:: db2lin(value:float) -> float

    Convert a decibel value to a linear amplitude value.

    :arg value: on a decibel scale.

    :return:
        - `float` - The value on a linear scale.


Multiprocessing
---------------

When using multiprocessing, you need to use the 'spawn' start method instead of the 'fork' start method.

.. code-block:: python

    import multiprocessing
    multiprocessing.set_start_method('spawn', force=True)


Slow connection
---------------

In case you are on a slow connection, you can increase the timeout for the connection to the server.

.. code-block:: shell

    export PITCHMELD_TIMEOUT=20
    python -c "import pitchmeld; print(pitchmeld.__version__)"


Exit On Interrupt (EOI)
-----------------------

Many C/C++ written python modules won't react to a ctrl-c interruption (or equivalent).
The C/C++ part will first finish its execution and the python part will then handle any ctrl-c.

Calling ``pitchmeld.eoi()`` after loading the module

.. code-block:: python

    import pitchmeld
    pitchmeld.eoi()

allows any ctrl-c to kill the C/C++ part immediately.

You can deactivate ``eoi()`` with ``pitchmeld.uneoi()``

By default, this uncommon behavior is disabled.
