Drumcomputer difficulties

Hello,

Me and my classmates are currently building a drumcomputer for a school project. We study electrical engineering in the first year. I was hoping if you could help me with this.

Our drumcomputer prototype consists of the following things:

  • 4 samples: 2 digital, 2 analog (4 channels)
  • 16-step sequencer
  • 4 analog effects, one per channel
  • Final mixer
  • Power Supply

We use an Arduino Due for the controller, mainly the DUE because of the DAC outputs. It has the following functions: - Send out the 2 digital samples out of the 2 DAC's - Send pulses to the analog sample circuit to start it - Control the sequencer

We've set up the DAC with the timer-interrupts, and I've worked with it to send out a standard sine. Now comes the tricky part, finding a proper 12-bit drum sample to put into an array and play it through the DAC. I was wondering if there was a way to convert a .wav file to 12 bit (4096) steps so that it can be placed directly into the code. I am able to convert a certain .wav to 12-bit and 44.1 kHz (the specification I'd like to have) or other bitrates.

Thanks a lot in advance,

Fly

I was wondering if there was a way to convert a .wav file to 12 bit (4096) steps so that it can be placed directly into the code.

Take a 16-bit sample and shift-right 4-bits, or multiply by 0.75. ;) Actually, you'll have to to check the DAC requirements and figure-out what to do with the sign bit. (I haven't used the Due, so I can't help with the details.) Some DACs don't accept signed values, so you might have to bias the value by adding 2048 to the signed 12-bit sample value.

16-bit WAV files use signed integers, and 8-bit files use unsigned integers (with "silence" at 127).

Fixed it! :slight_smile: thanks, we used matlab to make the sound values for our 12-bit DAC. Apparently, it was not that hard XD.

We’ve been stumbling upon some other difficulties yesterday. Our sample array is so big (around 50k values, a text file of 250kB or so) that we need to store in in the 512kB flash storage of the Due. If we put the command PROGMEM in front of our array, it doesn’t actually store it in the flash storage of the due, but in the ram, which is only 96kB… Anyone know the correct command?

Kind Regards,

Fly

ps. added attachment of our current sketch

testaudioplayer.ino (5.7 KB)

shift-right 4-bits, or multiply by 0.75

FYI: Those two aren't equivalent. A right shift of 4 bits divides by 16 which is multiply by 0.0625

Pete

ToHiForAFly: Fixed it! :) thanks, we used matlab to make the sound values for our 12-bit DAC. Apparently, it was not that hard XD.

We've been stumbling upon some other difficulties yesterday. Our sample array is so big (around 50k values, a text file of 250kB or so) that we need to store in in the 512kB flash storage of the Due. If we put the command PROGMEM in front of our array, it doesn't actually store it in the flash storage of the due, but in the ram, which is only 96kB... Anyone know the correct command?

Kind Regards,

Fly

ps. added attachment of our current sketch

You use:

const int16_t waveform[]= {...

The PROGMEM attrib is only for ATmega because it has separate ROM and RAM space.