{"id":13679884,"url":"https://github.com/iver56/clap-detection","last_synced_at":"2026-02-25T07:13:57.442Z","repository":{"id":72954187,"uuid":"42336239","full_name":"iver56/clap-detection","owner":"iver56","description":"Simple clap rhythm detection on Raspberry Pi using Csound and Python. Toy example.","archived":false,"fork":false,"pushed_at":"2019-05-18T10:51:51.000Z","size":16,"stargazers_count":32,"open_issues_count":4,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-16T06:38:34.603Z","etag":null,"topics":["audio","clap","csound","detection","python","raspberry-pi","rhythm","transients"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iver56.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-09-11T23:07:35.000Z","updated_at":"2024-12-20T18:11:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"b97c46d3-8536-4b8a-80e0-13bd4c693d98","html_url":"https://github.com/iver56/clap-detection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iver56/clap-detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iver56%2Fclap-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iver56%2Fclap-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iver56%2Fclap-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iver56%2Fclap-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iver56","download_url":"https://codeload.github.com/iver56/clap-detection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iver56%2Fclap-detection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29813721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T05:36:42.804Z","status":"ssl_error","status_checked_at":"2026-02-25T05:36:31.934Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","clap","csound","detection","python","raspberry-pi","rhythm","transients"],"created_at":"2024-08-02T13:01:10.672Z","updated_at":"2026-02-25T07:13:57.425Z","avatar_url":"https://github.com/iver56.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# clap-detection\nClap 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.\n\n## Why\n\nSome examples of things you can have your Raspberry Pi do when a matching clap sequence is detected:\n\n* Dim the lights and start playing smooth jazz music\n* Turn on/off the TV\n* Broadcast a yo\n* Project the weather forecast on the wall\n\n## How\n\nCsound 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.\n\n## Setup\n\n* Install Python 2.7\n* Install Csound\n\n## Usage\n\n### Python\n\nLet's use the following rhythmic sequence as example:\n\n![clap](https://cloud.githubusercontent.com/assets/1470603/9700905/a6de8d6a-5415-11e5-81f6-f81e4034a939.png)\n\nThe 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].\n\n```python\nfrom clap import ClapAnalyzer\n\nclap_analyzer = ClapAnalyzer(note_lengths=[0.25, 0.125, 0.125, 0.25, 0.25])\n\ndef clap_sequence_detected():\n  print 'Matching clap sequence detected!'\n\nclap_analyzer.on_clap_sequence(clap_sequence_detected)\n\n# You can now start calling clap_analyzer.clap(time)\n```\n\nBasically, this is the python code that is used in `clap.csd`\n\n### Csound\n\nStart csound from your command line. By default, the csound instrument will get live audio input:\n\n`csound clap.csd`\n\nIf you want to quickly analyze a wav file, you can use that file instead of live audio input. This is good for testing:\n\n`csound clap.csd -i myfile.wav`\n\nPS: 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.\n\n## Troubleshooting\n\n### \"no module named clap\"\n\nTry adding the directory with the python module dynamically:\n\n```\npyruni \"import sys, os\"\npyruni \"sys.path.append('/path/to/clap-detection')\"\n```\n\nEdit `/path/to/clap-detection` to the place where clap.py is located.\n\n### \"Segmentation fault\" or \"Unable to set number of channels on soundcard\"\n\nCheck 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`.\n\n### ALSA and/or PortAudio warnings\n\nUse the `-+rtaudio=alsa` option\n\n### Stuttering/crackling/noise/\"Buffer underrun\"\n\nLet Csound use a large buffer in both software and hardware. In other word, use the following options: `-b2048 -B2048`\n\n### Input device error\n\nRun `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`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiver56%2Fclap-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiver56%2Fclap-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiver56%2Fclap-detection/lists"}