Heroku app link for the landing page: https://peaceful-river-42856.herokuapp.com/
Link to the documentation: https://peaceful-river-42856.herokuapp.com/docs/index.html
Download the following source code files to your project's directory:
- Library JavaScript file:
lyrichord.js
- Library CSS file:
lyrichord.css
Include the following scripts on your webpage (in the same order):
<link rel="stylesheet" type="text/css" href="[path to the directory in which you put the library CSS source code]/lyrichord.css">
<script defer src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script defer type="text/javascript" src='[path to the directory in which you put the library JavaScript source code]/lyrichord.js'></script>
// Create a general song info instance
const song_info = new GeneralSongInfo('Knockin On Heaven\'s Door', 'Bob Dylan', 'The Essential Bob Dylan');
// Create the DOM element you want the song sheet to be displayed in
const song_container = document.createElement('div');
// Make the chords of the song.
const G = new Chord('G', [3, 2, 0, 0, 0, 3]);
G.add_shape([3, 5, 5, 4, 3, 3], {3: [1, 6]});
const D = new Chord('D', [-1, -1, 0, 2, 3, 2]);
const Am7 = new Chord('Am7', [-1, 0, 2, 0, 1, 0]);
const C = new Chord('Am7', [-1, 3, 2, 0, 1, 0]);
// Create a chord group
// ** Note that in each LyricChordPair instance, the chord is to be played together with the text counterpart.
const verse = new LyricChordGroup(
'VERSE',
[new LyricChordLine(
[new LyricChordPair('Mama take', G),
new LyricChordPair('this badge off', D),
new LyricChordPair('of me', Am7)]),
new LyricChordLine(
[new LyricChordPair('I can\'t', G),
new LyricChordPair('use it', D),
new LyricChordPair('anymore...', D)])
]
)
// Create a song content instance
const content = new SongContent([verse]);
// Create the song sheet instance
const song = new SongSheet(song_info, content);
// Display the song sheet inside the container created above
song.display(song_container);
// Optional: add the container to the body of DOM
const body = document.querySelector('body');
body.appendChild(song_container)
Link to the documentation: https://peaceful-river-42856.herokuapp.com/docs/index.html
- GeneralSongInfo
Class representing the general song info.
- Chord
Class representing a Chord object.
- LyricChordPair
Class representing the lyric-chord pair objects of the song sheet. In terms of representation, the chord part in the pair is to be played together with the text part.
- LyricChordLine
Class representing a line of lyric-chord pairs.
- LyricChordGroup
Class representing a group of lyric-chord lines.
- SongContent
Class representing the song content portion of the song sheet (lyrics and chords).
- SongSheet
Class representing the song sheet object.
Class representing the general song info.
Kind: global class
Create a general song info section.
Param | Type | Default | Description |
---|---|---|---|
[name] | String |
The name of the song. | |
[artist] | String |
The name of the song. | |
[album] | String |
The album name of the song. | |
[tuning] | String |
'eadgbe' |
The tuning of the song. |
[capo] | Number |
0 |
The fret number to put the capo on. |
[key] | String |
The key of the song. | |
[instrument] | String |
'Guitar' |
The string instrument name of the music sheet chords (e.g. 'Guitar' , 'Bass' , 'Ukulele' ). |
Display general song info on DOM.
Kind: instance method of GeneralSongInfo
Param | Type | Default | Description |
---|---|---|---|
[container] | Element |
document.querySelector('body') |
The element object to put the display element in. |
Class representing a Chord object.
Kind: global class
Param | Type | Default | Description |
---|---|---|---|
[name] | String |
The name of the chord. | |
fret_nums | Array.<Number> |
The fret number representation of the primary shape of 6hechord, i.e. n_i represents which fret to hold for string i .
|
|
[barres] | Object.<Number, Array.<Number>> |
The barres on the primary shape of the chord with the key as the fret number and the value array as [start_string , end_string] .
|
|
[display_in_popup] | Boolean |
true |
Boolean representing the initial indication of whether the chord should be displayed as popup. |
Add additional chord shape to a Chord
to display on pages of chord's carousel.
Kind: instance method of Chord
Param | Type | Description |
---|---|---|
fret_nums | Array.<Number> |
The fret number representation of the chord, i.e. n_i represents which fret to hold for string i .
|
[barres] | Object.<Number, Array.<Number>> |
The barres on the chord with the key as the fret number and the value array as[start_string , end_string] .
|
Display chord on DOM.
Kind: instance method of Chord
Param | Type | Default | Description |
---|---|---|---|
[container] | Element |
document.querySelector('body') |
The element object to put the display element in. |
[chords_section] | Boolean |
false |
Boolean indicating whether it is being displayed on the song chords section of the song sheet (since they are formatted differently) |
[popup] | Boolean |
Boolean indicating whether the chord should be displayed as a popup. |
Class representing the lyric-chord pair objects of the song sheet. In terms of representation, the chord part in the pair is to be played together with the text part.
Kind: global class
Param | Type | Default | Description |
---|---|---|---|
[text] | String |
The lyrical part of the pair. | |
[chord] | Chord |
The chord part of the pair. |
Display the lyric-chord pair on DOM.
Kind: instance method of LyricChordPair
Param | Type | Default | Description |
---|---|---|---|
[container] | Element |
document.querySelector('body') |
The element object to put the display element in. |
[format_single_chord] | Boolean |
false |
Format the corresponding chord's display on the song sheet. e.g. for instrumental portion of a non instrumental song |
[popup] | Boolean |
false |
Boolean indicating whether the corresponding chord should be displayed as popup. |
Class representing a line of lyric-chord pairs.
Kind: global class
Param | Type | Description |
---|---|---|
pairs | Array.<LyricChordPair> |
Array of lyric-chord pairs to be displayed togehter on the line. |
Add a lyric-chord pair to the line object.
Kind: instance method of LyricChordLine
Param | Type | Description |
---|---|---|
pair | LyricChordPair |
The lyric-chord pair to be added. |
Display lyric-chord line on DOM.
Kind: instance method of LyricChordLine
Param | Type | Default | Description |
---|---|---|---|
[container] | Element |
document.querySelector('body') |
The element object to put the display element in. |
[popup] | Boolean |
Boolean indicating whether the chords of the lyric-chord pairs on the line should be displayed as a popup. |
Class representing a group of lyric-chord lines.
Kind: global class
Param | Type | Description |
---|---|---|
[title] | String |
Name of the lyric-chord group (e.g. 'CHORUS' , 'SOLO' , etc.) |
lines | Array.<LyricChordLine> |
Array of lyric-chord lined to be displayed togehter in the group. |
Add a lyric-chord line to the line object.
Kind: instance method of LyricChordGroup
Param | Type | Description |
---|---|---|
line | LyricChordLine |
The lyric-chord line to be added. |
Display lyric-chord group on DOM.
Kind: instance method of LyricChordGroup
Param | Type | Default | Description |
---|---|---|---|
[container] | Element |
document.querySelector('body') |
The element object to put the display element in. |
[popup] | Boolean |
Boolean indicating whether the chords of the lyric-chord pairs on the lines of the group should be displayed as a popup. |
Class representing the song content portion of the song sheet (lyrics and chords).
Kind: global class
Param | Type | Description |
---|---|---|
groups | Array.<LyricChordGroup> |
Array of lyric-chord groups of the song content. |
Generates and returns the DOM element of the song content.
Kind: instance method of SongContent
Param | Type | Default | Description |
---|---|---|---|
[popup] | Boolean |
Boolean indicating whether the chords in the song content should be displayed as popups. |
Display song content on DOM.
Kind: instance method of SongContent
Param | Type | Default | Description |
---|---|---|---|
[container] | Element |
document.querySelector('body') |
The element object to put the display element in. |
[popup] | Boolean |
Boolean indicating whether the chords of the song content should be displayed as a popup. |
Class representing the song sheet object.
Kind: global class
Param | Type | Default | Description |
---|---|---|---|
song_info | GeneralSongInfo |
General song info part of the song. | |
song_content | SongContent |
Song content part of the song. | |
[display_all_chords] | Boolean |
true |
Option to have a section on the song sheet to display all chords together. |
[popup_format] | Boolean |
true |
Boolean indicating whether the chords of the song should be displayed as popups. |
Returns the dom element of the chord section or null if there are no chords in the song.
Kind: instance method of SongSheet
Display song sheet on DOM
Kind: instance method of SongSheet
Param | Type | Default | Description |
---|---|---|---|
[container] | Element |
document.querySelector('body') |
The element object to put the display element in. |