Sound detector to detect hammer strikes


Senior Member
In that case you are looking at "pre-amplifier" or something which creates an appropriate line signal output.
Gramps, since you have the sparkfun microphone module you can alter the feedback resistor of the first amp stage, remove R3 and populate R17 with 1 Meg for maximum gain. I've been experimenting with that circuit in my geophone project and its rock steady. I did not have the posh LMV324 op amp on hand, when I first saw 324 I remembered it as the old single supply voltage op-amp of hohum specs, but the LMV variant is by far better, it's rail to rail and low voltage, very good component. I had some TL062 op amps on hand and the sparkfun circuit worked exceedingly well with TL062 and a 5V supply.

here is the link to the sparkfun circuit,

Microphone Module


Senior Member

Yes, as hippy said, you need a pre-amplifier, not a Power Amplifier. And the "Class D" module linked above is particularly UNsuitable, because it uses "switching mode" (or PWM). The reference to a 4 - 8 ohm loudspeaker load is not a "capability", but a requirement. The inductance of the loudspeaker is essential to act as a low pass filter (ao); connecting the output voltage to a PICaxe pin definitely won't work and might well destroy the PICaxe.

Also, you don't need just an amplifier but also a "detector", to convert the ac "sound" to dc. The second stage of the circuit linked by Julian has such a function (they've called it a peak detector); you could take a signal from its output (if building a minimal circuit) or after the "buffer amplifier" (of the assembled module). Alternatively, there is a well-known PICaxe "Sound Detector" circuit which uses only two transistors (with an optional third for the buffer) and includes a gain control (potentiometer) which might be useful. In either case, just connect the "detected output" (buffered or not) via a few kohms to the PICaxe ADC input.

You might need to optimise the amplifier gain and the detector "attack and decay times", so a prototype "breadboard" could be a better starting point than a ready-made module.

Cheers, Alan.


Senior Member

You might not need a lot of gain if the microphone is close to the soundboard / hole.

Here is the long-established PICaxe "sound / noise detector" that I mentioned above. No "special" components are required, but even if you don't want to build it, the description is quite useful.

Cheers, Alan.


