I'd like to resolve 'Comparator interrupt counts' (frequency) to a Musical note & therefore have a table to base a LUT on as follows....
(btw: I've not got the low & high columns mixed up....they are with respect to frequency - as the incoming frequency increases the amount of interrupt counts get less)
Code:Count low High Note 68104 67000 66193 D 64282 66194 62478 D# 60674 62479 58971 E 57269 58972 55662 F 54054 55663 52538 F# 51021 52539 49589 G 48157 49590 46806 G# 45454 46807 44179 A 42903 44180 41699 A# 40495 41700 39359 B 38222 39360 37150 C 36077 37151 35065 C# 34052 35066 33097 D 32141 33098 31239 D# 30337 31240 29486 E 28634 29487 27831 F 27027 27832 26269 F# 25510 26270 24794 G 24078 24795 23403 G# 22727 23404 22089 A 21451 22090 20849 A# 20247 20850 19679 B 19111 19680 18575 C 18038 18576 17532 C# 17026 17533 16548 D 16070 16549 15619 D# 15168 15620 14743 E 14317 14744 13915 F 13513 13916 13134 F# 12755 13135 12397 G 12039 12398 11701 G# 11363 11702 11044 A 10725 11045 10424 A# 10123 10425 9839 B 9555 9840 9287 C5 9019 9288 8766 C# 8513 8767 8274 D 8035 8275 7810 D# 7584 7811 7371 E 7158 7372 6957 F 6756 6958 6567 F# 6377 6568 6198 G 6019 6199 5850 G# 5681 5851 5522 A 5362 5523 5212 A# 5061 5213 4919 B 4777 4920 4643 C 4509 4644 4383 C# 4256 4384 4137 D 4017 4138 3905 D# 3792 3906 3800 E
Therefore if the comparator interrupt count comes in a somewhere between 19680 & 18575.....then I need to establish (look up) what the associated musical note is - in this case a 'C'
If it then changes again to between 4138 & 3905 then it's high 'D#' ....and so on.
Now as a beginner, the simple way I'd approach this is take my comparator 'interrupt count' & go through the list one entry at a time until I get a match.....but if the notes are changing rapidly (&/or are at different ends of the table), then that's quite an overhead - is there a slick way to get to the actual note fast (eg way back, I was taught something in military wrt finding a fault in an electronic cct - the 'split half technique' ...basically to first check if the 'fault' is present at the halfway point in a circuit - if not, split the mid point again and check if it's present there....etc - this quickly gets you to the general area where the fault lies)....I'm sure something similar could be applied like that here?






Bookmarks