What algorithms/filters/whatever would I start looking into to use a
microcontroller/FPGA/digital ICs/analog components to detect the frequency
of a single audio source such a as an electric guitar input? I don't really
even need the actual frequency number, I just somehow need to convert the
input wave into a square wave/pulse that can be used to pulse an LED, for
example.
I used my oscilloscope to look at the signal generated by the guitar, and
it's pretty clean, but it:
1. doesn't look exactly like a sin wave
2. decreases in amplitude over time (and becomes almost exactly like a
sawtooth wave at low amplitudes)
How would I go about extracting the frequency out of this, or getting a
clean pulse corresponding to the frequency (like a square wave, or
whatever)
> Hi all,
>
> What algorithms/filters/whatever would I start looking into to use a
> microcontroller/FPGA/digital ICs/analog components to detect the frequency
> of a single audio source such a as an electric guitar input? I don't really
> even need the actual frequency number, I just somehow need to convert the
> input wave into a square wave/pulse that can be used to pulse an LED, for
> example.
>
> I used my oscilloscope to look at the signal generated by the guitar, and
> it's pretty clean, but it:
>
> 1. doesn't look exactly like a sin wave
> 2. decreases in amplitude over time (and becomes almost exactly like a
> sawtooth wave at low amplitudes)
>
> How would I go about extracting the frequency out of this, or getting a
> clean pulse corresponding to the frequency (like a square wave, or
> whatever)?
Could it be as simple as amplifying into cut off with a transistor or op amp? That should give you a square wave...
watch out for ringing though...
On 4/7/2012 8:21 AM, V G wrote:
> Hi all,
>
> What algorithms/filters/whatever would I start looking into to use a
> microcontroller/FPGA/digital ICs/analog components to detect the frequency
> of a single audio source such a as an electric guitar input? I don't really
> even need the actual frequency number, I just somehow need to convert the
> input wave into a square wave/pulse that can be used to pulse an LED, for
> example.
>
> I used my oscilloscope to look at the signal generated by the guitar, and
> it's pretty clean, but it:
>
> 1. doesn't look exactly like a sin wave
> 2. decreases in amplitude over time (and becomes almost exactly like a
> sawtooth wave at low amplitudes)
>
> How would I go about extracting the frequency out of this, or getting a
> clean pulse corresponding to the frequency (like a square wave, or
> whatever)?
-- John Ferrell W8CCW
“During times of universal deceit,
Telling the TRUTH becomes a revolutionary act”
George Orwell
> How would I go about extracting the frequency out of this, or getting a
> clean pulse corresponding to the frequency (like a square wave, or
> whatever)?
>
Getting a clean pulse: use comparator, it will give you a clean digital signal.
It's possible to use a comparator in a PIC and do processing using the same PIC.
Extracting frequency is more problematic, but can be done in e.g. dsPIC, as
others suggested. If you need to detect a specific frequency, LM565
phase-locked loop is good for audio frequencies.
Sergey Dryga http://beaglerobotics.com
> Getting a clean pulse: use comparator, it will give you a clean digital
> signal.
> It's possible to use a comparator in a PIC and do processing using the
> same PIC.
>
> Extracting frequency is more problematic, but can be done in e.g. dsPIC, as
> others suggested. If you need to detect a specific frequency, LM565
> phase-locked loop is good for audio frequencies.
>
I was thinking about the comparator, but since the amplitude of the signal
gradually falls over a period of a few seconds, how would I constantly
follow and update the cutoff
On Sun, April 8, 2012 9:38 am, V G wrote:
> On Sat, Apr 7, 2012 at 7:36 PM, Sergey Dryga <.....sergeyKILLspam.....dryga.us> wrote:
>
>> Getting a clean pulse: use comparator, it will give you a clean digital
>> signal.
>> It's possible to use a comparator in a PIC and do processing using the
>> same PIC.
>>
>> Extracting frequency is more problematic, but can be done in e.g. dsPIC,
>> as
>> others suggested. If you need to detect a specific frequency, LM565
>> phase-locked loop is good for audio frequencies.
>>
>
>
> I was thinking about the comparator, but since the amplitude of the signal
> gradually falls over a period of a few seconds, how would I constantly
> follow and update the cutoff?
If you want to do it computationally, look at the Goertzel algorithm. It
is, in essence, a single point DFT (discrete Fourier transform). For only
doing a few bins (frequency points), it can take a less cycles than a full
DFT/FFT.
Regards,
Matt
Matt Bennett
Just outside of Austin, TX
30.51,-97.91
The views I express are my own, not that of my employer, a large
multinational corporation that you are familiar with
> > Extracting frequency is more problematic, but can be done in e.g.
> > dsPIC, as others suggested. If you need to detect a specific
> > frequency, LM565 phase-locked loop is good for audio frequencies.
> >
>
>
> I was thinking about the comparator, but since the amplitude of the
> signal gradually falls over a period of a few seconds, how would I
> constantly follow and update the cutoff?
This is where using a dsPic instead of a PIC32 would make sense. Microchip has an AGC library that would maintain the level AIUI in a similar manner to some of the fuzz boxes.
-- Scanned by iCritical.
>
> On Sat, Apr 7, 2012 at 7:36 PM, Sergey Dryga <sergey <at> dryga.us> wrote:
>
> > Getting a clean pulse: use comparator, it will give you a clean digital
> > signal.
> > It's possible to use a comparator in a PIC and do processing using the
> > same PIC.
> >
> > Extracting frequency is more problematic, but can be done in e.g. dsPIC, as
> > others suggested. If you need to detect a specific frequency, LM565
> > phase-locked loop is good for audio frequencies.
> >
>
> I was thinking about the comparator, but since the amplitude of the signal
> gradually falls over a period of a few seconds, how would I constantly
> follow and update the cutoff?
>
Set the trigger level at some low value which you would still consider to be a
signal. Anything above that level will produce "1", below - "0". This way you
eliminate the problem of decay in the amplitude. For an AC-coupled signal
(through a capacitor) the level can be 1/2 V+. Essentially, this will be a
zero-crossing detector. If the noice is too high, increase the trigger level
just above the noise.
Sergey Dryga http://beaglerobotics.com
> Set the trigger level at some low value which you would still consider
> to be a
> signal. Anything above that level will produce "1", below - "0". This
> way you
> eliminate the problem of decay in the amplitude. For an AC-coupled signal
> (through a capacitor) the level can be 1/2 V+. Essentially, this will be a
> zero-crossing detector. If the noice is too high, increase the trigger
> level
> just above the noise.
>
I thought about this too, but the signal is not a clean sin wave. It's
unpredictable and has lots of different signals mixed in, so a fluctuation
mid-period from a wave other than the fundamental frequency can cause a
false trigger.
If I had my camera with me, I'd take a picture of the oscilloscope
It uses a threshold that is a proportion of the output of a peak
detector.
Neat idea, this part makes it easy. MAX9924.
Bob
On Mon, Apr 9, 2012, at 07:07 AM, V G wrote: {Quote hidden}
> On Mon, Apr 9, 2012 at 1:04 AM, Sergey Dryga <sergeyspam_OUTdryga.us> wrote:
>
> > Set the trigger level at some low value which you would still consider
> > to be a
> > signal. Anything above that level will produce "1", below - "0". This
> > way you
> > eliminate the problem of decay in the amplitude. For an AC-coupled signal
> > (through a capacitor) the level can be 1/2 V+. Essentially, this will be a
> > zero-crossing detector. If the noice is too high, increase the trigger
> > level
> > just above the noise.
> >
>
> I thought about this too, but the signal is not a clean sin wave. It's
> unpredictable and has lots of different signals mixed in, so a
> fluctuation
> mid-period from a wave other than the fundamental frequency can cause a
> false trigger.
>
> If I had my camera with me, I'd take a picture of the oscilloscope.
On Sat, 2012-04-07 at 08:21 -0400, V G wrote:
> Hi all,
>
> What algorithms/filters/whatever would I start looking into to use a
> microcontroller/FPGA/digital ICs/analog components to detect the frequency
> of a single audio source such a as an electric guitar input? I don't really
> even need the actual frequency number, I just somehow need to convert the
> input wave into a square wave/pulse that can be used to pulse an LED, for
> example.
>
> I used my oscilloscope to look at the signal generated by the guitar, and
> it's pretty clean, but it:
>
> 1. doesn't look exactly like a sin wave
> 2. decreases in amplitude over time (and becomes almost exactly like a
> sawtooth wave at low amplitudes)
>
> How would I go about extracting the frequency out of this, or getting a
> clean pulse corresponding to the frequency (like a square wave, or
> whatever)?
Do a transform in to the frequency space (DFT or others depending on
what hardware you've got) and usually just select the biggest peak.
You might have program a little more intelligence then that if you the
guitar is being put through distortion stuff, but I doubt it.
If you're update rate is low (say 5Hz) you have lots of options.
> Do a transform in to the frequency space (DFT or others depending on
> what hardware you've got) and usually just select the biggest peak.
>
> You might have program a little more intelligence then that if you the
> guitar is being put through distortion stuff, but I doubt it.
>
> If you're update rate is low (say 5Hz) you have lots of options.
>
I'm leaning towards this option the most. It feels the most logical. I'll
probably use a dsPIC or a PIC32 depending on which chip can give me the
most DSP performance.
5Hz seems like a very reasonable update frequency, I'll probably go with
10Hz or so. What do you mean by "lots of options"?
Around what update frequency should I expect if I use a modern dsPIC or a
PIC32 at full speed
I seem to recall you have an iPhone, check out the free app "n-track tuner" which does a real time fft and displays the spectrum along with the detected note. It will give you some good insight into what you'll have to deal with in the way of strong overtones on a guitar signal.
> On Mon, Apr 9, 2012 at 11:54 AM, Herbert Graf <RemoveMEhkgrafTakeThisOuTgmail.com> wrote:
>
>> Do a transform in to the frequency space (DFT or others depending on
>> what hardware you've got) and usually just select the biggest peak.
>>
>> You might have program a little more intelligence then that if you the
>> guitar is being put through distortion stuff, but I doubt it.
>>
>> If you're update rate is low (say 5Hz) you have lots of options.
>>
>
> I'm leaning towards this option the most. It feels the most logical. I'll
> probably use a dsPIC or a PIC32 depending on which chip can give me the
> most DSP performance.
>
> 5Hz seems like a very reasonable update frequency, I'll probably go with
> 10Hz or so. What do you mean by "lots of options"?
>
> Around what update frequency should I expect if I use a modern dsPIC or a
> PIC32 at full speed?
> I seem to recall you have an iPhone, check out the free app "n-track
> tuner" which does a real time fft and displays the spectrum along with the
> detected note. It will give you some good insight into what you'll have to
> deal with in the way of strong overtones on a guitar signal.
>
Thanks for the tip. I also tried TrueRTA software on my computer on a
signal directly from my electric guitar. The amplitudes of the harmonics
are significant, and sometimes higher(?) than the fundamental frequency.
That's okay. I'll just isolate the lowest frequency peak on the spectral
analysis, since that will be the fundamental frequency