pouët.net

Go to bottom

Advice with my first 64K demo

category: music [glöplog]
 
I am currently in the process of creating my very fist demo, a 64k one.
I've decided to make it on Linux using C++ and OpenGL (it will be mostly raymarching).
I have some degree of experience making game engines, so I'm familiar with these.

The problem I'm facing is that I've done audio before with OpenAL but I don't think that could be used for this purpose as it is not installed by default...

I've been researching a bit on how to do a synthesizer, generating the different waves, what an ADSR envelope is etc, but I haven't found any examples on any available "default" API to interface with the audio system. Any suggestions?

Also what is the norm? pre-generating the audio before the demo starts or creating it in realtime as it is playing?
added on the 2019-08-20 14:58:29 by NoxWings NoxWings
Quote:
I haven't found any examples on any available "default" API to interface with the audio system. Any suggestions?

No idea what's considered default on Linux nowadays, I would guess ALSA/PulseAudio?
Quote:
pre-generating the audio before the demo starts or creating it in realtime as it is playing?

Whichever is more convenient; realtime is preferred since the CPU isn't doing much anyway and it skips you the long-ass loading time.
added on the 2019-08-20 15:05:32 by Gargaj Gargaj
ALSA is completely fine. If the user uses PulseAudio (which is common these days), it will install a special ALSA device by default which feeds into the PA mixer.
added on the 2019-08-20 15:08:40 by Sesse Sesse
Usually the compomachine runs the latest stable version of Ubuntu released at that time (eg. it was 19.04 at Evoke last weekend), so you can use anything that's available on there, and sometimes there are a few extra things available, too.

One of those is SDL2, so you can use that API. But on other machines, you'll have to use the "default" APIs. However, ALSA is way too annoying/brittle/verbose, and I wouldn't like to rely on PulseAudio (I avoid installing it on my machines as much as possible), but there's a simple trick I used in 작은 (small): creating an aplay(1) process and piping audio data to it. (SDL was available, but I couldn't use it directly, because the synth I used works only in a 32-bit process, and the 32-bit versions of the libs aren't available.)

Also, take a look at the Linux sizecoding wiki, the recently-updated in4k page on Linux, and maybe join #lsc on IRCnet as well. I'll be releasing the source code of 작은, but there are still a few bugs in there, and as I want people to make prods using the "framework" without issues instead of only being able to know how it's done, I need to fix those first.
added on the 2019-08-20 16:37:07 by porocyon porocyon
Btw, please please please don't do raw X11 to create a window. At least use GTK if SDL isn't available. (GLFW and SFML never are afaik.)
added on the 2019-08-20 17:06:09 by porocyon porocyon
SDL audio API is the best. You just give it a callback, and then write samples in that callback.

ALSA can be dumbed down to something like this, but you'll have to create your own thread, set priorities, etc etc

PulseAudio is a huge no. Way too verbose and inconvenient to use for something as simple as just outputting audio stream.
added on the 2019-08-20 18:02:25 by provod provod
Quote:
Btw, please please please don't do raw X11 to create a window. At least use GTK if SDL isn't available.


ouch, I already did that, may I ask you why not? I use KDE so I don't want to rely on gtk (or qt) being there.
added on the 2019-08-20 18:14:34 by NoxWings NoxWings
About using SDL... I am a bit unsure SDL isn't near any kind of default package in any distro I know. It sounds (no pun intented) a bit like cheating.
added on the 2019-08-20 18:16:50 by NoxWings NoxWings
Quote:
One of those is SDL2, so you can use that API. But on other machines, you'll have to use the "default" APIs. However, ALSA is way too annoying/brittle/verbose, and I wouldn't like to rely on PulseAudio (I avoid installing it on my machines as much as possible), but there's a simple trick I used in 작은 (small): creating an aplay(1) process and piping audio data to it. (SDL was available, but I couldn't use it directly, because the synth I used works only in a 32-bit process, and the 32-bit versions of the libs aren't available.)


Nice trick using aplay xD

Quote:
Also, take a look at the Linux sizecoding wiki, the recently-updated in4k page on Linux, and maybe join #lsc on IRCnet as well. I'll be releasing the source code of 작은, but there are still a few bugs in there, and as I want people to make prods using the "framework" without issues instead of only being able to know how it's done, I need to fix those first.


Oh thank you for those links too, I really appreciate it. For now I am compressing the binary with sstrip and UPX, but I definitely need to look a bit more into it.
added on the 2019-08-20 18:35:06 by NoxWings NoxWings
Quote:
Quote:
Btw, please please please don't do raw X11 to create a window. At least use GTK if SDL isn't available.


ouch, I already did that, may I ask you why not? I use KDE so I don't want to rely on gtk (or qt) being there.


Same reason as ALSA/PulseAudio: it's verbose as hell, tends to break quickly on differing setups (hello Wayland), and annoying. For doing 'simple' things (like going fullscreen, hiding the cursor, quitting on ESC), you have to jump through multiple hoops while keeping everything else happy. Also raw GLX or EGL... just no.

GTK is available by default on the compomachines, because those run Ubuntu :) I myself use Sway (i3-like wm for Wayland), but I don't think doing raw Wayland stuff is a feasible option.

Las (4k compo orga for Evoke, Revision, and probably a few other parties as well) told me in an email that he prefers to have SDL installed so all this can be done in a uniform way without too much breakage on differing setups. But he can probably tell you more about this.
added on the 2019-08-20 19:16:39 by porocyon porocyon
Quote:
Oh thank you for those links too, I really appreciate it. For now I am compressing the binary with sstrip and UPX, but I definitely need to look a bit more into it.


UPX sucks. A simple shell dropper already beats it by quite a bit of margin. There's better stuff coming up, but it's not quite ready yet.
added on the 2019-08-20 19:17:36 by porocyon porocyon
SDL2 is usually considered fair game, but check the rules for the party in question. I don't think raw ALSA is that bad, though.
added on the 2019-08-20 19:33:52 by Sesse Sesse
Quote:
SDL2 is usually considered fair game, but check the rules for the party in question. I don't think raw ALSA is that bad, though.


I don't see anything specific on the rules

I've just sent an email asking clarification for what libraries I can expect on Linux. I guess that if sdl is allowed I'll use it and I'll try ALSA otherwise.

Thank you for your suggestions!
added on the 2019-08-20 20:59:42 by NoxWings NoxWings
Then your best bet is to send an email indeed. I did the same for Evoke. At least Revision is pretty clear in this regard.

Now get on IRC :P
added on the 2019-08-20 21:02:55 by porocyon porocyon
NoxWings, from that website:
Quote:
Together with the entry, submit a video render of it.

They probably wont play it on real hardware so you probably can get away with whatever you want.

As long as no one stops me from doing so - libSDL* will be installed on compo machines at certain german demoparties. It makes a lot of things a whole lot easier and it's really simple to create windows ports if you don't use too many fancy preinstalled libraries (hi porocyon! :D).
added on the 2019-08-20 21:56:22 by las las
Quote:
I don't see anything specific on the rules

“Libraries such as msvcr70.dll won't be available in the system.”

I would not be surprised if SDL goes under sort-of that heading. But send them an email and ask. :-)
added on the 2019-08-20 23:27:24 by Sesse Sesse
Btw coming back to say thank you all. I finally released my first intro Retro-Vibes.
added on the 2020-07-30 12:11:11 by NoxWings NoxWings
Congratulations on your first intro!
added on the 2020-07-30 20:24:57 by superogue superogue

login

Go to top