8-bit drum synthesis

For sometime I wanted to build a 8 Button Arduino drum pad Thingy, and can’t find anything like what I want. I’ve scoured the internet for the type of stuff and just can’t find anything, and I don’t quite know how I would do it myself...

The features I am looking for are something like this: you press one of 8 buttons, and you get the corresponding sound, played through a speaker (I.E. kick, snare, Tom, hihat, etc.), no MIDI or anything fancy here. Sounds pretty simple, but I just can’t figure it out.

I want each drum sound to be synthesized directly from the arduino, and I don’t care about the quality, as long as it provides the sort of arcade/chiptune drum sound.

I’ve tried something like:

byte kick[] {
262, 233, 363 //etc. you get the idea
}

const int spkPin = 8;
Int btnVal = digitalRead(2);

void setup() {
pinMode(spkPin, OUTPUT);
pinMode(2, INPUT);

}

void loop() {
If (btnVal == High) (
tone(kick, spkPin);
)
}

but in theory it should only play a sequence of tones...

How would I use an array of values to synthesize a crappy drum sound and play it when I press a button?

Drum Thingy..txt (230 Bytes)

Which board?

It should be int not Int. The digitalRead() needs to be inside loop(). Kick is an array so it won't iterate itself. You can't just say tone(kick,spkPin) you need it in a for loop. And you have the parameters the wrong way round. And I don't think that a continuous square wave is going to sound even slightly like a drum. At some point you need stop it from sounding so the command notone() is going to come in useful.

Until you can at least get some code to compile it isn't going to do anything.

Steve

Dude, I was just trying to show some example code, and I hand typed it on my phone so chill out. I am using an Uno, and I think I would mabye need a r2r DAC, and some piece of code that can create the waveform I’m looking for.

I also might have an easier time writing another piece of python code to get the values that I should enter... I HAVE seen things like this, so if I can figure out how to generate the waveform, then I will be able to use the converter script to tell the Arduino what values to synthesize the waveform from.

Any help?

Edit: you might could use this from hackaday.io
is.gd/VAg4Uy

Dude, if I ever work out the point of saying "I tried this" then posting some rubbish that could never possibly do anything I might get back to you. Until then I'll 'chill out' as instructed.

Steve

How would I use an array of values to synthesize a 8-bit drum sound and play it when I press a button?
Do I have to use an R2R DAC?

Thanks

Peter_Dodge:
How would I use an array of values to synthesize a 8-bit drum sound and play it when I press a button?
Do I have to use an R2R DAC?

Thanks

That's why I asked you, "what board?". It's possible to produce low quality sound without a DAC, using PWM. I think there is a library for that, I never used it so I don't know the name.

Ok! Thanks! Just to be clear I’m looking for how to code this, because I don’t know how...
Anybody got anything?

Thanks in advance!