A speed-tatstic way to look up a value? (LUTs)


Results 1 to 13 of 13

Threaded View

  1. #8
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cncmachineguy View Post
    Well I only count 32 notes, but I'm on my phone so maybe I don't get to see the whole thing.
    Sorry, should have made it clear...the table I posted above is actually longer, but I shortened it to be easier on the eye! (the jist of the table was just to show the methodology of converting incoming frequency (guitar notes), to counts (comparator1 interrupt counts) & finally the end goal - a midi note value.

    the LUT will only have something like this (first two columns are upper and lower comparator 'counts' for each individual musical note boundary)

    Code:
    Lo       Hi       Midi Note 
    62479	58971	28
    58972	55662	29
    55663	52538	2A
    52539	49589	2B
    49590	46806	2C
    46807	44179	2D
    44180	41699	2E
    41700	39359	2F
    39360	37150	30
    37151	35065	31
    35066	33097	32
    33098	31239	33
    31240	29486	34
    29487	27831	35
    27832	26269	36
    26270	24794	37
    24795	23403	38
    23404	22089	39
    22090	20849	3A
    20850	19679	3B
    19680	18575	3C
    18576	17532	3D
    17533	16548	3E
    16549	15619	3F
    15620	14743	40
    14744	13915	41
    13916	13134	42
    13135	12397	43
    12398	11701	44
    11702	11044	45
    11045	10424	46
    10425	9839	47
    9840	9287	48
    9288	8766	49
    8767	8274	4A
    8275	7810	4B
    7811	7371	4C
    7372	6957	4D
    6958	6567	4E
    6568	6198	4F
    6199	5850	50
    5851	5522	51
    5523	5212	52
    5213	4919	53
    4920	4643	54
    4644	4383	55
    4384	4137	56
    4138	3905	57
    3906	3800	58
    There are about 50 individual notes on a guitar - from lowest open E (82.4Hz) thru the highest E fretted at the 24th fret of the top E string (1318.51Hz)....so an LUT will need an array 50 deep & a check condition along these lines for any change in the count value...

    Code:
    if (comp1time>= 66194 and comp1time <= 62478) then note = $27
    but to apply 50 of code like that each & every time guitar note changes is going to get time consuming, hence wanting something like a binary search algorithm for picbasic (a search on the forum yields almost nothing)
    Last edited by HankMcSpank; - 3rd October 2010 at 21:34.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts