pouët.net

Go to bottom

Header-Only Music

category: code [glöplog]
 
Hi all, I'm new here.

I've recently finished creating a simple header only library called TDAW, which allows for shader-like music/sound programming in C/C++, as well as some other features (It's also cross-platform). Currently the only dependency is portaudio.

A simple plucked sine wave clocks in around 1.8kb on Linux, but I'm working my hardest to try and bring this down. I'm not familiar with Windows demos, so I'm not sure how i would go about reducing the size there.

Please let me know your thoughts and bring up any criticism/ideas!
You can find the library here.

Thanks :)
added on the 2022-05-09 19:13:56 by pipe pipe
Cool idea. Looks like Intel only atm.
added on the 2022-05-10 17:14:19 by El Topo El Topo
Neat, I like the idea of header-only libs to ease demo-making. Portaudio is nice, but on Linux you could surely save some space by just spawning aplay in a subprocess and piping data to it.
Quote:
Cool idea. Looks like Intel only atm.

How so?
Quote:
Neat, I like the idea of header-only libs to ease demo-making. Portaudio is nice, but on Linux you could surely save some space by just spawning aplay in a subprocess and piping data to it.

No idea why I didn't think of that, but I'll def work that in someday.
added on the 2022-05-10 18:48:36 by pipe pipe
Quote:
Quote:


Cool idea. Looks like Intel only atm.


How so?


Code:asm( "movl $1,%eax\n" "xor %ebx,%ebx\n" "int $128\n");


This is from the example though so perhaps it's possible with other architectures too, I'm not much of a coder.
added on the 2022-05-10 21:30:53 by El Topo El Topo
It is possible to use that with other architectures, it's just plain at&t asm to stop the program. I appreciate your concern however.
added on the 2022-05-11 00:58:37 by pipe pipe
Finally added ALSA support onto this. Now you can essentially run this anywhere as ALSA comes with almost all Linux distros, making it viable for demoscene use (portaudio does not come with ubuntu).

This comes with the added benefit of size reduction, it has now been crunched down to 1.6kb!

I will add that aplay support eventually El Topo!
added on the 2022-09-03 23:59:38 by pipe pipe
Hello, thanks for the cool tool :)
Unfortunately core usage is 100% and sound output is very choppy on my RPi400 :(
added on the 2022-09-04 04:10:00 by gnit gnit
Quote:
Hello, thanks for the cool tool :)

You're welcome! :)
Quote:
Unfortunately core usage is 100% and sound output is very choppy on my RPi400 :(

Is this when running the code in the demo/ folder? If so, maybe try going into the source and changing the second parameter of initTDAW to 1024, it could be that the frame buffer is too small.

If that doesn't work, please msg me on discord (kbx#0375), I would be happy to help!
added on the 2022-09-04 05:25:32 by pipe pipe
Quote:
I will add that aplay support eventually El Topo!


Thanks for the mention but it was not I who asked fort aplay support :) ALSA is nice, I shall see if I can compose a little ditty with it.
added on the 2022-09-05 05:34:09 by El Topo El Topo
Quote:
Thanks for the mention but it was not I who asked for aplay support :)

Haha, I got mixed up with the usernames, my bad!

On that note, byteobserver! I will add the aplay support eventually!
added on the 2022-09-06 21:39:33 by pipe pipe
Pre-rendering has been added to TDAW! (only with ALSA at the moment). Saves a bunch of CPU usage (addressing the issue gnit had with his RPI), however the "on the fly" rendering is still intact if you want to use it. Additionally, size has been crunched down to 1.1kb.
added on the 2022-11-12 21:14:46 by pipe pipe
I have returned.

...with good news!
I have revamped the entirety of TDAW to be incredibly more efficient, with and without multi-threading, using almost under 1% of CPU on my machine anyways, while maintaining similar size. I also (finally) implemented an aplay backend that byteobserver suggested. GitHub repo also contains useful info on sizes with different compilers and backends.

I did remove prerendering, but only because I realized the user could do this pretty easily, and I didn't want to write more code for each backend.

To explain my long wait, over last year I had a massive amount of exams to prepare for and do (spoiler alert, I ended up doing well). Have fun and hope this solves the problems people had previously! Let me know if there are any issues.
added on the 2024-02-23 21:27:01 by pipe pipe
Where did you put it? The GitHub link shows a 404 to me.
added on the 2024-02-23 21:47:23 by skrebbel skrebbel
Cool, looks like it will save quite a lot of hassle with making audio portable on Linux!

login

Go to top