top of page
Search

[62] Master Broth; Perpetual Stew

  • Writer: Conlan Walker
    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:

ree

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

ree

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):

ree

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

ree

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:

ree

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):

ree

"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():

ree

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

ree

Finally, this the audio output that wraps all the fruits of this work into a nice cornucopia:

Now I can rest.

 
 
 

Comments


bottom of page