{"id":22449896,"url":"https://github.com/turskyi/drummachine","last_synced_at":"2026-04-28T20:33:52.737Z","repository":{"id":133703011,"uuid":"308981604","full_name":"Turskyi/drummachine","owner":"Turskyi","description":"A pure Kotlin project showcasing class usage, JUnit testing, and coroutine-based audio playback. Designed for JVM, not Android.","archived":false,"fork":false,"pushed_at":"2024-07-26T02:52:15.000Z","size":1486,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T12:16:26.635Z","etag":null,"topics":["audio-playback","concurrent-programming","junit","jvm","kotlin","kotlin-coroutines","kotlin-example","unit-testing"],"latest_commit_sha":null,"homepage":"https://github.com/Turskyi/drummachine","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Turskyi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-10-31T22:18:41.000Z","updated_at":"2024-07-26T02:52:03.000Z","dependencies_parsed_at":"2024-07-26T03:48:28.395Z","dependency_job_id":"d311b3ef-b4d3-49fa-881c-ec060d9874ef","html_url":"https://github.com/Turskyi/drummachine","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Turskyi/drummachine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Turskyi%2Fdrummachine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Turskyi%2Fdrummachine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Turskyi%2Fdrummachine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Turskyi%2Fdrummachine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Turskyi","download_url":"https://codeload.github.com/Turskyi/drummachine/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Turskyi%2Fdrummachine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32398765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"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-playback","concurrent-programming","junit","jvm","kotlin","kotlin-coroutines","kotlin-example","unit-testing"],"created_at":"2024-12-06T05:12:23.706Z","updated_at":"2026-04-28T20:33:52.718Z","avatar_url":"https://github.com/Turskyi.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg)](https://stand-with-ukraine.pp.ua)\n\u003cimg alt=\"GitHub commit activity\" src=\"https://img.shields.io/github/commit-activity/m/Turskyi/drummachine\"\u003e\n\n# Pure Kotlin Project\n\nThis is a pure Kotlin project demonstrating the use of Kotlin features such as\nclasses, unit testing with JUnit, and coroutines for concurrent programming.\nThe project is not an Android project and runs on the JVM.\n\n## Project Structure\n\nThe project consists of three main components:\n\n1. **Totaller Class**: A simple class that adds numbers to a total.\n2. **TotallerTest Class**: A unit test class for the Totaller class using JUnit.\n3. **Main** Function with Coroutines: Demonstrates the use of Kotlin\n4. coroutines and plays audio files.\n\n## Totaller Class\n\nThis class maintains a running total of numbers added to it.\n\n```kotlin\nclass Totaller(var total: Int = 0) {\n    fun add(num: Int): Int {\n        total += num\n        return total\n    }\n}\n```\n\n## TotallerTest Class\n\nThis class tests the functionality of the Totaller class.\n\n```kotlin\nimport org.junit.jupiter.api.Assertions\nimport org.junit.jupiter.api.Test\n\nclass TotallerTest {\n    @Test\n    fun shouldBeAbleToAdd3And4() {\n        val totaller = Totaller()\n        Assertions.assertEquals(3, totaller.add(3))\n        Assertions.assertEquals(7, totaller.add(4))\n        Assertions.assertEquals(7, totaller.total)\n    }\n}\n```\n\n## Main Function with Coroutines\n\nThis demonstrates the use of Kotlin coroutines to play audio beats concurrently.\n\n```kotlin\nimport kotlinx.coroutines.delay\nimport kotlinx.coroutines.launch\nimport kotlinx.coroutines.runBlocking\nimport java.io.File\nimport javax.sound.sampled.AudioSystem\n\nsuspend fun playBeats(beats: String, file: String) {\n    val parts = beats.split(\"x\")\n    var count = 0\n    for (part in parts) {\n        count += part.length + 1\n        if (part == \"\") {\n            playSound(file)\n        } else {\n            delay(100 * (part.length + 1L))\n            if (count \u003c beats.length) {\n                playSound(file)\n            }\n        }\n    }\n}\n\nfun playSound(file: String) {\n    val clip = AudioSystem.getClip()\n    val audioInputStream = AudioSystem.getAudioInputStream(File(file))\n    clip.open(audioInputStream)\n    clip.start()\n}\n\nfun main() {\n    runBlocking {\n        launch {\n            playBeats(\"x-x-x-x-x-x\", \"audio/toms.aiff\")\n        }\n        launch {\n            playBeats(\"x----x----x\", \"audio/crash_cymbal.aiff\")\n        }\n        playBeats(\"--x--x---x-\", \"audio/high_hat.aiff\")\n    }\n}\n```\n\n## How to Run the Project\n\n### Prerequisites\n\n- JDK 1.8 or higher\n- Gradle\n\n## Running the Tests\n\nTo run the unit tests, use the following command:\n\n```sh\n./gradlew test\n```\n\n## Notes\n\n- Ensure you have the required audio files (toms.aiff, crash_cymbal.aiff,\n  high_hat.aiff) in the audio directory relative to the project root.\n- This project uses kotlinx.coroutines for coroutine support and\n  javax.sound.sampled for audio playback.\n\n## Conclusion\n\nThis project showcases the simplicity and power of Kotlin for JVM applications.\nIt demonstrates unit testing with JUnit and concurrent programming with\ncoroutines, making it a great example for learning and reference.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturskyi%2Fdrummachine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fturskyi%2Fdrummachine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturskyi%2Fdrummachine/lists"}