Code Monkey home page Code Monkey logo

rpi-audio-levels's Introduction

rpi-audio-levels

Description

Python binding allowing to retrieve audio levels by frequency bands given audio samples, on a raspberry pi (aka power spectrum). It uses the GPU FFT lib (see http://www.aholme.co.uk/GPU_FFT/Main.htm).

I compared implementations using cython and ctypes, and the ctypes solution was slower (overhead due to the input data transformation for the C call).

In my case it's 7 times faster than using pure python with Numpy.

Dependencies

The GPU FFT lib sources which can be found here http://www.aholme.co.uk/GPU_FFT/Main.htm. It is also directly in raspbian. You will also need Cython.

Installation

$ python setup.py build_ext --inplace

This generates the rpi_audio_levels.so, be sure to add its directory to the PYTHONPATH (or install it using sudo python setup.py install instead of the above command).

Usage

from rpi_audio_levels import AudioLevels
DATA_SIZE = 11  # -> we will give chunks of 2**11 audio samples
BANDS_COUNT = 6  # -> we will give 6 ranges of band indexes for each computation
# Preliminary call to prepare things
audio_levels = AudioLevels(DATA_SIZE, BANDS_COUNT)

# example of 6 arbitrary frequency bands. Indexes must be between 0 and 2**(DATA_SIZE - 1)
bands_indexes = [[0,100], [100,200], [200,600], [600,700], [700,800], [800,1024]]

# Then retrieve audio levels each time you have new data
levels = audio_levels.compute(data, bands_indexes)
# data must be an numpy array of 2**DATA_SIZE real data with float dtype (np.float32), with only 1 dimmension.

rpi-audio-levels's People

Contributors

colin-guyon avatar tom-slick avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.