2

Anyone knows any idea of how can I detect plucking in a string of a guitar with an arduino (possibly using the pickup signal)?

Thanks in advance ! ;)

rflmota
  • 151
  • 1
  • 3
  • Does it already have a pickup fitted? Can you modify the guitar, or must the solution work remotely with no changes to the instrument? What level of knowledge do you have now and what did you try already? – David Jan 08 '14 at 20:05

3 Answers3

2

You'll have to decide what a pluck is, but detecting touch is quite simple with capacitive sensing.

Perhaps coupling that with the pickup signal to correlate the string being touched with how hard it was plucked.

Samuel
  • 11,811
  • 31
  • 51
1

Well, you have an electric bass guitar so it makes sense to use the pickup. Next you'll need a buffer amplifier (probably with a little bit of gain). And then you can take the output of the buffer amp (which could also act as a DC level shift to 2.5V) and connect it into an ADC input of your arduino. With no strings being slapped, plucked, fingered, strummed or otherwise fondled you should get a signal of about half scale and if memory serves me correctly that should be a digital value of about 512. There will be a little bit of noise and it won't be dead-centre on 512 but it'll be close.

To detect if the string has been manipulated, you should have a bit of code that looks for an ADC value in-excess of +/- 100 from the "neutral" position of 512.

The buffer amp can be made with a non-inverting op-amp configuration with a pot as the feedback resistor (alters gain). You should capacitively couple the bass pickup to the non-inverting input and form a potential divider with 220k ohm resistors so the input to the op-amp is also centred around 2.5V.

Output from the op-amp (choose a rail-to-rail type for maximum signal swing) connects straight to an ADC input - Make sure your op-amp is powered from 0V and 5V to prevent excess currents going into the ADC input.

I don't know how fast the Arduino can sample or for how long but this is a typical snapshot of (me) playing bass: -

enter image description here

These are all individual notes in a piece I'm working on but note (LOL) how the waveform shape is quite jagged in places. This was played with fingers but if you use a plectrum be prepared for large initial peaks turning rapidly into what you see above. BTW the notes were C, rising to F then down a tone to Eb. Good luck.

Andy aka
  • 434,556
  • 28
  • 351
  • 777
  • 1
    You could avoid the need to sample fast by rectifying and low-pass filtering to do a simple envelope detection. – Scott Seidman Jan 08 '14 at 21:57
  • @ScottSeidman you are probably right but I think the OP needs to recognize this - at least he stands half a chance of getting something from the bass guitar. Highest playable frequency is about 300Hz and that'll have bearly any harmonics worth aliasing. – Andy aka Jan 08 '14 at 22:34
1

I would recommend using the signal from the pickup, similar to what Andy aka suggests, but it will need to be more complicated to work really well:

  1. If you record some bass signal and zoom well in (e.g., with Audacity), you'd see the individual oscillations of the string. Measuring the signal via the ADC function (Analog In in Arduinish) will just note the momentary value somewhere along the waveform; what you need, however, is the peak value - you need to collect a lot of samples and use the "greatest" of them (with the most deviation from the midpoint value, e.g. 512). 50-100 such samples, taken over 20ms would suffice to detect the peak value of the signal. If your code doesn't do anything except monitoring bass plucking, you may just continuously sample the ADC until you accumulate 20ms of data.
  2. Just a fixed threshold, e.g. +/- 100 would make it dependent on your amplification, and on how hard you pluck; Especially if you play quietly for some part of the song, it may not register anything at all! A much better solution is to use some beat detection algorithm. I've used this one previously, and it works well, but you can of course adapt it to be simpler than this in your case.
  3. Plucking a single string results in a signal, whose amplitude fades away in a 1/x fashion over time. So any beat detection algorithm will suffice for this. However, some chords (bass players don't typically employ two strings at the same time, but hey, it can happen) will be different - due to beating, the shape of the waveform, on the large scale, will be cyclically louder and quieter. This could trick your beat detection, but I think tweaking the parameters would avoid this; you need to experiment with values for complex signals like this.
anrieff
  • 5,199
  • 1
  • 27
  • 46