Senior Member
I realized that my first test with the sound detector module was based on the wrong algorithm. I did 10 READADCs, threw out the highest and lowest, and averaged the remaining. What you really want to do is establish a baseline reading, and then look for significant differences from that. The following does it (partially) for my sound module:
' 08adcminmax
#picaxe 08m2
symbol cDiff=8
symbol base =b3
symbol xmin=b4
symbol xmax=b5
symbol xadc=b6
symbol wTmp=w13
pause 1000
gosub ADCread10x
xmin = base - cDiff
xmax = base + cDiff
sertxd("base ADC is ",#base," min=",#xmin," max=",#xmax,cr,lf)
   readadc c.4,xadc
  loop until xadc < xmin or xadc > xmax
  sertxd("# ") ' once per strike
  pause 400 ' give time to settle

ADCread10x: ' only called to establish a base reading
readadc c.4,xadc : wTmp = wTmp + xadc
readadc c.4,xadc : wTmp = wTmp + xadc
readadc c.4,xadc : wTmp = wTmp + xadc
readadc c.4,xadc : wTmp = wTmp + xadc
readadc c.4,xadc : wTmp = wTmp + xadc
readadc c.4,xadc : wTmp = wTmp + xadc
readadc c.4,xadc : wTmp = wTmp + xadc
readadc c.4,xadc : wTmp = wTmp + xadc
readadc c.4,xadc : wTmp = wTmp + xadc
readadc c.4,xadc : wTmp = wTmp + xadc
base = wTmp / 10
As my module was adjusted, the base reading (10 ADCs averaged) was about 30. A difference from that of 8 signified a strike. I was using a Martin Backpacker guitar with the module poked through the soundhole.

I say "partially", because the very lightest plucks were not registered, and for the strongest, the ADC readings were still high after PAUSE 400 (which might be too long, anyway). As a result, the next note might be seen as having been struck before it actually was, because the strings were still vigorously vibrating from the previous strike.

Any other sound module would have to be adjusted for individually. I was surprised and disappointed that the pot on my module did not adjust the sensitivity (to me, the difference between the base and a strike), but only altered where the base was located.


Senior Member
JulianE, how did you hook up the op amp and the microphone module?
Gramps, I was just complementing the microphone module circuit, I used it to hook it up to a geophone, it's a device for detecting seismic activity.
I only used to the first stage of the circuit with a modification, I placed a capacitor in parallel with the R17, the feedback resistor, that would act as a low pass filter. Also, I a used the other half of TL062 as second stage amplification. For the second stage I use less gain, a 330 K feedback resistor. I don't have the sparkfun module but liked the circuit.


Senior Member
lBenson, I really appreciate your sound detector test setup and want to run some tests with the module we have but have been absolutely buried.
Hardly had time to even play my dulcimer yet alone work on this project!
So, from a high speed read of this thread... You are looking for when the strike has occurred. I am assuming the strike always happens successfully and you want to electronically detect when a strike has occurred. If I am correct in understanding this, then is there any reason you could not make use of optics to provide a 1 or 0 to your picaxe using IR sensors such as this...?

Or perhaps if there is somewhere on the hammer in which you could place a very small neodymium magnet that won't impede on the produced audio, you could easily use a hall effect sensor such as this...

Hall effect datasheet to help you understand it's functionality:

Hope this helps.
motifyu--had you noted the photo of the hammered dulcimer which gramps posted a while back--many strings:
View attachment 22738
And somewhat delicate hammers (the heads appear lower right of center).

I did see that image, I am very instrumentally challenged. Sorry, didn't realize what the hammer's were. I was anticipating hammers like in a piano, not hammers one would manually strike the strings with.


Senior Member
sound detector test setup
I'll try again when I get time. Among my findings--in groupings of 10, you can make over 1200 adc readings a second at 4mHz--so even with other code to detect events, you should be able to look often enough to see, say, 5 strikes per second--a pretty fast rate of 300 beats per minute.

I am still thinking about how to detect a new strike before the ringing of the previous one has settled. I can see the strike if I look at a continuous display of the highest of a set of 10 adc readings, but I haven't quite yet figured out the algorithm to capture that programmatically. Being able to see it is a big step towards a solution.
Being extreme with my thoughts... Coming back to use of hall effect sensors, using the right type of hall effect with high sensitivity, you could paint a small area of each string with 'magnetic paint' (yes, it does exist) and re-tune each string if necessary. The varying hall signal could be used to determine the vibrating string that had been struck. A bit extreme I know, but it would work ;-) Doing this would also provide the option of determining the exact frequency.


Senior Member
Benson said , I am still thinking about how to detect a new strike before the ringing of the previous one has settled.
My little Snark tuner can read an individual note very accurately but it can only read one note at a time
35 $0.43 IR sensors would be about $15.
Mounting one on each pair of strings would be a challenge!

After seeing the video's I now have a far better understanding. I now don't think IR sensors would be of help. Sorry for the misunderstanding of the instrument. However, I stand by my idea of using hall effect sensors. I am quite confident you'd get a solid result with this method. You could try it with just a few hall sensors and some magnetic paint to prove my theory. There are differing types of hall effect sensors available on the market. A linear hall sensor would be your choice for this application. Linear hall sensors provide proportional outputs based on magnetic field strength. From the output of the hall sensor you could reliably detect a strike and also if desired, determine the frequency of the vibrating string.


Technical Support
Staff member
I am still thinking about how to detect a new strike before the ringing of the previous one has settled.
It should just be a case of looking for the initial peak when a new note is hit producing a sound volume which is greater than any decaying notes -
A state machine can keep track of whether the input is rising, strike detected, or decaying. Something like -
  Gosub ReadCurrent
  Select Case state
    Case FALLING
      If current > last+10% then
        state = RISING
        count = 0
      End If
    Case RISING
      If current >= last then
        count = count + 1
        If count > 2 Then
          state = DETECTED
          High OUT
        End If
        count = count - 1
      End If
      If current < last-10% Then
        state = FALLING
        Low OUT
      End If
  End Select
  last = current
That's just the bare bones and will need tweaking. You will probably spend some hours staring at a scope watching the input signal and tweaking the code to get the desired pulses on note hits.

One thing I would suggest is a dedicated PICAXE which just produces a digital 'hit' rising edge rather than try and put it all in one PICAXE program along with everything else.
Please elaborate on your idea.

