All Projects → iver56 → clap-detection

iver56 / clap-detection

Licence: MIT license
Simple clap rhythm detection on Raspberry Pi using Csound and Python. Toy example.

Programming Languages

python
139335 projects - #7 most used programming language
Csound Document
19 projects

Projects that are alternatives of or similar to clap-detection

AXI PCB defect detection
This repo contains data pre-processing, classification and defect detection methodologies for images from Advance XRay Inspection from multi-layer PCB boards. Proprietary AXI image dataset is not included in this repo. Users can use their own datasets on top of the OOP data extraction layer and neural network models implemented here.
Stars: ✭ 31 (+6.9%)
Mutual labels:  detection
klask
Automatically create GUI applications from clap3 apps
Stars: ✭ 329 (+1034.48%)
Mutual labels:  clap
camera.ui
NVR like user Interface for RTSP capable cameras
Stars: ✭ 99 (+241.38%)
Mutual labels:  detection
cflow-ad
Official PyTorch code for WACV 2022 paper "CFLOW-AD: Real-Time Unsupervised Anomaly Detection with Localization via Conditional Normalizing Flows"
Stars: ✭ 138 (+375.86%)
Mutual labels:  detection
MOSFiT
Modular Open Source Fitter for Transients
Stars: ✭ 27 (-6.9%)
Mutual labels:  transients
UBA
UEBA Solution for Insider Security. This repo is archived. Thanks!
Stars: ✭ 36 (+24.14%)
Mutual labels:  detection
detect-gpu
Classifies GPUs based on their 3D rendering benchmark score allowing the developer to provide sensible default settings for graphically intensive applications.
Stars: ✭ 749 (+2482.76%)
Mutual labels:  detection
Automata
Automatic detection engineering technical state compliance
Stars: ✭ 33 (+13.79%)
Mutual labels:  detection
SpatiallyAdaptiveInference-Detection
Spatially Adaptive Inference with Stochastic Feature Sampling and Interpolation, ECCV 2020 Oral
Stars: ✭ 55 (+89.66%)
Mutual labels:  detection
eewids
Easily Expandable Wireless Intrusion Detection System
Stars: ✭ 25 (-13.79%)
Mutual labels:  detection
etiketai
Etiketai is an online tool designed to label images, useful for training AI models
Stars: ✭ 63 (+117.24%)
Mutual labels:  detection
Object-Detection-And-Tracking
Target detection in the first frame and Tracking target by SiamRPN.
Stars: ✭ 33 (+13.79%)
Mutual labels:  detection
watsor
Object detection for video surveillance
Stars: ✭ 203 (+600%)
Mutual labels:  detection
Scanr
Detect x86 shellcode in files and traffic.
Stars: ✭ 16 (-44.83%)
Mutual labels:  detection
LSCDetection
Data Sets and Models for Evaluation of Lexical Semantic Change Detection
Stars: ✭ 17 (-41.38%)
Mutual labels:  detection
DecisionAmbiguityRecognition
Deep learning AI, that recognizes when are people uncertain
Stars: ✭ 16 (-44.83%)
Mutual labels:  detection
image-ndd-lsh
Near-duplicate image detection using Locality Sensitive Hashing
Stars: ✭ 42 (+44.83%)
Mutual labels:  detection
music-id
🚀 Music ID for Twitch (TwitchMusicID) is a Chatbot which automatically identifies music in the background of Twitch Streams, VODs, and Clips.
Stars: ✭ 49 (+68.97%)
Mutual labels:  detection
farm-animal-tracking
Farm Animal Tracking (FAT)
Stars: ✭ 19 (-34.48%)
Mutual labels:  detection
yolov5-deepsort-tensorrt
A c++ implementation of yolov5 and deepsort
Stars: ✭ 207 (+613.79%)
Mutual labels:  detection

clap-detection

Clap sequence/rhythm/pattern detection on Raspberry Pi using Csound and Python. This was made as a quick experiment. Don't use it for anything serious.

Why

Some examples of things you can have your Raspberry Pi do when a matching clap sequence is detected:

  • Dim the lights and start playing smooth jazz music
  • Turn on/off the TV
  • Broadcast a yo
  • Project the weather forecast on the wall

How

Csound takes in audio from a microphone live and checks the audio for transients. Whenever a transient (rapidly ascending amplitude) is detected, Csound will notice ClapAnalyzer, a class implemented in Python. ClapAnalyzer looks for a specific rhytmic clap sequence. ClapAnalyzer will notice all listeners whenever a matching clap sequence is detected.

Setup

  • Install Python 2.7
  • Install Csound

Usage

Python

Let's use the following rhythmic sequence as example:

clap

The note lengths are 1/4, 1/8, 1/8, 1/4, 1/4, so we set the note_lengths parameter to [0.25, 0.125, 0.125, 0.25, 0.25].

from clap import ClapAnalyzer

clap_analyzer = ClapAnalyzer(note_lengths=[0.25, 0.125, 0.125, 0.25, 0.25])

def clap_sequence_detected():
  print 'Matching clap sequence detected!'

clap_analyzer.on_clap_sequence(clap_sequence_detected)

# You can now start calling clap_analyzer.clap(time)

Basically, this is the python code that is used in clap.csd

Csound

Start csound from your command line. By default, the csound instrument will get live audio input:

csound clap.csd

If you want to quickly analyze a wav file, you can use that file instead of live audio input. This is good for testing:

csound clap.csd -i myfile.wav

PS: The file must be mono, not stereo, for this to work. And if your sound file is long, then you should modify the amount of time the Csound instrument stays alive accordingly, in order to analyze the whole file.

Troubleshooting

"no module named clap"

Try adding the directory with the python module dynamically:

pyruni "import sys, os"
pyruni "sys.path.append('/path/to/clap-detection')"

Edit /path/to/clap-detection to the place where clap.py is located.

"Segmentation fault" or "Unable to set number of channels on soundcard"

Check if your input device is mono or stereo. If it is mono (i.e. has only one channel), then you should set nchnls = 1 in your csound file, and you should use the in opcode instead of ins. If your input device is stereo, then you should set nchnls = 2.

ALSA and/or PortAudio warnings

Use the -+rtaudio=alsa option

Stuttering/crackling/noise/"Buffer underrun"

Let Csound use a large buffer in both software and hardware. In other word, use the following options: -b2048 -B2048

Input device error

Run arecord -l and check the list of sound cards and subdevices that are available. If you, for example, want to use card 1, subdevice 0, then you should use the following csound option: -i adc:hw:1,0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].