While my Arduino is being used elsewhere, I felt this would be a good time to cover one of the more important features of the MIDI protocol - Velocity - and how I intend to implement this into the system.
Velocity is an indication of how hard the instrument (be it piano key, drum pad or guitar string) has been hit. As you'd expect, this is to try and emulate the natural dynamic response of acoustic instruments, which get louder if you play them harder.
So without velocity, what are we left with? A drum kit that has no dynamics. It will just play loud all the time. This might sound like a small price to pay for cost, but it severely limits how convincing an instrument sounds to the listener. As the great John Chowning (inventor of FM synthesis) once said:
'Many natural sounds seem to have characteristic spectral evolutions which, in addition to providing their 'signature', are largely responsible for what we judge to be their lively quality. In contrast, it is the largely fixed portion spectrum of most synthesized sounds that so readily imparts to the listener the electronic cue and a lifeless quality' *
Although the context is slightly different (he was talking about sythesisers needing more dynamic qualities), the message is the same - dynamic quality is a very good thing. Variety being the spice of life, and whatnot.
The way a lot of samplers deal with velocity is interesting. As anyone who plays an instrument knows, playing and instrument louder or quieter doesnt just change the volume, it generally changes the sound also. Cheaper drum samplers will take one sample, and control the volume of that proportional to the velocity. This doesn't sound particularly good. More expensive samplers, such as Native Instruments' Studio Drummer, Toontrack's Superior Drummer 2.0, have multiple samples per instrument for each velocity level. They record a drum being played at a range of velocities, and map these samples to the MIDI velocity level. This sounds much better.
To this project, velocity control is not essential to the operation of the device, but it is essential to it having a chance of sounding nice and dynamic. The way this will be implemented is by means of peak detection (hopefully written in software to keep costs down!) that will be able to detect what is called 'local maxima'. Local maxima means that say, if a small peak and a big peak were sent one after each other to an input, the device would be able to detect them both. This is opposed to a 'peak value' - a maximum threshold that will trigger once a voltage becomes bigger than the threshold value - which would only be able to detect peaks above a certain level, and would result in all velocity values being the same.
The gradient of the incoming signal can be analysed to detect peaks. Over a peak, this is how the gradients will look:
^ g = 0
| /\
| g = + / \ g = -
| / \
| / \
--|-------/ \-------------------->
(better diagram coming soon!)
To implement this algorithmically, a few samples of the incoming signal can be stored and compared. If the values are increasing, a peak is about to happen. If the values have stopped increasing, a peak is reached. If the values are decreasing, the peak has passed. An algorithm can be written that will analyse the difference between the last 3 or so sampled vales of the input. If it detects an increasing signal, a 'flag' can be set (change a known variable to '1' or something) to denote it is expecting a peak. When the signal starts decreasing, the flag can be set to '0' and the last biggest value of the input can be used as a peak. This value can be mapped to the MIDI standard's 127 levels of velocity. And there you have it! Well, hopefully. This hasn't been implemented yet. If anyone else has got some good ideas about this, I'd love to hear them!
*This paper is freely available - and it's a good read! Check it out here.
Showing posts with label MIDI. Show all posts
Showing posts with label MIDI. Show all posts
Saturday, 19 May 2012
Arduino drum kit, part 2 (The Blastmachine!)
Hi everyone, some more info on the Arduino drum machine...
The state which I left the drum kit in before my Arduino had to be repurposed for university work is covered in this post. The first thing I did was to test how well MIDI works with the Arduino with a simple test from this site:
http://arduino.cc/en/Tutorial/Midi
All the code and stuff in the link above is already in the Arduino IDE under Examples -> Communication -> MIDI.
Sending MIDI messages with the Arduino is very simple. RS232, the standard communications protocol that the Arduino (and all sorts of other things), is almost exactly the same as MIDI. The only thing that needs doing before using simple Serial.write commands is setting the baud rate to the MIDI standard - 31250 baud, which is shown in the link above. The program provided transmits a whole range of notes. The code can be modified to just send one note by removing the 'for' loop and replacing where it says 'note' with the note that you want. This note is in hexadecimal, so use this for reference:
http://www.wavosaur.com/download/midi-note-hex.php
The state which I left the drum kit in before my Arduino had to be repurposed for university work is covered in this post. The first thing I did was to test how well MIDI works with the Arduino with a simple test from this site:
http://arduino.cc/en/Tutorial/Midi
All the code and stuff in the link above is already in the Arduino IDE under Examples -> Communication -> MIDI.
Sending MIDI messages with the Arduino is very simple. RS232, the standard communications protocol that the Arduino (and all sorts of other things), is almost exactly the same as MIDI. The only thing that needs doing before using simple Serial.write commands is setting the baud rate to the MIDI standard - 31250 baud, which is shown in the link above. The program provided transmits a whole range of notes. The code can be modified to just send one note by removing the 'for' loop and replacing where it says 'note' with the note that you want. This note is in hexadecimal, so use this for reference:
http://www.wavosaur.com/download/midi-note-hex.php
(I may create a better diagram later on)
The example code creates a 'note on' message. This contains the note number, velocity and channel. For those not familiar with MIDI, velocity emulates the speed at which a piano key or any other instrument is hit, therefore bigger velocity translates to louder sound.The maximum velocity level is 127, minimum is 0, which translates to 0x7F and 0x00 in hex respectively. It is standard practise to send a note with velocity set to 0, as opposed to using the dedicated 'note off' command.
In my setup, I'm using a drum sampler within the recording software Cubase. Cubase is full of all sorts of good stuff, but the bit that we're concerned with here is its VST hosting capability. Whats that? Well, a VST is a virtual instrument that can, amongst other things, accept MIDI and output audio. A VST host sets up the environment for providing the MIDI and audio I/O. I'm using Cubase as a host and Native Instruments Studio Drummer as the instrument, but free alternatives exist, and I hope to write something about this towards the end of the project. Because free alternatives are always a bonus, right?
To test this MIDI communications functionality, and with a certain level of control, I hooked together the MIDI output as specified on that example page, a couple of switched and a couple of LEDs...
(CODE COMING SOON!)
In this case, the code waits for an input from the switch before transmitting a MIDI note. There's one button to trigger the bass drum note, and one to trigger the snare note.
I'd like to add - this has been very poorly coded and you'd never try and run a proper drum kit this way, this was just to test the thing. However it had a quite funny side effect - if you hold a button down, it will continually cycle and play the sample very fast. If you hold down both buttons, it will alternate between both very quickly, and essentially emulates a traditional 'blast beat', the staple drum pattern of extreme metal. Awesome! Good example of what I'm getting at here:
Let's compare...
Labels:
Arduino,
blast beat,
drum kit,
electronic drum kit,
metal,
MIDI
Thursday, 17 May 2012
Arduino Drum Kit, part 1
Hey everyone, heres a fun project that I've sadly had to halt while my Arduino and time was committed to university work.What I hope to do with this blog is write down some more discussion-based aspects of the development, and then when the thing is done, put up an instruction guide or something similar with design files and whatnot.
The basic plan is this - create an electronic drum brain with an Arduino, where the input is a set of piezo transducers attached to some form of percussive pads, and the output is MIDI messages corresponding to notes. This system will send MIDI messages to a computer, which will in turn play the appropriate drum samples.
Sounds very simple... And quite conveniently, the bulk of it is! And most electronic drum kits Ive come across use very similar methods. In fact, wire up a piezo to a jack plug, plug it into almost electronic drum kit you care to mention, hit it and you'll most likely see it work. So the question you may be asking is 'why do electronic drum kits cost so damn much?' well, the answer quite neatly sums up the limitations of my project. Commercial electtonic drum kits generally have these sorts of features:
In short, these are things that make electronic drumkits nice, self contained instruments that require little external technology for proper operation. For this project - almost none of these things will be included to keep costs as low as possible. But how will it work with no pads, very little I/O and no sound to play?
What this project is intended to be is the very fundamentals of a drum 'brain'. As it happens, most of the features mentioned above are great, but not neccessary. Rather than onboard samples, sounds are sorted on the computer via a drum sampler and VST host (more on that in part 2). Rather than huge I/O options, the limited Arduino analogue inputs will be used. Rather than nice pads, the sensors will be attached to whatever you can tape them to and dont mind hitting! This is a brief overview of the system.
Some projected costs, taking the cheapest in each case:
A more detailed breakdown of costs will be included at the end of the project.
I hope to extend this system and add all sorts of usefull bits and bobs. Velocity control would be a particularly useful feature, which I hope to cover later.
Ill be adding more information about this project over the next few days.
Thanks for reading!
The basic plan is this - create an electronic drum brain with an Arduino, where the input is a set of piezo transducers attached to some form of percussive pads, and the output is MIDI messages corresponding to notes. This system will send MIDI messages to a computer, which will in turn play the appropriate drum samples.
- Nice hardware - racks for the pads to sit on, nice pads made of durable materials, decent piezo sensors, pads with multiple sensors (think ride cymbal pads with bells as well) e.t.c. Made to go on the road!
- Large amounts of I/O - allows the user to attach a ton of pads.
- On board samples - increases the specification of the system considerably in terms of memory and storage to hold the samples. Anyone who's worked with digital audio knows - storage and fine quality audio aren't the best of friends.
- Other digital features - complex interfaces, additional MIDI features, custom patches and sample sets, things that increase flexibility to the user.
What this project is intended to be is the very fundamentals of a drum 'brain'. As it happens, most of the features mentioned above are great, but not neccessary. Rather than onboard samples, sounds are sorted on the computer via a drum sampler and VST host (more on that in part 2). Rather than huge I/O options, the limited Arduino analogue inputs will be used. Rather than nice pads, the sensors will be attached to whatever you can tape them to and dont mind hitting! This is a brief overview of the system.
- Arduino - £18
- Piezos - can be found for around 30p each. A set of 6 would therefore be £1.80.
- MIDI cable - around £3.
- MIDI interface (omitted from diagram) - cheapest I've found is around the £20 mark.
- VST host - Free!
- Drum Sampler - Free!
- Materials - going to attempt to make pads from butchered mousepads initially. Picked up three for £1.
- Drum sticks - £4 if you're feeling fancy. Any old pen you have lying about, if not.
A more detailed breakdown of costs will be included at the end of the project.
I hope to extend this system and add all sorts of usefull bits and bobs. Velocity control would be a particularly useful feature, which I hope to cover later.
Ill be adding more information about this project over the next few days.
Thanks for reading!
Subscribe to:
Posts (Atom)
