{"id":20400490,"url":"https://github.com/ppekko/tdaw","last_synced_at":"2025-04-12T13:52:08.223Z","repository":{"id":154636893,"uuid":"489836280","full_name":"ppekko/tdaw","owner":"ppekko","description":"A tiny, header only, easy to use, cross-platform, minimal overhead audio wrapper, tailored for the demo scene.","archived":false,"fork":false,"pushed_at":"2024-05-27T22:41:25.000Z","size":167,"stargazers_count":19,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-26T08:37:06.198Z","etag":null,"topics":["aplay","audio","demoscene","easy-to-use","fast","header-only","music","portaudio","small","sound"],"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/ppekko.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":"2022-05-08T03:30:29.000Z","updated_at":"2024-10-10T21:28:56.000Z","dependencies_parsed_at":"2024-02-23T21:28:34.803Z","dependency_job_id":"a700592c-1b6f-4726-bb0c-bba7718a4e51","html_url":"https://github.com/ppekko/tdaw","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/ppekko%2Ftdaw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppekko%2Ftdaw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppekko%2Ftdaw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppekko%2Ftdaw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ppekko","download_url":"https://codeload.github.com/ppekko/tdaw/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248576036,"owners_count":21127310,"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":["aplay","audio","demoscene","easy-to-use","fast","header-only","music","portaudio","small","sound"],"created_at":"2024-11-15T04:40:44.922Z","updated_at":"2025-04-12T13:52:08.202Z","avatar_url":"https://github.com/ppekko.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TDAW\n\nA tiny, header only, easy to use, minimal overhead, cross-platform audio wrapper, tailored for the demo scene.\n\nThis header enables you to do shader-like sound programming (similar to that of [ShaderToy](https://shadertoy.com \"ShaderToy\")) inside of C/C++ incredibly easily.\n\n**Keep in mind that the demo projects sizes may vary on your machine, and additionally *if you incorporate them into your project, chances are it will be smaller due to compiler optimisations and better packing compression with larger files***\n\n\u003cins\u003eFor actual sizes, refer to the table inside the demo folder's readme.\u003c/ins\u003e\n\n\n# Usage\n\nBefore including TDAW, you must first `#define TDAW_IMPLEMENTATION` in *one* C/C++ file.\n\nYou then must select a backend, the following are:\n\n- PortAudio `#define TDAW_BACKEND_PORTAUDIO`\n- ALSA `#define TDAW_BACKEND_ALSA` (linux only)\n- aplay `#define TDAW_BACKEND_APLAY` (linux only)\n\nThere are also features you can activate by defining the following lines:\n\n```c\n#define TDAW_USERDATA // Allow user data to be passed to your stream\n#define TDAW_DEBUGTEXT // Output debug text to console\n#define TDAW_MULTITHREAD // Enables multithreaded playback\n```\nThese are also detailed in the header itself.\n\n## Creating a function to render\n\nYour function must follow this format. `TDAW_CHANNEL` is a struct with 2 floats for both audio channels.\n```c\nTDAW_CHANNEL test(float time, float samp)\n{\n  TDAW_CHANNEL out;\n  //code here\n  return out;\n}\n```\nIf you have enabled `TDAW_USERDATA`, an extra `void* userdata` is required as an argument, allowing you to pass data in.\n\n# Live rendering on a single threads\n\nInitialise TDAW with a refernce to a TDAW_PIP and your \"frames per buffer\" size (FPB). If your audio lags, try increasing the FPB. Lower FPB results in faster output at the cost of potential missing buffers if your code fails to send out a buffer in time, and vice versa.\n\n```c\nTDAW_PIP tdaw;\nTDAW_initTDAW(\u0026tdaw, 1024);\n```\n\nInside your application/demo loop, run the following\n\n```c\nTDAW_render(\u0026tdaw, \u0026function);\n```\n\nTo terminate a TDAW instance run `TDAW_terminate()`.\n\n# Live rendering with multithreading\n\nSame as live rendering, except instead of running `TDAW_render()` in a loop, you run `TDAW_mt_render()` **outside of the loop**, otherwise you will be constantly spawning new threads. It holds the same parameters as `TDAW_render()`\n\n# Dependencies\n\n- PortAudio, ALSA or aplay depending on what backend you want to use\n- For the demo, NASM and Python for vondehi and [Elfkickers for sstrip](https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html)\n\n# QNA\n\n\u003cdetails\u003e\n\u003csummary\u003eWhy are there so many preprocessor definitions in `TDAW.h`, it's painful to read!! I hate you!!\u003c/summary\u003e\n\n\u003e Packaging this all in one header file while trying to save on binary size will result at messy code at some point haha\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eCan I pass a single float[2] into TDAW_CHANNEL without having to apply left and right channels separately?\u003c/summary\u003e\n\n\u003e Yes, just do the following pointer magic\n\u003e\n\u003e ```c\n\u003e TDAW_CHANNEL out;\n\u003e float (*ptr)[2] = (float (*)[2])\u0026out;\n\u003e float data[2] = {0.2, 0.2};\n\u003e *ptr = \u0026data;\n\u003e ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eWhat backend should I use?\u003c/summary\u003e\n\n\u003e Portaudio if you want compatibility with other platforms, aplay if you want to save on size. ALSA is slightly worse in size but may offer better performance compared to aplay.\n\u003c/details\u003e\n\n# Credits\n- [pipe (creator)](https://github.com/ppekko)\n- [PoroCYon for vondehi](VONDEHI-LICENSE) (original vondehi found [here](https://gitlab.com/PoroCYon/vondehi))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppekko%2Ftdaw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fppekko%2Ftdaw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppekko%2Ftdaw/lists"}