Audio kit for Volux
Project description
Voluxaudio
☠️ EXPERIMENTAL: - Beware all ye who enter here ☠️
Todo List
- Get simple
VoluxAudioStream
class working - Make
VoluxAudioStream
class highly configurable - Add basic example to documentation
- Add basic documentation
- Add more examples to documentation
VoluxAudioStream Example
Summary
Draws a bar in your terminal based on a simple approximation of the amplitude (i.e. loudness) of the sound coming from your system's default recording device (microphone or computer/desktop audio).
Example Code
from voluxaudio import VoluxAudioStream
import numpy as np
from time import sleep
# call this every time new samples gathered
def on_data(*args, **kwargs):
return
# open an audio stream with buffering enabled
with VoluxAudioStream(
on_data=on_data,
chunk_size=2048,
channels=2,
buffer_size_in_seconds=2,
) as audio_stream:
# repeat until script stopped
while True:
# weakly approximate amplitude
samples = audio_stream.buffer
sample_count = len(samples)
samples_per_channel = np.swapaxes(samples, 0, 1)
L_channel_e = np.average(np.abs(samples_per_channel[0][-2048:])) / sample_count
R_channel_e = np.average(np.abs(samples_per_channel[1][-2048:])) / sample_count
e = (L_channel_e + R_channel_e) / 2
# print bar
print(f"{e:<3.3f} " + int(e*100) * '|')
# wait ~50ms
sleep(1 / 20)
Information
- Please note that this is only a simple example and much more complex audio processing is easily achievable.
- A bar is printed every 50ms that gets longer/shorter depending on the approximated amplitude.
- Whether your system volume (not amplitude) affects results depends on your system, so it's best to test pausing/unpausing your music if you're using computer/desktop audio instead of a microphone.
- This example uses buffering as a
buffer_size_in_seconds
value is specified.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
voluxaudio-0.8.0.tar.gz
(4.7 kB
view hashes)
Built Distribution
Close
Hashes for voluxaudio-0.8.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dfe184e26f50014a147bf2abc4432c0323e5df70bff915e60a3f232cb1b65e6 |
|
MD5 | 5899aa47f0b2edb0ddb568f133041a25 |
|
BLAKE2b-256 | 2a7c599d60dea0ed9ae544c6fe9563b8dcd2edadf1a43b593ee3536ba0a06dac |