ukeGeeks.tabs Class
Tablature renderer -- reads tab data and draws canvas elements. Creates "packed" versions of the tabs, including a "key line" that's comprised only of '-' and '*' -- the asterisks denoting where a dot will eventually be placed.
Constructor
ukeGeeks.tabs
()
Item Index
Methods
Properties
Methods
drawLabels
-
ctx -
pos -
settings
Adds the string letters on the left-side of the canvas, before the tablature string lines
Parameters:
-
ctxCanvasContextHandle to active canvas context
-
posXyPosJSON (x,y) position
-
settingsSettingsObj
Returns:
drawMeasure
-
ctx -
pos -
settings -
heavy
Draws a vertical "measure" demarcation line
Parameters:
-
ctxCanvasContextHandle to active canvas context
-
posXyPosJSON (x,y) position
-
settingsSettingsObj -
heavyBoolif TRUE hevy line
Returns:
drawNotes
-
ctx -
pos -
tabs -
settings -
lineWidth
Loop over the normalized tabs emitting the dots/fingers on the passed in canvase
Parameters:
-
ctxCanvasContextHandle to active canvas context
-
posXyPosJSON (x,y) position
-
tabsArrayArray of normalized string data -- space (character) or int (fret number)
-
settingsSettingsObj -
lineWidthIntLength in pixels (used only when line ends with a measure mark)
Returns:
drawStaff
-
ctx -
pos -
length -
settings
Create the staff -- really the four tablature strings
Parameters:
-
ctxCanvasContextHandle to active canvas context
-
posXyPosJSON (x,y) position
-
lengthIntLength in pixels
-
settingsSettingsObj
Returns:
getFretNumbers
-
ukeStrings
Finds the frets in used for each line. In other words, ignoring spacers ("-" or "|") this returns arrays of numbers, the frets in use, for each line.
Parameters:
-
ukeStringsArray
Returns:
getGuideLine
-
symbols -
minLength
OK, having created symbolic representations for the lines in earlier steps here we go through and "merge" them into a single, master "guide" -- saying "somewhere on this beat you'll pluck (or not) one note". This normalized guide will be the master for the next step.
Parameters:
-
symbolsUndefined -
minLengthInt
Returns:
getMinLineLength
-
ukeStrings
Run through all of the strings (array) and return the length of the shortest one. would prefer the max length, but then I'd need to pad the shorter ones and ... well, it's complicated. this gets a TODO: get max!
Parameters:
-
ukeStringsArray
Returns:
getPackedLines
-
frets -
symbols -
guide -
minLength
Using the packed "guide" line we loop over the strings, rebuilding each string with either a space, measure marker, or the note -- as an integer! Now the frets are the same regardless of whether they are single or double digit numbers: a "12" occupies no more horizontal space than a "5".
Parameters:
-
fretsUndefined -
symbolsUndefined -
guideUndefined -
minLengthInt
Returns:
getSymbols
-
ukeStrings
Returns array of the strings with placeholders instead of the numbers. This helps us pack because "12" and "7" now occupy the same space horizontally.
Parameters:
-
ukeStringsArray
Returns:
getWidth
-
tabs -
labelOffset -
isTruncate
Parameters:
-
tabs2Darray -
labelOffsetInt -
isTruncateBoolIf TRUE returns the length of the line, allowing for a terminating "|" character, othwrwise, it's for canvas width
Returns:
init
()
Void
public
Again this is a constructor replacement
Returns:
loadBlocks
-
text -
outElement
Parameters:
-
textStringBlock of text that contains one or more tablature blocks
-
outElementString or DOMEither: (string) the Id to a DOM element, or DOM element handle where the canvas/converted text will be placed.
Returns:
readTabs
-
ukeStrings
This is insanely long, insanely kludgy, but, insanely, it works. This will read break a block of text into four lines (the ukulele strings), then find which frets are used by each. Then, the hard part, pack un-needed dashes. Once it's done that a 2-dimentional array (strings X frets) is created and returned.
Parameters:
-
ukeStringsArrayBlock of tablbabure to be parsed
Returns:
redraw
-
inTabs -
outElement
Parameters:
-
inTabsString or arrayBlock of text or four element array containing tablbature to be parsed
-
outElementString or DOMEither: (string) the Id to a DOM element, or DOM element handle where the canvas/converted text will be placed.
Returns:
replace
-
h
Races through all <pre> tags within h, any with the CSS class of "ugsTabs" will be replaced with the canvas element.
Parameters:
-
hDOM-element
Returns:
stripStringLabels
-
ukeStrings
Processes ukeStrings stripping the first character from each line
Parameters:
-
ukeStringsArray
Returns:
Properties
LAST_STRING_NAME
String
private
(Constant) Last String Name (Note), as above, on Ukulele is a "G". Here for other instruments.
NUM_STRINGS
Int
private
(Constant) Number of Strings (dashed lines of tablature notation) expected. (For now a constant -- ukueleles "always" have four). Making a variable to help support port for other instruments.
tab_settings
JSON
private
alias for external Settings dependencies (helps with complression, too)
