{"id":13657243,"url":"https://github.com/dxinteractive/ArduinoTapTempo","last_synced_at":"2025-04-24T01:31:42.758Z","repository":{"id":45502269,"uuid":"66767154","full_name":"dxinteractive/ArduinoTapTempo","owner":"dxinteractive","description":"An Arduino library that times consecutive button presses to calculate tempo / BPM. Corrects for missed beats and can reset phase with single taps.","archived":false,"fork":false,"pushed_at":"2023-11-07T12:14:42.000Z","size":21,"stargazers_count":60,"open_issues_count":7,"forks_count":12,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-08-02T05:06:52.330Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","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/dxinteractive.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-28T12:33:28.000Z","updated_at":"2024-07-29T20:17:23.000Z","dependencies_parsed_at":"2024-08-02T05:13:18.597Z","dependency_job_id":null,"html_url":"https://github.com/dxinteractive/ArduinoTapTempo","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxinteractive%2FArduinoTapTempo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxinteractive%2FArduinoTapTempo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxinteractive%2FArduinoTapTempo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxinteractive%2FArduinoTapTempo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dxinteractive","download_url":"https://codeload.github.com/dxinteractive/ArduinoTapTempo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223940887,"owners_count":17228915,"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","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":"2024-08-02T05:00:39.093Z","updated_at":"2024-11-10T10:30:56.725Z","avatar_url":"https://github.com/dxinteractive.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# ArduinoTapTempo\n\n![ArduinoTapTempo](https://user-images.githubusercontent.com/345320/50956952-1d32b300-1511-11e9-816a-cdcb1c9bf82e.jpg)\n\nAn Arduino library that times consecutive button presses to calculate a tempo. Corrects for missed beats and can reset phase with single taps.\n\nHow do you use it? Just tap a button in time with some music. This'll work out the tempo and keep track of it internally. Single taps will reset the phase so the bar begins from the start again. Mutiple taps will average out and give you a more accurate tempo reading. If you miss a tap this will detect it and prevent a tempo change.\n\n## How to install\n\nIn the Arduino IDE, go to Sketch \u003e Include libraries \u003e Manage libraries, and search for ArduinoTapTempo. You can also just use the files directly from the src folder.\n\nLook at the example in the examples folder for an idea on how to use it in your own projects. The source files are also heavily commented, so check those out if you want fine control of the library's behaviour.\n\n## How to use\n\n```c++\n// include the ArduinoTapTempo library\n#include \u003cArduinoTapTempo.h\u003e\n\n// define the pin you want to attach your tap button to\nconst int BUTTON_PIN = 5;\n\n// make an ArduinoTapTempo object\nArduinoTapTempo tapTempo;\n\nvoid setup() {\n  // begin serial so we can see the state of the tempo object through the serial monitor\n  Serial.begin(9600);\n\n  // setup your button as required by your project\n  pinMode(BUTTON_PIN, INPUT);\n  digitalWrite(BUTTON_PIN, HIGH);\n}\n\nvoid loop() {\n  // get the state of the button\n  boolean buttonDown = digitalRead(BUTTON_PIN) == LOW;\n  \n  // update ArduinoTapTempo\n  tapTempo.update(buttonDown);\n\n  // print out the beats per minute\n  Serial.print(\"bpm: \");\n  Serial.println(tapTempo.getBPM());\n}\n```\n\n## Basic methods\n\n```c++\nvoid update(bool buttonDown);\n```\nCall this each time you read your button state. Accepts a boolean indicating if the tap button is down.\n```c++\nfloat getBPM();\n```\nReturns the number of beats per minute.\n```c++\nunsigned long getBeatLength();\n```\nReturns the length of the beat in milliseconds.\n```c++\nfloat beatProgress();\n```\nReturns a float from 0.0 to 1.0 indicating the percent through the current beat.\n```c++\nbool onBeat();\n```\nReturns true if a beat has occured since the last update(). Not accurate enough for timing in music but useful for LEDs or other indicators. Note that this may return true in rapid succession while tapping and setting the tempo to a slightly slower rate than the current tempo, as the beat may occur and shortly afterward a new tap triggers a new beat.\n```c++\nunsigned long getLastTapTime();\n```\nReturns the time of the last tap in milliseconds since the program started.\n\n\n## Other methods and settings\n\n### Chains\n\nArduinoTapTempo calls groups of taps 'chains', and calculates the tempo by averaging a number of taps in a chain. Chains are active for a short while after each most recent tap, and while they are active they will count new taps as part of the current chain and average the timing of new taps together with previous taps. The chain is reset if a tap occurs once the chain is no longer active, and the tempo calculation will then be based off 2 or more taps in the new chain.\n\n```c++\nbool isChainActive();\n```\nReturns true if the current tap chain is still accepting new taps to fine tune the tempo.\n```c++\nvoid resetTapChain();\n```\nResets the current chain of taps and sets the start of the bar to the current time. This is called internally when a tap occurs and the current chain is no longer active\n```c++\nvoid setBeatsUntilChainReset(int beats);\n```\nThe current chain of taps will finish this many beats after the most recent tap. It accepts an integer greater than 1.\n```c++\nvoid setTotalTapValues(int total);\n```\nSets the maximum number of most recent taps that will be averaged out to calculate the tempo. Accepts int from 2 to 20. Increasing this allows the tempo to be more accurate compared to your tapping, but slower to respond to gradual changes in tapping speed. Response to different tapping speeds in new chains is unaffected.\n\n### Skipped tap detection\n\n ArduinoTapTempo has skipped tap detection turned on by default. If you miss tapping a beat but tap the next one it'll recognise that a tap was meant to occur and prevent the tempo from dropping abnormally. Skipped taps are detected when a tap duration is close to double the last tap duration.\n\n```c++\nvoid enableSkippedTapDetection();\n```\nTurns skipped tap detection on.\n```c++\nvoid disableSkippedTapDetection();\n```\nTurns skipped tap detection off.\n```c++\nvoid setSkippedTapThresholdLow(float threshold);\n```\nThis sets the lower threshold, how early your next tap can be after a missed tap. It accepts a float from 1.0 to 2.0.\n```c++\nvoid setSkippedTapThresholdHigh(float threshold);\n```\nThis sets the upper threshold, how late your next tap can be after a missed tap. accepts a float from 2.0 to 4.0.\n\n### Limits\n\n```c++\nvoid setMaxBeatLengthMS(unsigned long ms);\n```\nSets the maximum beat length permissible. If a tap attempts to set the beat length to anything greater than this value, the new tap will start a new chain and the tempo will remain unchanged.\n```c++\nvoid setMinBeatLengthMS(unsigned long ms);\n```\nSets the minimum beat length permissible. If the average tap length is less than this value, then this value will be used instead.\n```c++\nvoid setMaxBPM(float bpm);\n```\nSets the minimum beats per minute permissible. This is another way of setting the minimum beat length.\n```c++\nvoid setMinBPM(float bpm);\n```\nSets the maximum beats per minute permissible. This is another way of setting the maximum beat length.\n\n\n## License\n\nLicensed under the MIT License (MIT)\n\nCopyright (c) 2016, Damien Clarke\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdxinteractive%2FArduinoTapTempo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdxinteractive%2FArduinoTapTempo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdxinteractive%2FArduinoTapTempo/lists"}