We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello guys,
I am doing an project where I am displaying information on a snare drum only (not a all drum kit!). My goal is to give simple feedbacks to the user using a microphone as detection tool. My projection look like a clock and when the main hand reach a point, the player should hit the drum. I would like to detect if he hits the drum on time or not and if he hits the drum or not. My projection is in yellow on a black background, it will highlight in blue if he didn't hit on time and in red if he didn't hit the drum (or if he hits anything which is not the drum).
I tried with minim and beatdetect but unfortunatelly the "isSnare" doesn't work as it should be ... It returns true even if I am whistling or hitting my desk...
Should I go in an FFT analysis ? I am up for any advices .. I don't really know where to start.. Should I record the drum sound and then test in real-time if the hit is equal to the recorded sound?
Here is my code for now:
import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
BeatDetect beat;
AudioInput in;
float eRadius;
void setup()
{
size(200, 200, P3D);
minim = new Minim(this);
in = minim.getLineIn(Minim.STEREO, 512);
// a beat detection object SOUND_FREQUENCY based on my mic
beat = new BeatDetect(in.bufferSize(), in.sampleRate());
}
void draw()
{
background(0);
beat.detect(in.mix);
println("isSnare: "+ beat.isSnare());
//println("isHat: "+ beat.isHat());
//println("isKick: " + beat.isKick());
//println("isOnset: "+ beat.isOnset());
}
Answers
You do a FFT analysis and check what your spectrum looks like. Then, you can select a section of your spectrum to trigger to. You can choose both based on frequency and the frequency's amplitude. Previous posts on FFT to get you started:
https://forum.processing.org/two/search?Search=FFT
https://forum.processing.org/two/discussion/comment/100684/#Comment_100684
Kf
If i understood you well, I should record the drum sound, make an FFT analysis on it and then test it ?
To make the FFT analysis, is there any software which can do that quickly or should I develop something using processing?
Thank you for your quick answer @kfrajer
You could use the mic option to check sound live. That is what I will do.
If you check one of the previous post and get it running, that is half of the battle won. No need to implement anything new. It has been done already in the forum. After you get one version working, then it comes to choosing the frequency region to act as the trigger for your console.
What is important is to define the frequency region. Amplitude is trivial. Consistency... that is what you need to study. You need to assess how the FFT performs for your task.
Kf
Ok I used one of your previous post to get frequency from my mic.
What's the mic option you are talking about ? I am using minim, isn't it the same ? Otherwise, what are the differences?
Sorry it's the first time for me in this field
With mic I am referring to your microphone. You can use AudioInput to access your mic and this is done through the Minim library. A recent example: https://forum.processing.org/two/discussion/comment/100684/#Comment_100684
Kf
Thank you very much
I tried the processing sketch from one of your previous post and I have adapted it in order to check sound live. However, I am not able to identify properly in which spectrum my drum is ...
I mean yes I can see it is between 0kHz and 2kHz (closer to 0kHz) but when I am singing or hitting my desk it is quite the same spectrum.... Have i missed a part ?
This is more of a technical question about drums and their frequencies. Maybe some other forum goer can provide some of their experience. I will suggest exploring previous posts:
https://forum.processing.org/two/search?Search=drums
https://forum.processing.org/two/search?Search=snare
Or do some research in google... I am sure somebody has had the same problem. I wouldn't use the low part of the spectrum to identify my instrument as anything can trigger that part of the spectrum. However, if you are only playing one instrument (ever), then instead of a frequency trigger, you could just focus in amplitude.
Kf