{"id":31913120,"url":"https://github.com/stasilo/beatdetector","last_synced_at":"2025-10-13T18:27:32.828Z","repository":{"id":31982106,"uuid":"35552353","full_name":"stasilo/BeatDetector","owner":"stasilo","description":"A simple beat detector for visualising sound on the web. Also has limited BPM-detection support. ","archived":false,"fork":false,"pushed_at":"2015-12-25T16:03:57.000Z","size":180,"stargazers_count":39,"open_issues_count":3,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-03-01T21:16:28.311Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/stasilo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-13T14:01:25.000Z","updated_at":"2022-11-10T17:53:50.000Z","dependencies_parsed_at":"2022-09-02T23:41:04.787Z","dependency_job_id":null,"html_url":"https://github.com/stasilo/BeatDetector","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/stasilo/BeatDetector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stasilo%2FBeatDetector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stasilo%2FBeatDetector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stasilo%2FBeatDetector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stasilo%2FBeatDetector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stasilo","download_url":"https://codeload.github.com/stasilo/BeatDetector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stasilo%2FBeatDetector/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016584,"owners_count":26085852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-10-13T18:27:30.850Z","updated_at":"2025-10-13T18:27:32.814Z","avatar_url":"https://github.com/stasilo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"BeatDetector.js\n=============\n ---\nA pretty rudimentary but working beat detector. Built using the Web audio api. Based on comparing average shift in freq amplitudes in a current sample to a sample history. Catches heavy beat hits pretty accurately (techno, house, hip hop, that kinda stuff)\n \nBPM calculation funcionality mostly for kicks: don't use it for anything exact, there are far better options. \n \nBased on the frequency select-algorithm (the web audio api does fft-calculations for us) but without band splitting from: \nhttp://archive.gamedev.net/archive/reference/programming/features/beatdetection/index.html \n\n####  Example: \n```\t\nvar song = new stasilo.BeatDetector({sens: \t\t\t\t5.0,\n\t\t\t\t\t\t \t\t\t visualizerFFTSize: 256, \n\t\t\t\t\t\t\t\t\t analyserFFTSize:   256, \n\t\t\t\t\t\t\t\t\t passFreq:          600,\n\t\t\t\t\t\t\t\t\t url:               \"file.mp3\" } ); \n```\n\n### Usage\nTo get frequency data for drawing bars and what not:\n\n```\t\nsong.getAudioFreqData();\n```\n\nThis returns an array of visualizerFFTSize / 2 data values corresponding to frequency amplitudes.\n\n### To detect a beat hit\n\nCall \n```\t\nsong.isOnBeat()\n```\nfrom the render loop of your script. Returns true if song is on a beat. \n \nFor everything else, see the source. \n\n\nSettings\n----------\n\u003e **sens:**\n\u003e Sensitivity of the algorithm. A value between 1 and 16 (1 - low threshold, 16 - high treshold) should do it. Requires a bit of trail and error tweaking for the sweet spot. \n\u003e \u003e This setting is required.\n\n\u003e **url:**\n\u003e Url to audio file.\n\u003e \u003e  Detection defaults to microphone if no url is supplied.\n\u003e \n\u003e **visualizerFFTSize:**\n\u003e Size of fft calculations for visualizations.\nMust be a power of two (2^7 = 128, 2^8 = 256, 2^9 = 512, ...)\n\u003e\u003e Default value: 256\n\n\u003e **analyserFFTSize:**\n\u003e Size of fft calculation for the algorithm\nMust be a power of two (2^7 = 128, 2^8 = 256, 2^9 = 512, ...)\n\u003e\u003e Default value: 256\n\n\u003e **passFreq:**\n\u003e Float. If supplied, passes audio through a bandpass filter with a peak at this frequency before passing it on to the algorithm. Suitable for example when a song has a loud treble/mid section and you'd like to detect bass drum beats, in which case a bandpass at 100-800Hz could help you out. \n\u003e\u003eFreq chart for common instruments: \nhttp://www.independentrecording.net/irn/resources/freqchart/main_display.htm\n\n\u003e\u003e Default value: off\n\n\u003e**loop:**\t\t\t\t\t\n\u003e Boolean. Whether to loop the sound or not. \n\u003e \u003eDefault: false. \n\n\u003e**playbackFinished:**\n\u003e A function called at the end of playback.\n\n\u003e**progress(obj):**\t\t\n\u003e A callback run while sound is downloading from url. An object of {percent: value, complete: boolean} is passed as an argument. Useful for when loading sounds through ajax. \n\n\n\nBrowser support\n-------------------\nPlease see: http://caniuse.com/#feat=audio-api\n\t\n\n\n\nContact\n-------------------\nJakob Stasilowicz made this. Contact me through kontakt [at] stasilo.se or http:///www.stasilo.se.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstasilo%2Fbeatdetector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstasilo%2Fbeatdetector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstasilo%2Fbeatdetector/lists"}