Configuring SPI for audio

Hello,

I have an MCP4822 12 bit dual channel DAC which I would like to transmit an audio waveform (to use as a voltage-controlled oscillator).

If I aim to send a 12 bit sample at a bit-rate of 441000 kHz, should I configure spiSettings as such?:
edited to say "12 bit sample" where it used to say 16 bit sample, whoops.

SPI.beginTransaction(SPISettings(441000, MSBFIRST, SPI_MODE0))

Because it's a dual DAC, should I double the SPI transfer speed to account for twice the data being transferred?

This is my first project making any sort of audio driver, so let me know if my question is clear enough, and if there's any additional information that I can provide. Thank you!

A lot of information is missing! What processor? Have you written any code? Have you spent time with the DAC data sheet?

This

Because it's a dual DAC, should I double the SPI transfer speed to account for twice the data being transferred?

tells me maybe you have not.

Wrong! I have. Just... I don't understand much of it :sweat_smile:. This is my classic method of having an idea and feeling around for a starting point.

I'm using an STM32f401CCU "Green Pill" MCU, 100 MHZ. It's not an AVR, sorry. Figured (incorrectly i guess) that the SPI library would behave similarly across boards using the Arduino IDE (STM32Duino in my case).

No code has been written, but I was going to base it off of code that written for a DSP discovery board, the Axoloti. I would have to adapt it to be used independently of chibiOS, and the other platform specific parts, but I intend to figure it out as I go along.

That is to say, the code exists, just not for this project. The individual wavetables to be used are 256 bytes per table, but it's a 2 dimensional array of these wavetables meant to be scanned and interpolated. The scanning can goes outside of the audio-rate code.

What do I look for in the datasheet that will help me answer this? It's a stupid question, but that's why I'm here.

What makes you think that it doesn't? Especially as you say you haven't written any code.

You asking what processor I'm using.

Well, there are a million scenarios you could hypothesize about. But only a few you could implement.

You can find the answer to your question by actually researching and designing the interface. Any possibility of getting help on it here without that, would require that we do that job. Nobody is going to do an implementation that would take at least days to research and implement for free.

Allow me to state a goal, since you're right, I'm missing a lot of information.

I would like to produce a saw wave with a length of 256 bytes in a 440hz "A", at a rate of 44.1 kHz using a dual channel SPI DAC.

If necessary, I will make the code for creating a wavetable in the shape of a saw wave, and include the necessary drivers for the potentiometers that I will eventually use, but my goal with this question is specifically how to configure the DAC for audio rate.

Are you sure you need a wavetable? Many of the STM32 series have automatic waveform generation capability.

Again you surprise us with hidden requirements and features that you haven't explained the purpose of - potentiometers.

I'm done here. Good luck.

Why do I get helpful answers on every forum, but every time I come here with a question people tell me to figure it out by myself? What makes you assume I want you to write it for me?

Why do you answer questions to someone saying they need help and not provide help? I don't know what to do. You said look at the datasheet. Great, where?

It has a very well organized index. I say what I say not to be cruel, but to awake you to the reality that it will take to complete your project at all.

I told you why people can't answer your question. It's because a new and individual project like this always requires research and design. Even by an expert. It is simply not possible to guess. It is a system specific question not a general one. If you provide full examples and context and then post any issues with actual, concrete codes and designs then lots of people will gladly help. Maybe even me, I have a lot of STM32 experience. But I find your attitude off putting. You seem more interested in debating than working.

Did you want a 112.64 kHz sample rate (playing all 256 samples 440 times a second) or the 44.1 kHz sample rate, playing 100.227 of the 256 samples 440 times a second? I'm guessing the latter.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.