{"id":23444101,"url":"https://github.com/sevagh/drum_machine","last_synced_at":"2025-10-28T08:47:23.900Z","repository":{"id":82225441,"uuid":"275405670","full_name":"sevagh/drum_machine","owner":"sevagh","description":"create click tracks from harmonixset annotations on the fly with libmetro, libsoundio, and stk","archived":false,"fork":false,"pushed_at":"2020-06-28T15:19:31.000Z","size":2013,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T01:01:52.622Z","etag":null,"topics":["ast","beats","click-track","lexer-parser","metronome","music-information-retrieval","rhythm","tokenizer"],"latest_commit_sha":null,"homepage":"","language":"Go","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/sevagh.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":"2020-06-27T15:59:26.000Z","updated_at":"2023-03-13T07:25:35.000Z","dependencies_parsed_at":"2023-04-05T10:46:34.323Z","dependency_job_id":null,"html_url":"https://github.com/sevagh/drum_machine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sevagh%2Fdrum_machine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sevagh%2Fdrum_machine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sevagh%2Fdrum_machine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sevagh%2Fdrum_machine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sevagh","download_url":"https://codeload.github.com/sevagh/drum_machine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125570,"owners_count":21051765,"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":["ast","beats","click-track","lexer-parser","metronome","music-information-retrieval","rhythm","tokenizer"],"created_at":"2024-12-23T18:26:42.911Z","updated_at":"2025-10-28T08:47:23.809Z","avatar_url":"https://github.com/sevagh.png","language":"Go","readme":"Pipe [harmonixset](https://github.com/urinieto/harmonixset) beat txt files through drum_machine to listen to a clicktrack.\n\nThe file format drum_machine supports are the beat annotations here: [harmonixset/datasets/beats_and_downbeats](https://github.com/urinieto/harmonixset/tree/master/dataset/beats_and_downbeats)\n\nThe clicktrack is generated using [libmetro](https://github.com/sevagh/libmetro). The beat txt files are parsed using a handwritten tokenizer/lexer and parser, based on [this tutorial](https://blog.gopheracademy.com/advent-2014/parsers-lexers/). drum_machine is fuzz tested with the entire harmonixset dataset as a corpus, and fuzzing is done with [go-fuzz](https://github.com/dvyukov/go-fuzz) ([tutorial](https://dgraph.io/blog/post/continuous-fuzzing-with-go/)). Run fuzz test with `./fuzz_test.sh`.\n\n### Mapping harmonix to libmetro\n\nlibmetro provides the following constructs:\n\n* _beats_ are represented with _note_ objects, which are wrappers around a vector of floats generated from Stk. libmetro is more flexible but the C wrapper and use in drum_machine are limited to the MIDI Drum instrument, and 2 'timbres' of beats\n* _bars_ are represented with _measure_ objects, which are collections of a sequence of _notes_ (can be padded with silence)\n* the _tempo_ of the song is configured on the _metronome_ object, which can register a sequence of _measures_ to loop through\n\nAlthough the result is not mind-blowingly exciting given the tempo and beat structure of pop songs is stable, drum_machine still a fun combination of several projects.\n\n### Compile\n\nGetting `drum_machine` built is not straightforward. You have to statically compile and install several C++ libraries from scratch. They must be compiled statically Go + cgo doesn't care about your configured dynamic library paths.\n\n* https://github.com/andrewrk/libsoundio\n\nAfter ensuring you have the correct dependencies (I've tested it only on Linux with ALSA, pulseaudio, and JACK libraries installed):\n\n```\nlibsoundio $ mkdir -p build \u0026\u0026 cd build \u0026\u0026 cmake .. \u0026\u0026 make \u0026\u0026 sudo make install\n```\n\n* https://github.com/thestk/stk\n\nI suggest you copy `rawwaves` to `~/rawwaves` and compile this way:\n\n```\nstk $ autoconf\nstk $ ./configure\nstk $ ./configure RAWWAVE_PATH='$(HOME)/rawwaves/' BUILD_STATIC='yes'\nstk $ cd src \u0026\u0026 make \u0026\u0026 sudo make install\n\n# manually install the .a file, it's not in the makefile i believe\nstk $ sudo cp libstk.a /usr/local/lib/libstk.a\n```\n\n* https://github.com/sevagh/libmetro\n\nLibmetro is a C++ library but it has a minimal C wrapper to work with cgo.\n\n```\nlibmetro $ mkdir -p build \u0026\u0026 cd build \u0026\u0026 cmake .. -DBUILD_STATIC=ON \u0026\u0026 make \u0026\u0026 sudo make install\n```\n\nFinally, compile this project:\n\n```\ndrum_machine $ go build .\n```\n\ncgo configuration is:\n\n```\n// #cgo LDFLAGS: /usr/local/lib/libmetro.a /usr/local/lib64/libsoundio.a /usr/local/lib/libstk.a -lstdc++ -lasound -lpulse -ljack -lm\n// #include \u003clibmetro/cmetro.h\u003e\nimport \"C\"\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsevagh%2Fdrum_machine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsevagh%2Fdrum_machine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsevagh%2Fdrum_machine/lists"}