Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unvalved PowerDraw and PowerBender tunings #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
298 changes: 209 additions & 89 deletions harmonica_tablature.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ MuseScore {

id: window
width:280
height: 180
height: 250
ColumnLayout {
id: column
anchors.margins : 10
Expand All @@ -38,102 +38,169 @@ MuseScore {
anchors.right: parent.right
height: 90

ComboBox {
currentIndex: 17
model: ListModel {
id: keylist
property var key
ListElement { text: "Low G"; harpkey: 43 }
ListElement { text: "Low Ab"; harpkey: 44 }
ListElement { text: "Low A"; harpkey: 45 }
ListElement { text: "Low Bb"; harpkey: 46 }
ListElement { text: "Low B"; harpkey: 47 }
ListElement { text: "Low C"; harpkey: 48 }
ListElement { text: "Low C#"; harpkey: 49 }
ListElement { text: "Low D"; harpkey: 50 }
ListElement { text: "Low Eb"; harpkey: 51 }
ListElement { text: "Low E"; harpkey: 52 }
ListElement { text: "Low F"; harpkey: 53 }
ListElement { text: "Low F#"; harpkey: 52 }
ListElement { text: "G"; harpkey: 55 }
ListElement { text: "Ab"; harpkey: 56 }
ListElement { text: "A"; harpkey: 57 }
ListElement { text: "Bb"; harpkey: 58 }
ListElement { text: "B"; harpkey: 59 }
ListElement { text: "C"; harpkey: 60 }
ListElement { text: "Db"; harpkey: 61 }
ListElement { text: "D"; harpkey: 62 }
ListElement { text: "Eb"; harpkey: 63 }
ListElement { text: "E"; harpkey: 64 }
ListElement { text: "F"; harpkey: 65 }
ListElement { text: "F#"; harpkey: 66 }
ListElement { text: "High G"; harpkey: 67 }
RowLayout
{
Label {
text: "Key"
}
width: 100
onCurrentIndexChanged: {
console.debug(keylist.get(currentIndex).text + ", " + keylist.get(currentIndex).harpkey)
keylist.key = keylist.get(currentIndex).harpkey
ComboBox {
currentIndex: 17
model: ListModel {
id: keylist
property var key
ListElement { text: "Low G"; harpkey: 43 }
ListElement { text: "Low Ab"; harpkey: 44 }
ListElement { text: "Low A"; harpkey: 45 }
ListElement { text: "Low Bb"; harpkey: 46 }
ListElement { text: "Low B"; harpkey: 47 }
ListElement { text: "Low C"; harpkey: 48 }
ListElement { text: "Low C#"; harpkey: 49 }
ListElement { text: "Low D"; harpkey: 50 }
ListElement { text: "Low Eb"; harpkey: 51 }
ListElement { text: "Low E"; harpkey: 52 }
ListElement { text: "Low F"; harpkey: 53 }
ListElement { text: "Low F#"; harpkey: 52 }
ListElement { text: "G"; harpkey: 55 }
ListElement { text: "Ab"; harpkey: 56 }
ListElement { text: "A"; harpkey: 57 }
ListElement { text: "Bb"; harpkey: 58 }
ListElement { text: "B"; harpkey: 59 }
ListElement { text: "C"; harpkey: 60 }
ListElement { text: "Db"; harpkey: 61 }
ListElement { text: "D"; harpkey: 62 }
ListElement { text: "Eb"; harpkey: 63 }
ListElement { text: "E"; harpkey: 64 }
ListElement { text: "F"; harpkey: 65 }
ListElement { text: "F#"; harpkey: 66 }
ListElement { text: "High G"; harpkey: 67 }
}
width: 100
onCurrentIndexChanged: {
console.debug(keylist.get(currentIndex).text + ", " + keylist.get(currentIndex).harpkey)
keylist.key = keylist.get(currentIndex).harpkey
}
}
}
ComboBox {
currentIndex: 0
model: ListModel {
id: harp
property var tuning
ListElement { text: "Blues Harp (Richter)"; tuning: 1 }
ListElement { text: "Richter valved"; tuning: 2 }
ListElement { text: "Paddy Richter (Brendan Power), valved"; tuning: 10 }
ListElement { text: "Natural Minor"; tuning: 7 }
ListElement { text: "Melody Maker"; tuning: 8 }
ListElement { text: "Country"; tuning: 3 }
ListElement { text: "Circular (Seydel), valved"; tuning: 5 }
ListElement { text: "Circular (Inversed for blow 1), valved "; tuning: 9 }
ListElement { text: "TrueChromatic Diatonic, valved"; tuning: 6 }
ListElement { text: "Power Bender (Brendan Power), valved"; tuning: 11 }
ListElement { text: "Power Draw (Brendan Power), valved"; tuning: 12 }
ListElement { text: "Standard Chromatic"; tuning: 4 }
RowLayout
{
Label {
text: "Tuning"

}
width: 100
onCurrentIndexChanged: {
console.debug(harp.get(currentIndex).text + ", " + harp.get(currentIndex).tuning)
harp.tuning = harp.get(currentIndex).tuning
ComboBox {
currentIndex: 0
model: ListModel {
id: harp
property var tuning
ListElement { text: "Blues Harp (Richter)"; tuning: 1 }
ListElement { text: "Richter valved"; tuning: 2 }
ListElement { text: "Paddy Richter (Brendan Power), valved"; tuning: 10 }
ListElement { text: "Natural Minor"; tuning: 7 }
ListElement { text: "Melody Maker"; tuning: 8 }
ListElement { text: "Country"; tuning: 3 }
ListElement { text: "Circular (Seydel), valved"; tuning: 5 }
ListElement { text: "Circular (Inversed for blow 1), valved "; tuning: 9 }
ListElement { text: "TrueChromatic Diatonic, valved"; tuning: 6 }
ListElement { text: "Power Bender (Brendan Power)"; tuning: 13 }
ListElement { text: "Power Bender (Brendan Power), half valved"; tuning: 11 }
ListElement { text: "Power Draw (Brendan Power)"; tuning: 14 }
ListElement { text: "Power Draw (Brendan Power), half valved"; tuning: 12 }
ListElement { text: "Standard Chromatic"; tuning: 4 }
}
width: 100
onCurrentIndexChanged: {
console.debug(harp.get(currentIndex).text + ", " + harp.get(currentIndex).tuning)
harp.tuning = harp.get(currentIndex).tuning
}
}
}
ComboBox {
currentIndex: 1
model: ListModel {
id: placetext
property var position
ListElement { text: "Above staff"; position: "above" }
ListElement { text: "Below staff"; position: "below" }
RowLayout
{
Label {
text: "Placement"
}
width: 100
onCurrentIndexChanged: {
console.debug(placetext.get(currentIndex).text + ", " + placetext.get(currentIndex).position)
placetext.position = placetext.get(currentIndex).position
ComboBox {
currentIndex: 1
model: ListModel {
id: placetext
property var position
ListElement { text: "Above staff"; position: "above" }
ListElement { text: "Below staff"; position: "below" }
}
width: 100
onCurrentIndexChanged: {
console.debug(placetext.get(currentIndex).text + ", " + placetext.get(currentIndex).position)
placetext.position = placetext.get(currentIndex).position
}
}
}
}
RowLayout {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: column.bottom
height: 70
Button {
id: okButton
text: "Ok"
onClicked: {
apply()
Qt.quit()
ColumnLayout {
Label {
text: "Breath Indicator"
font.underline: true
}
RowLayout {

Label {
text: "Position"
}
ComboBox {
currentIndex: 0
model: ListModel {
id: breathtext
property var position
ListElement { text: "Left of Hole #"; position: "left" }
ListElement { text: "Right of Hole #"; position: "right" }
}
width: 100
onCurrentIndexChanged: {
console.debug(breathtext.get(currentIndex).text + ", " + breathtext.get(currentIndex).position)
breathtext.position = breathtext.get(currentIndex).position
}
}
}
RowLayout {
Label {
text: "Shown"
}
ComboBox {
currentIndex: 0
model: ListModel {
id: breathIndicator
property var mode
ListElement { text: "Both"; mode: "both" }
ListElement { text: "Blow Only"; mode: "blow_only" }
ListElement { text: "Draw Only"; mode: "draw_only" }
}
width: 100
onCurrentIndexChanged: {
console.debug(breathIndicator.get(currentIndex).text + ", " + breathIndicator.get(currentIndex).mode)
breathIndicator.mode = breathIndicator.get(currentIndex).mode
}
}
}
}
Button {
id: closeButton
text: "Close"
onClicked: { Qt.quit() }
RowLayout {
anchors.horizontalCenter: parent.horizontalCenter
height: 70
Button {
id: okButton
text: "Ok"
onClicked: {
apply()
Qt.quit()
}
}
Button {
id: closeButton
text: "Close"
onClicked: { Qt.quit() }
}
}

}



function tabNotes(notes, text) {

var richter = ["+1", "-1b", "-1", "+1o", "+2", "-2bb", "-2b", "-2", "-3bbb", "-3bb", "-3b", "-3",
Expand Down Expand Up @@ -192,18 +259,28 @@ MuseScore {
"+8", "-8b", "-8", "+9b", "+9", "-9", "+10b", "+10", "-10b", "-10" ]; // Circular/Spiral tuned diatonic
// Inversed for Blow 1. Key of C major scale starts at blow 1

var powerBender = ["+1", "-1b", "-1", "+2b", "+2", "-2bb", "-2b", "-2", "-3bbb", "-3bb", "-3b", "-3",
var powerBenderHalfValved = ["+1", "-1b", "-1", "+2b", "+2", "-2bb", "-2b", "-2", "-3bbb", "-3bb", "-3b", "-3",
"+4", "-4b", "-4", "-5b", "-5", "+6", "-6b", "-6", "+7b", "+7", "-7b", "-7",
"+8", "-8b", "-8", "+9b", "+9", "-9bb", "-9b", "-9", "+10b", "+10", "-10bb", "-10b",
"-10" ];
powerBender[-2] = "+1bb"; powerBender[-1] = "+1b"; //Two notes below the key at blow 1
powerBenderHalfValved[-2] = "+1bb"; powerBenderHalfValved[-1] = "+1b"; //Two notes below the key at blow 1
// Brendan Power's tuning, half valved

var powerDraw = ["+1", "-1b", "-1", "+2b", "+2", "-2bb", "-2b", "-2", "-3bbb", "-3bb", "-3b", "-3",
var powerBender = ["+1", "-1b","-1", "+1o", "+2", "-2bb", "-2b", "-2", "-3bbb", "-3bb", "-3b", "-3",
"+4", "-4b", "-4", "-5b", "-5", "+6", "-6b", "-6", , "+6o", "+7", "-7b", "-7",
"+8", "-8b", "-8","+8o", "+9", "-9bb", "-9b", "-9", "+9o", "+10", "-10bb", "-10b",
"-10","+10o" ];

var powerDraw = ["+1", "-1b", "-1", "+1o", "+2", "-2bb", "-2b", "-2", "-3bbb", "-3bb", "-3b", "-3",
"+4", "-4b", "-4", "+4o", "+5", "-5", "+5o", "+6", "-6b", "-6", "+6o", "+7", "-7b", "-7",
"+8", "-8b", "-8","+8o", "+9", "-9bb", "-9b", "-9", "+9o", "+10", "-10bb", "-10b",
"-10", "+10o"];

var powerDrawHalfValved = ["+1", "-1b", "-1", "+2b", "+2", "-2bb", "-2b", "-2", "-3bbb", "-3bb", "-3b", "-3",
"+4", "-4b", "-4", "+5b", "+5", "-5", "+6b", "+6", "-6b", "-6", "-7b", "-7",
"+8", "-8b", "-8", "+9b", "+9", "-9bb", "-9b", "-9", "+10b", "+10", "-10bb", "-10b",
"-10" ];
powerDraw[-2] = "+1bb"; powerDraw[-1] = "+1b"; //Two notes below the key at blow 1
powerDrawHalfValved[-2] = "+1bb"; powerDrawHalfValved[-1] = "+1b"; //Two notes below the key at blow 1
// Brendan Power's tuning, half valved

var tuning = richter
Expand All @@ -218,8 +295,10 @@ MuseScore {
case 8: tuning = melodyMaker; break;
case 9: tuning = spiral_b1; break;
case 10: tuning = paddyRichter; break;
case 11: tuning = powerBender; break;
case 12: tuning = powerDraw; break;
case 11: tuning = powerBenderHalfValved; break;
case 12: tuning = powerDrawHalfValved; break;
case 13: tuning = powerBender; break;
case 14: tuning = powerDraw; break;
default: tuning = richter; break;
}

Expand All @@ -239,11 +318,52 @@ MuseScore {
else {
if (bendChar !== "b")
tab = tab.replace(/b/g, bendChar);
tab = applyStyleToTabNotes(tab);
text.text = tab + text.text;
}
}
}

function positionBreathIndicator(tab) {
if(breathtext.position !== "right")
return tab;
// MuseScore doesn't appear to have a Regex library
// So, we do this a naive way.
// Assumes harmonicas have 1-99 holes.
var symbol = tab[0];
var isDoubleDigit = false;
if(tab.length >= 3)
{
// Is the third character a digit?
for(var number = 0; number <= 9; number++) {
isDoubleDigit = isDoubleDigit || tab[2] == number;
}
}

var newBreathIndex = isDoubleDigit ? 2 : 1;
var newString ="";
for(var index = 1; index < tab.length; index++) {
newString += tab[index]
if(index == newBreathIndex)
newString += symbol;
}
return newString;
}
function applyStyleToTabNotes(rawTab) {
var finalTab = rawTab;

finalTab = positionBreathIndicator(finalTab);

switch(breathIndicator.mode) {
case "draw_only": finalTab = finalTab.replace("+", ""); break;
case "blow_only": finalTab = finalTab.replace("-", ""); break;
default: finalTab = finalTab; break;
}

return finalTab;
}


function applyToSelection(func) {
if (typeof curScore === 'undefined')
Qt.quit();
Expand Down