.-----.   .----.   .-----.  .-----.         .---. .---.         .---. .---. 
/ ,-.   \ /  ..  \ / ,-.   \/ ,-.   \  .-') /_   |/_   |   .-') /_   |/_   | 
'-'  |  |.  /  \  .'-'  |  |'-'  |  |_(  OO) |   | |   | _(  OO) |   | |   | 
   .'  / |  |  '  |   .'  /    .'  /(,------.|   | |   |(,------.|   | |   | 
 .'  /__ '  \  /  ' .'  /__  .'  /__ '------'|   | |   | '------'|   | |   | 
|       | \  `'  / |       ||       |        |   | |   |         |   | |   | 
`-------'  `---''  `-------'`-------'        `---' `---'         `---' `---' 

100days of guitar day 62

Lick of the Day

e|-----------------|-----------------|-----------------|-----------------|
B|-----------------|-----------------|-----------------|-----------------|
G|-----------------|-----------------|-----------------|-----------------|
D|-------3---------|-----------------|-----------------|-----------------|
A|-----5---5-4-3---|-----3-4-5-------|-----------------|-----------------|
E|-3-3-----------6-|-3-6-------3-----|-----------------|-----------------|

Better Tab 2 Note

Yesterday I posted some code that loads a tab formated file and plays it in sonic-pi. It was using a big fretboard lookup table to figure out what note to play. I figured I could do a little better and use math:

class Tab2note
  def self.getNote (s, fret)
    slist = { :E => ['E', 3],
              :A => ['A', 4],
              :D => ['D', 5],
              :G => ['G', 5],
              :B => ['B', 5],
              :e => ['E', 6]
    }

    notes = ['C','CS','D','DS','E','F','FS','G','GS','A','AS','B']

    start_tone = slist[s][1] 
    inc_key = (notes.index( slist[s][0] ) + fret) / 12
    note = (notes.index( slist[s][0] ) + fret) % 12

    "#{notes[note]}#{(start_tone + inc_key)}"

  end
end

Probably still room for improvement, but at least this version goes over 12 frets.

👈 Prev Day - Home - Next Day 👉