|
|
|
|
|
var StringTablature = require('./string-tablature'); |
|
|
var tabRenderer = require('../render/tab-renderer'); |
|
|
var StringPatterns = require('./string-patterns'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Plugin.prototype.init = function (abcTune, tuneNumber, params, tabSettings) { |
|
|
|
|
|
this.tune = abcTune; |
|
|
this.params = params; |
|
|
this.tuneNumber = tuneNumber; |
|
|
this.inError = false; |
|
|
this.abcTune = abcTune; |
|
|
this.linePitch = 3; |
|
|
this.nbLines = tabSettings.defaultTuning.length; |
|
|
this.isTabBig = tabSettings.isTabBig; |
|
|
this.tabSymbolOffset = tabSettings.tabSymbolOffset; |
|
|
this.capo = params.capo; |
|
|
this.transpose = params.visualTranspose; |
|
|
this.hideTabSymbol = params.hideTabSymbol; |
|
|
this.tablature = new StringTablature(this.nbLines, this.linePitch); |
|
|
var tuning = params.tuning; |
|
|
if (!tuning) { |
|
|
tuning = tabSettings.defaultTuning; |
|
|
} |
|
|
this.tuning = tuning; |
|
|
this.semantics = new StringPatterns(this); |
|
|
}; |
|
|
|
|
|
Plugin.prototype.setError = function (error) { |
|
|
|
|
|
if (error) { |
|
|
this.error = error; |
|
|
this.inError = true; |
|
|
if (this.tune.warnings) { |
|
|
this.tune.warnings.push(error); |
|
|
} else { |
|
|
this.tune.warnings = [error]; |
|
|
} |
|
|
} |
|
|
}; |
|
|
|
|
|
Plugin.prototype.render = function (renderer, line, staffIndex) { |
|
|
|
|
|
if (this.inError) return; |
|
|
if (this.tablature.bypass(line)) return; |
|
|
tabRenderer(this, renderer, line, staffIndex); |
|
|
}; |
|
|
|
|
|
function Plugin() { } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var AbcStringTab = function () { |
|
|
return { name: 'StringTab', tablature: Plugin }; |
|
|
}; |
|
|
|
|
|
module.exports = AbcStringTab; |
|
|
|