$MUSIC_UI


This JavaScript module handles musical selectors for html pages.

Files to include in HTML file header
<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>

$MUSIC_UI Methods

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.

Examples

$MUSIC_UI.init()

$MUSIC_UI.init(options);

init() Initializes the library to setup language.

Example

JavaScript
$MUSIC_UI.init({'lang':'en'});



$MUSIC_UI.buildTones()

$MUSIC_UI.buildTones(id, tone, cb_update);

buildTones() shows a tone selector.

buildTones calls the given cb_update callback, with the given selected tone.

Example

HTML
<div align="center">a tone selector
    <div id="tonesSelector"></div>
    <br>Selected tone is: <span id="selectedTone" class="big"></span>.
</div>

JavaScript
function updateTone(tone) {
    document.querySelector('#selectedTone').innerHTML = tone;
}
$MUSIC_UI.buildTones('tonesSelector', 'E', updateTone);

a tone selector

Selected tone is: .

$MUSIC_UI.buildTonalities()

$MUSIC_UI.buildTonalities(id, tonality, cb_update);

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.

Note the tonality encoding: mode than tone.

Example

HTML
<div align="center">a tonality selector
    <div id="tonalitiesSelector"></div>
    <br>Selected tonality is: <span id="selectedTonality"></span>.
</div>

JavaScript
function updateTonality(tonality) {
    document.querySelector('#selectedTonality').innerHTML = tonality;
}
$MUSIC_UI.buildTonalities('tonalitiesSelector', 'mF#', updateTonality);

a tonality selector

Selected tonality is: .

$MUSIC_UI.buildMajorTonalities()

$MUSIC_UI.buildMajorTonalities(id, tonality, cb_update);

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.

Note the tonality encoding: mode than tone.

Example

HTML
<div align="center">a major tonality selector
    <div id="majorTonalitiesSelector"></div>
    <br>Selected tonality is: <span id="selectedMajorTonality"></span>.
</div>

JavaScript
function updateMajorTonality(tonality) {
    document.querySelector('#selectedMajorTonality').innerHTML = tonality;
}
$MUSIC_UI.buildMajorTonalities('majorTonalitiesSelector', 'MD', updateMajorTonality);

a major tonality selector

Selected tonality is: .

$MUSIC_UI.buildMinorTonalities()

$MUSIC_UI.buildMinorTonalities(id, tonality, cb_update);

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.

Note the tonality encoding: mode than tone.

Example

HTML
<div align="center">a minor tonality selector
    <div id="minorTonalitiesSelector"></div>
    <br>Selected tonality is: <span id="selectedMinorTonality"></span>.
</div>

JavaScript
function updateMinorTonality(tonality) {
    document.querySelector('#selectedMinorTonality').innerHTML = tonality;
}
$MUSIC_UI.buildMinorTonalities('minorTonalitiesSelector', 'mA', updateMinorTonality);

a minor tonality selector

Selected tonality is: .

$MUSIC_UI.buildSignatures()

$MUSIC_UI.buildSignatures(id, signatures, selected, cb_update);

buildSignatures() shows a chord signature selector.

buildSignatures calls the given cb_update callback, with the given selected signature.

Note that in the signture list, fi you add char '!' behind signature, it's show a line return.

Example

HTML
<div align="center">a chord signature selector
    <div id="signaturesSelector"></div>
    <br>Selected signature is: <span id="selectedSignature" class="big"></span>.
</div>

JavaScript
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: .

$MUSIC_UI.buildModesTable()

$MUSIC_UI.buildModesTable(id, mode, bSeven, tone);

buildModesTable() shows table of chord for each scales of mode.

Example

HTML
<div id="modes-table"></div>

JavaScript
$MUSIC_UI.buildModesTable('modes-table', 14, true, 'E');

$MUSIC_UI.getSignatureClass()

$MUSIC_UI.getSignatureClass(signature);

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:



$MUSIC_UI.getSignatureColor()

$MUSIC_UI.getSignatureColor(signature);

getSignatureColor() returns the color associated to chord signature.

$MUSIC_UI.getSignatureClass('M7') returns '#008040'



$MUSIC_UI.getSignatureNotation()

$MUSIC_UI.getSignatureNotation(signature);

getSignatureNotation() returns the notation associated to chord signature.

$MUSIC_UI.getSignatureNotation('') returns 'Maj'.



$MUSIC_UI.getSignatureHtmlFormat()

$MUSIC_UI.getSignatureHtmlFormat(signature);

getSignatureHtmlFormat() .

$MUSIC_UI.getSignatureHtmlFormat('m7b5')
returns 'm<span class="mn-exp">7b5</span>' seen as m7b5

$MUSIC_UI.getChordHtmlFormat()

$MUSIC_UI.getChordHtmlFormat(fundamental, signature, bass);

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#.



$MUSIC_UI.getChordHtmlFormatFromChord()

$MUSIC_UI.getChordHtmlFormatFromChord(chord);

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.



$MUSIC_UI.getDegreeHtmlFormat()

$MUSIC_UI.getDegreeHtmlFormat(degree);

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.

$MUSIC_UI.getFunctionAttributes()

$MUSIC_UI.getFunctionAttributes(fn);

getFunctionAttributes() Returns the attributes (name, color and background) of a harmonic function.

$MUSIC_UI.getFunctionAttributes('D2') returns
{
 name:'D²',
 background:'#92D050',
 color:'white'
}