[62] Master Broth; Perpetual Stew
- Conlan Walker

- Dec 23, 2022
- 2 min read
I have far too much stuff to show to explain it in a reasonable time, so explanations will be of inconsistent length again (I feel like I say something like this almost every weekly update, whether or not it's warranted).
I started the week by working more on the bindings, specifically these ones:
(These were easy to make, as they're very similar)
4 new 'common' Lua utilities were created, with at least 1-2 of those being used in each function above. Those utilities are as follows:

There's also one that's not even a function, but is instead a macro:

The big test I did to demo some of these is shown here. All of the Lua code that performs the test is also shown in the video, from lines 6 to 37:
I realized that at some point I'm going to have to deal with audio at some point, whether it be music or sound effects, so I decided to try out playing some PCM audio.
for handling that PCM audio, I'm using SDL's built-in audio functionality. It's pretty basic, and you need to do handling of buffers and mixing yourself.
I browsed the API and figured out how to list all of the available audio devices, which is shown in this test (the green text is the test's output):

To hold the PCM audio, I made a new file format, called a ".mua". Here's its header:

It's basically a ".wav", but with some more features, like 64-bit sample data size (instead of 32-bit), explicitly stating whether samples are floats, or signed or unsigned integers of 1->128 bits.
Also, you can set the endianness of bytes, and you can make the audio loop, which is cool.
This is the function that loads a .mua into memory:

The only check to the file being done here is seeing whether the file signature is correct, but I might add some more checks at some point, like checking whether the actual sample data size matches what the file says it is.
Anyway, here's an example muaReadFile() being used (the printf()s print the header info):

"n3-Tcs" is a song I ripped from Yume 2kki's game files, and is a good candidate for these tests, as many songs are short, have odd sample rates, alongside some other things.
The code shown below opens an audio device, given some desired parameters, before playing the audio previously loaded by muaReadFile():

And this is the callback that is fed into SDL whenever it needs new audio data to be written to its buffer:

Finally, this the audio output that wraps all the fruits of this work into a nice cornucopia:
Now I can rest.















![[158] Most Important Brick in the Least Important Wall](https://static.wixstatic.com/media/df100d_f70be6ae4318455fbbc605cd1069c6ee~mv2.jpg/v1/fill/w_980,h_410,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/df100d_f70be6ae4318455fbbc605cd1069c6ee~mv2.jpg)
![[157] Mail Order Sacrifice](https://static.wixstatic.com/media/df100d_e284fa6c51b04524bab9d3cf9f1f6441~mv2.png/v1/fill/w_980,h_382,al_c,q_90,usm_0.66_1.00_0.01,enc_avif,quality_auto/df100d_e284fa6c51b04524bab9d3cf9f1f6441~mv2.png)
![[156] Moat of Babble](https://static.wixstatic.com/media/df100d_091e451794b14aecb494a16c15c966c3~mv2.png/v1/fill/w_980,h_705,al_c,q_90,usm_0.66_1.00_0.01,enc_avif,quality_auto/df100d_091e451794b14aecb494a16c15c966c3~mv2.png)
Comments