This JavaScript module handles musical selectors for html pages.
<link rel="stylesheet" href="css/music.min.css" />
<script src="libs/harmony-1.0.0.min.js"></script>
<script src="libs/music-ui-1.0.0.min.js"></script>
Method | Description |
---|---|
init() | Initializes the library to setup language. |
buildTones() | Shows a tone selector. |
buildTonalities() | Shows a tonality selector. |
buildMajorTonalities() | Shows a major tonality selector. |
buildMinorTonalities() | Shows a minor tonality selector. |
buildSignatures() | Shows a chord signature selector. |
buildModesTable() | Shows table with modes. |
getSignatureClass() | Returns the class to setup background color. |
getSignatureColor() | Returns the color associated to chord signature. |
getSignatureNotation() | Returns the notation associated to chord signature. |
getSignatureHtmlFormat() | Returns the notation in html format for chord signature. |
getChordHtmlFormat() | Returns the chord notation in html format. |
getChordHtmlFormatFromChord() | Returns the chord notation in html format. |
getDegreeHtmlFormat() | Returns the degree notation in html format. |
getFunctionAttributes() | Returns the attributes of a harmonic function. |
init() Initializes the library to setup language.
$MUSIC_UI.init({'lang':'en'});
buildTones() shows a tone selector.
buildTones calls the given cb_update callback, with the given selected tone.
<div align="center">a tone selector
<div id="tonesSelector"></div>
<br>Selected tone is: <span id="selectedTone" class="big"></span>.
</div>
function updateTone(tone) {
document.querySelector('#selectedTone').innerHTML = tone;
}
$MUSIC_UI.buildTones('tonesSelector', 'E', updateTone);
a tone selector
Selected tone is: . |
buildTonalities() shows a tonality selector. It allows to select a major or minor scale tonality.
buildTones calls the given cb_update callback, with the given selected tonality.
<div align="center">a tonality selector
<div id="tonalitiesSelector"></div>
<br>Selected tonality is: <span id="selectedTonality"></span>.
</div>
function updateTonality(tonality) {
document.querySelector('#selectedTonality').innerHTML = tonality;
}
$MUSIC_UI.buildTonalities('tonalitiesSelector', 'mF#', updateTonality);
a tonality selector
Selected tonality is: . |
buildMajorTonalities() shows a major tonality selector. It allows to select a major scale tonality.
buildMajorTonalities calls the given cb_update callback, with the given selected tonality.
<div align="center">a major tonality selector
<div id="majorTonalitiesSelector"></div>
<br>Selected tonality is: <span id="selectedMajorTonality"></span>.
</div>
function updateMajorTonality(tonality) {
document.querySelector('#selectedMajorTonality').innerHTML = tonality;
}
$MUSIC_UI.buildMajorTonalities('majorTonalitiesSelector', 'MD', updateMajorTonality);
a major tonality selector
Selected tonality is: . |
buildMinorTonalities() shows a minor tonality selector. It allows to select a minor scale tonality.
buildMinorTonalities calls the given cb_update callback, with the given selected tonality.
<div align="center">a minor tonality selector
<div id="minorTonalitiesSelector"></div>
<br>Selected tonality is: <span id="selectedMinorTonality"></span>.
</div>
function updateMinorTonality(tonality) {
document.querySelector('#selectedMinorTonality').innerHTML = tonality;
}
$MUSIC_UI.buildMinorTonalities('minorTonalitiesSelector', 'mA', updateMinorTonality);
a minor tonality selector
Selected tonality is: . |
buildSignatures() shows a chord signature selector.
buildSignatures calls the given cb_update callback, with the given selected signature.
<div align="center">a chord signature selector
<div id="signaturesSelector"></div>
<br>Selected signature is: <span id="selectedSignature" class="big"></span>.
</div>
function updateSignature(signature) {
document.querySelector('#selectedSignature').innerHTML = signature;
}
var signatures = [
'Maj', 'm', '°', 'mb5', '+5',
'!7', 'M7', 'Δ', 'm7', 'mM7', '°7',
'!m7b5', 'Ø', '7b5', '7#5', 'M7#5', 'dim7',
'!sus2', 'sus4', '7sus4', '6', 'm6', 'add9'
];
$MUSIC_UI.buildSignatures('signaturesSelector', signatures, 0, updateSignature);
a chord signature selector
Selected signature is: . |
buildModesTable() shows table of chord for each scales of mode.
<div id="modes-table"></div>
$MUSIC_UI.buildModesTable('modes-table', 14, true, 'E');
getSignatureClass() returns the class from music.css to setup background color from chord signature.
$MUSIC_UI.getSignatureClass('M7') returns 'sig-majorM7'
List of possible returned value:
getSignatureColor() returns the color associated to chord signature.
$MUSIC_UI.getSignatureClass('M7') returns '#008040'
getSignatureNotation() returns the notation associated to chord signature.
$MUSIC_UI.getSignatureNotation('') returns 'Maj'.
getSignatureHtmlFormat() .
$MUSIC_UI.getSignatureHtmlFormat('m7b5')
returns 'm<span class="mn-exp">7b5</span>' seen as m7b5
getChordHtmlFormat() returns the chord notation in html format.
$MUSIC_UI.getChordHtmlFormat('G#', '7b9')
returns 'G#<span class="mn-exp">7b9</span>' seen as G#7b9.
$MUSIC_UI.getChordHtmlFormat('G#', '7b9', 'D#')
returns 'G#<span class="mn-exp">7b9</span><span class="normal">/</span>D#'
seen as G#7b9/D#.
getChordHtmlFormatFromChord() returns the chord notation in html format.
$MUSIC_UI.getChordHtmlFormatFromChord('EbM7,9')
returns 'Eb<span class="mn-exp">M7,9</span>' seen as EbM7,9
$MUSIC_UI.getChordHtmlFormatFromChord('Gb7#9/Db')
returns 'Gb<span class="mn-exp">7#9</span><span class="normal">/</span>Db'
seen as Gb7#9/Db.
getDegreeHtmlFormat() returns the degree notation in html format.
$MUSIC_UI.getDegreeHtmlFormat('bII=N6') returns 'bII=N6' seen as bII=N6.
$MUSIC_UI.getDegreeHtmlFormat('+6') returns '+6' seen as +6.
$MUSIC_UI.getDegreeHtmlFormat('It+6')
returns 'It<span class="mn-exp">+6</span>' seen as It+6.
$MUSIC_UI.getDegreeHtmlFormat('Fr+6')
returns 'Fr<span class="mn-exp">+6</span>' seen as Fr+6.
$MUSIC_UI.getDegreeHtmlFormat('Ger+6')
returns 'Ger<span class="mn-exp">+6</span>' seen as Ger+6.
$MUSIC_UI.getDegreeHtmlFormat('IV7')
returns 'VI<span class="mn-exp">7</span>' seen as VI7.
getFunctionAttributes() Returns the attributes (name, color and background) of a harmonic function.
$MUSIC_UI.getFunctionAttributes('D2') returns
{
name:'D²',
background:'#92D050',
color:'white'
}