Add mtm_hardware.DACOut audio output for the MTM Workshop Computer#10895
Add mtm_hardware.DACOut audio output for the MTM Workshop Computer#10895todbot wants to merge 36 commits intoadafruit:mainfrom
Conversation
tannewt
left a comment
There was a problem hiding this comment.
I think this should be reorganized so that it can be use elsewhere besides this board.
I'd put it in shared-bindings under the mcp4822 name unless this is a common SPI DAC protocol. If it is, then use a more generic name with any mcp4822 specific settings.
Then, move this implementation to common-hal for rp2 (since it is PIO based). Could it be SPI based if we had an internal async SPI API? Maybe have it take in the bus to use?
The board will init it and add an entry to board for using it.
These changes would allow any board build to use it and potentially enable it for "dynamic" use when folks plug it into something.
Thanks!
|
I don't see it being of much use to others. This is not a good DAC for doing audio on. We already have the This DAC frustratingly requires per-sample manipulation (bit sets for channel selection & bit shifts for 16-bit->12-bit conversion) that makes it difficult to use for audio on any other port in CircuitPython that doesn't have a PIO-like module to handle that sample manipulation (since I believe the CircuitPython audio DMA system requires a single address to write to) So, I had to use up most of the PIO program memory to accomplish this. I'd rather it stay in this board for now and if anyone else asks for it, we can revisit the move to common-hal or shared-bindings. |
tannewt
left a comment
There was a problem hiding this comment.
If you insist, then ok. How about still initing it in board_init and adding it to board? That way folks don't need to know about this module at all.
|
I'm also currently trying to put it in |
Not in |
|
Is it possible to pass in arguments in objects defined in |
No, it's meant to just work. I'd suggest making |
…hon into mtm_computer_dac_audio
|
Okay, the 'mcp4822' module is in its own namespace. There's now a However, I was having some weirdness with If that's too much churn for a PR, I can resubmit this as one change. But I still may get the weird translation changes. |
This reverts commit 8bf51db.
|
To fix the zephyr builds you'll need to run: https://github.com/adafruit/circuitpython/blob/main/ports/zephyr-cp/cptools/update_board_info.py (We cache what modules are enabled on zephyr and have a check to make sure every module is listed. We should likely relax it.) |
Should I be running this before every commit, as an adjunct to pre-commit? |
tannewt
left a comment
There was a problem hiding this comment.
A few minor things. Getting close! Thanks!
Maybe? It only matters when adding a new module but it should be fast to run. |
|
A zephyr build is still failing but I can't tell how it's failing or see how I can fix it. |
This reverts commit 8bf51db.
…hon into mtm_computer_dac_audio
Adds a new board-level module
mtm_hardwarewith aDACOutclass that provides non-blocking audio playback through the slightly strange MCP4822 dual-channel 12-bit SPI DAC on the Music Thing Modular Workshop Computer.DACOutfollows the same API asaudiobusio.I2SOut, accepting anyAudioSample(WaveFile,RawSample,Mixer,MP3Decoder) and plays it non-blocking via DMA to a PIO state machine.