Wednesday 30 October 2013

Ready to build a soldered version

So although I thought I had the final circuit, I didn't. I added an additional digital pot to the feedback loop of the pre-amp to allow me to boost output when the tuner was engaged and lower it again so as to avoid clipping when being played more dynamically (that's strumming the guitar to you and me).

I also did some more work on the tuner code, switching from the slope detecting code to a Yin algorithm that works by shifting the waveform until it overlaps as accurately as possible. Initially I tried this in fixed point, but had all kinds of problems avoiding overflow and still keeping accuracy, plus I then needed 32 bit integers and managed to fill up the 8K RAM you have for data on the Mega card. I did try shifting some static variables into program memory rather than RAM, but that made code almost unreadable. Instead I managed to optimise out a lot of static data, such as my frequency look up tables, and was then fit in a good sized buffer to enable a sufficiently large waveform for the Yin algorithm. For the high E, this is easy, for the low E, it was challenging to get a couple of cycles.

Further tweaking allowed me to lower the sample rate as guitar strings are quite low frequency, meaning more cycles captured, and then I used floating point instead of fixed point. Although this is undoubtedly slower, it is actually just about fast enough and updates about once a second. I'll try to improve on this by moving as much as possible into the integer domain and only use float when strictly necessary, but for now fixed point seems to be impossible to tune for the Yin algorithm on an Arduino. Or more properly I haven't had the time to work out where it goes wrong and find a solution.

So here is the probable final channel circuit with the target guitar.


3 comments:

  1. hi, mine just stopped working after I plugged a bad stereo cable into the power supply. Any idea?

    ReplyDelete
  2. You may have damaged the power supply. They are quite a simple design, so any local electronics guys should be able to fix it.

    ReplyDelete
    Replies
    1. Thank's for your reply! I feel less hopeless now.

      Delete