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:
-
ctx
CanvasContextHandle to active canvas context
-
pos
XyPosJSON (x,y) position
-
settings
SettingsObj
Returns:
drawMeasure
-
ctx
-
pos
-
settings
-
heavy
Draws a vertical "measure" demarcation line
Parameters:
-
ctx
CanvasContextHandle to active canvas context
-
pos
XyPosJSON (x,y) position
-
settings
SettingsObj -
heavy
Boolif 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:
-
ctx
CanvasContextHandle to active canvas context
-
pos
XyPosJSON (x,y) position
-
tabs
ArrayArray of normalized string data -- space (character) or int (fret number)
-
settings
SettingsObj -
lineWidth
IntLength 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:
-
ctx
CanvasContextHandle to active canvas context
-
pos
XyPosJSON (x,y) position
-
length
IntLength in pixels
-
settings
SettingsObj
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:
-
ukeStrings
Array
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:
-
symbols
Undefined -
minLength
Int
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:
-
ukeStrings
Array
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:
-
frets
Undefined -
symbols
Undefined -
guide
Undefined -
minLength
Int
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:
-
ukeStrings
Array
Returns:
getWidth
-
tabs
-
labelOffset
-
isTruncate
Parameters:
-
tabs
2Darray -
labelOffset
Int -
isTruncate
BoolIf 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:
-
text
StringBlock of text that contains one or more tablature blocks
-
outElement
String 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:
-
ukeStrings
ArrayBlock of tablbabure to be parsed
Returns:
redraw
-
inTabs
-
outElement
Parameters:
-
inTabs
String or arrayBlock of text or four element array containing tablbature to be parsed
-
outElement
String 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:
-
h
DOM-element
Returns:
stripStringLabels
-
ukeStrings
Processes ukeStrings stripping the first character from each line
Parameters:
-
ukeStrings
Array
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)