Skip to main content

A real-time audio recording & analyzing library

Project description

rcaudio : A Realtime Audio Recording & Analyzing Library

Introduction

rcaudio is a real-time audio analysis library that allows you to simply record audio through a microphone and analyze.

It supports real-time analysis of :

  • The raw audio data
  • Volume
  • Beat Information
  • DIY method extraction function

For chinese documentation : 中文文档

Installation

pip install rcaudio

Usage

CoreRecorder

CoreRecorder is used to fetch raw data. When started, the audio data will be stored in the CoreRecorder.buffer.

from rcaudio import CoreRecorder
CR = CoreRecorder(
        time = 10, #How much time to record
        sr = 1000 #sample rate
        )
CR.start()
while True:
    if not CR.buffer.empty():
        x = CR.buffer.get()
        print('*'*int(abs(x)))

SimpleRecorder

In most cases, we use SimpleRecorder. For efficiency consideration, the SimpleRecorder should only be instantiated once.

This class can register several Analyzer.

When the function start() called, It will begin to record through microphone, and refresh the status of all the Analyzer

Analyzers

All class extended from BaseAnalyzer can be registered into SimpleRecorder. For example VolumeAnalyzer can get the current volume of the microphone.

import time
from rcaudio import SimpleRecorder,VolumeAnalyzer

SR = SimpleRecorder()
VA = VolumeAnalyzer(rec_time = 1)
SR.register(VA)
SR.start()
while True:
    print("VOLUME : ",VA.get_volume())
    time.sleep(1)

And beat analyzer can predict the beats from the music. (However, there will be some delay.)

SR = SimpleRecorder(sr = 20000)
BA = BeatAnalyzer(rec_time = 15, initial_bpm = 120, smooth_ratio = .8)
SR.register(BA)
SR.start()
while True:
    print(BA.block_until_next_beat())

A FeatureAnalyzer can use to generate all user defined acoustic features. Just override the data_process function. (Current function are the calculation of the Zero Crossing Rate.

SR = SimpleRecorder(sr = 1000)
FA = FeatureAnalyzer(refresh_time = 1)
SR.register(FA)
SR.start()
cpos = 0
while True:
	if len(FA.result) > cpos:
		print(FA.result[cpos])
		cpos += 1
	time.sleep(.01)

Some notes

Most function has the time delay about 1-2 seconds. I did lot effort to let the BeatAnalyzer looked as it is real-time. However, for the FeatureAnalyzer, if the feature extraction function are too slow compare to the microphone recording, the dalay may become huge. Decrease the sample rates would be a solution, but better solution would be DIY a analyzer yourself.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rcaudio-0.0.3.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

rcaudio-0.0.3-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file rcaudio-0.0.3.tar.gz.

File metadata

  • Download URL: rcaudio-0.0.3.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

File hashes

Hashes for rcaudio-0.0.3.tar.gz
Algorithm Hash digest
SHA256 229d0f154e2773c9a1730c9862fb0b052719b751bc851f3e8753d131bc21d88d
MD5 385015a077376c0a285d1fa28c9b1e40
BLAKE2b-256 a78fd7a38f324098d8c05cc71205c28575581d1af7fef1b3d9eaa191aab05cbf

See more details on using hashes here.

File details

Details for the file rcaudio-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: rcaudio-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

File hashes

Hashes for rcaudio-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a82c0d07ae0e13486ba61f9989b1d8add0715edc244e0193de419542e3321e34
MD5 785c391145c6cd895e8dc972b59c6706
BLAKE2b-256 600da5093a86e2a9b92737ac2df8243ab9253b2a1a7e6870d1a2f75dc060701d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page