Hi peeps,
Since starting this threa, I went away & knocked up a little program to monitor a DC level at a PIC input pin & then output a PWM stream accordingly ...it increases the PWM duty cycle if the incoming DC level is too low & vice versa...it works well.
But now I'm thinking it would be really cool if I didn't have to rectify the incoming analogue guitar signal first (ie to derive DC level for the PIC input pin)...as this means I could do away with 6 x rectification circuits (& space is tight) ....there must be a slicker way of doing this in software?
The frequency 'band' of each string is quite small ...therefore what my 'concept is', is to work out the highest frequency per string (I'm monitoring each string individually) & sample the signal level at a fast enough rate to make sure the highest frequency 'peak' is detected.
A highest fretted top E string is about 1kHhz (give or take!), which means the shortest time between 'peaks' will be 1ms. I guess that I'd need to take a reasonable amount of samples to make sure I catch 'peak' ...I'm thinking 64 samples within that 1ms. (guitar signals aren't exactly sine waves, but they're not square waves either so I'm thinking 64 samples ought to get me very close to 'peak')
Therefore 1ms divided by 64 samples = 15us between samples.
Is a PIC up to this level of AtoD rate? (there'd be six different individual strings to sample).
Now, I'm no programmer & I find myself having to learn this PIC programming melarkey out of need, so at a high concept level, how does this sound...
Start looping (to be done every 15us for 1ms)
'sample1' - store result in a Variable1
'sample2' - compare result to Variable1, if it's less do nothing, if it's more update Variable1
'sample3 - compare result if less do nothing, if more update Variable1
& so on...
after 1ms stop stampling - the data stored in 'Variable1' is the peak.
Now go and 'act upon' the data.
Start next loop sampling cycle
Does this sound about right?
Have I missed anything?
Does anyone have a link to some suitable sample code to get me started?




Bookmarks