Audio or music related Zig project ideas

  • DACs for crude audio output.
    • Again, not as good as a dedicated chip, but you can do a lot worse than 12-bit.

I was curious about this, since I saw their marketing advertised “192kHz/32-Bit Stereo Audio Hardware”, but I couldn’t find more details about that on their datasheet. I ended up finding on their forums that the board supposedly has a TAC5242 codec on it which grants that level of quality on pins 16-19. Confused that that was omitted from the datasheet though.

but you’'ll always get better results with an external chip because the sensitive analog audio lines don’t need to go near the micro-controller, clock crystal, and USB lines.

Might I pick your brain a bit on this? I’m very much a hardware noob but am interested to learn. How near is near enough to introduce a meaningful amount of noise? MCU boards like this Seed3 are quite compact, is it the physical size of the PCB that raises the mental yellow flag? Or is it more about whether the analog lines have to enter the primary SoC?

For the audio stuff you’d like help on, is your goal to introduce an API into the shader language similar to Hydra’s? Looks like theirs essentially provides access to a list of loudness bins, updated each frame, which can optionally be smoothed over time? If so, I’m down to take a crack at it! May I DM you to ask about some of the details?

1 Like

Yeah you’re right, there’s a TAC5242 on there, not mentioned anywhere in the documentation. I don’t know how I missed that…

Begin Rant

No, I know exactly why; it’s because they didn’t include a schematic in the datasheet. I was willing to give them a pass at first, because I know some companies are touchy about their IP, but that’s not acceptable when the rest of the documentation is so lacking.

Looking closely at the pin table I can see there are three I2S interfaces. Three of them! There should be an entire chapter describing the I2S interfaces, their pins and their capabilities. Which pins are connected to the TAC5242 ? No clue!

Yeah on second thoughts I hate this board. The hardware seems ok, but the documentation is unacceptably bad.

Just to show I’m not overreacting, here’s the chapter on I2S for the ESP32-S3 .
https://documentation.espressif.com/esp32-s3_datasheet_en.pdf#paragraph.4.2.1.3

It’s short, but links to a more in-depth explanation in the technical reference manual:
https://documentation.espressif.com/esp32-s3_technical_reference_manual_en.pdf#i2s

You might find it a good read actually; it explains a bit about how I2S is encoded at the electrical level. It would be better if you can find docs for the micro-controller you’'re using, of course.

Yes, the 192 kHz / 32-bit will be referring to the TAC5242’s capabilities. Oh, and that the I2S ports are able to supply & receive enough data; but that’'s only ~ 6Mbit/s, but that’s pretty easy; it could probably do 40Mbit/s (e.g. multiple codecs on a single I2S bus).

Regarding noise, the good news is that there is, in fact, a dedicated chip, so the analog lines don’t go quite as close to the microcontroller. They’ve put it in a good position too, far away from the microcontroller and buck regulator. Size of the board is not important, except insofar as it lets you space components apart, or have a better ground plane.

There’s a few reasons to keep analog audio lines away from microcontrollers.

  • Microcontroller GPIO’s tend to have a high-slew rate (they need to switch at 40 MHz or higher, after all), which means they put out a lot of noise which can affect nearby circuits. Digital circuits can ignore the noise, analog inputs/outputs cannot.
  • Microcontrollers will use bursts of power depending on what they’re doing, so nearby devices that share the power or gnd plane will also see the input voltage change in noisy bursts, which then affects their outputs.
  • Environmental noise can come in from external connectors, enter the microcontroller through one GPIO, and exit via all the other GPIO’s and mess with seemingly-unrelated circuits.

As you can guess, these are all exacerbated when the ADC/DAC is integrate into the microcontroller.

1 Like

Thank you for sharing your expertise! I’ve been enjoying learning more about hardware lately, thanks for being willing to answer my questions haha

I too found Daisy’s datasheet frustrating! Their software docs for e.g. DaisySP are somewhat better (and have an impressive array of ready-made APIs for writing synthesizers & effects pedals). If only the hardware documentation was complete, but ah well.

I think if I were making a eurorack synth module I might still consider the Seed3 for its raw convenience, but for my mixer idea I am leaning heavily toward the ESP32 family, especially since a great future feature would be Wi-Fi range remote control.

Yeah 100%, DM’d you the details.

tyvm, always looking for contributors. it’s also free ytmusic without ads making use of the innertube api. i’ve thought of adding a lowkey dl option (ctrl+d or something on albums playlists and tracks) but that throws it into even more of a grey area lol

Yeah, there’'s situations where raw simplicity is the winner. But if the goal is running your own code on the micro, then the ESP32 has a much richer environment.

Some tips if you do go down that route.

  • Espressif provides the ESP-ADF as a supplement to the ESP-IDF for audio projects. It’s got its own docs site, including audio development boards with really good documentation. There are also lots of examples.
  • The ADF is written in C. Even if you do decide to rewrite all of it, you can avoid a lot of work by looking at the HAL code used to interface with all the different audio chips. Writing a codec library from scratch is a PITA, even when the datasheet is great.
  • Many of the audio processing elements (especially the mp3/ogg/aac decoders) have an optimized binary blob to do their core computations - you could re-use that in zig code.
  • The best chips for a zig project would be ESP32-C3 and ESP32-P4, since they are RISC-V based. The ESP32-S3 is my personal favourite, but it uses the XTensa instruction set - same as the original ESP32.
2 Likes

my decent (pun intended) 2 cents:

1 Like