Ok, so as I previously stated, linear hall effect sensors provide a proportional output based on the strength of a magnetic field. The output of a linear hall sensor with no magnetic field detected will output a mid point voltage. If VCC is 5VDC, the output of the sensor with no field detected will be 2.5VDC. If the NORTH pole of a magnet is presented to the sensor face, the voltage will swing toward VCC, while a SOUTH pole will swing the output toward GND or 0 volts. The stronger the field, the stronger the swing.

Ultimately if a small section of a string was coated with magnetic paint and a hall placed right next to it with the hall sensor output connected to a PICaxe ADC input, you could then use the ADC variation as a trigger when a strike occurs.

To experiment with this idea, I would suggest to maybe attach a small magnet to one of the strings perhaps with blu-tac and play around with the code.

With a bit of ingenuity you may be able to mount a small magnet on one side of the string and the hall on the other (Obviously not physically making contacting with the string). When a strike occurs there will be a variation in magnetic flux due to the string physically vibrating between the sensor and magnet, thus giving variation on the hall sensor output, but this may only be effective with steel strings.

Here is a video that clearly demonstrates hall effect functionality.

I hope this explanation is elaborate enough for your appreciation.


Senior Member
In regard to the LM567 - it is an IC specifically made to select a single tone from an audio input. It can be made more or less selective [off pitch a bit] and put out a switched signal 'tone heard - on/off' which can light a light or relay etc. Please look up the data sheet. A few external components need to be attached to the LM567 to determine what frequency it "hears". One LM567 per tone required.

in groupings of 10, you can make over 1200 adc readings a second at 4mHz.
Yes, that's about what I've measured in the past, but I don't think it increases for clock frequencies above 4 MHz. :(

To measure a frequency, the Sampling Theorem (Nyquist) at 1200 Hz, limits the fundamental frequency to about 500 Hz (one octave above middle C). You could probably detect higher frequencies, but there is a problem if the sampling frequency has an integer relationship to the signal (e.g. double). Then there's a risk that all the ADC will "see" is a sequence of (near to) zero-crossing level. That might be solved by taking many more than 10 measurements and/or by introducing timing "glitches" in the ADC reading sequence. But a further issue with trying to detect individual notes by their frequency is: will it work with a repeated note?

"Hardware detection" of the ac signals (from a microphone or hall sensor, etc.) needs only one diode, one capacitor and a resistor or two (to control the attack and decay times). Or I would add one more diode and capacitor to form a "voltage doubler" configuration. You probably need the "attack" to be as fast as possible anyway, so just set the decay time similar to the string / sound-box resonance. Now you only need to detect sudden rises in the detected dc level, either by software or an R-C "differentiator" (high pass filter).

Cheers, Alan.


Senior Member
Yes 35 for 35 tone detection together with external R & C components - repetitive circuitry. You could combine the 35 outputs into a digital to analog converter structure [resistor network] and then feed that output DC to a single READADC pin.

HOWEVER - I've lost track of what the PICAXE is doing - if it's only lighting lights then just drive the lights from the LM357s... sorry no PICAXE... whatever works...


Senior Member
I've lost track of what the PICAXE is doing - if it's only lighting lights then just drive the lights from the LM357s... sorry no PICAXE
The picaxe is determining which LEDs to light, as indicators of which string to strike to play the tune. Strike detection is needed to turn off the LED and proceed to the next note.


Well-known member
I never understood why you weren’t just using “metronome” sequencing for those LEDs. Simply slow it down for training purposes ... like other trainers.


Senior Member
This will probably seem like an off the wall idea, but here goes. It looks like the strings are fairly close together and the hammers are wide. You could get some cheap lasers and shoot them across the dulcimer to detectors on the other side. A sort of beam break detector. One of these every few strings with a detector on the other side. Or one laser and spread it out into a line using this technique with multiple detectors on the other side.
Last edited:


Senior Member
Just an "off the wall" idea for sound detection - a gramophone cartridge. If you had a complete record player, just resting the tone arm on the soundboard would be an easy way to test. Pre-amp and power amp are all built in so you could simply listen to the sound or measure the output at the speaker terminals or line out jacks.