From 867249706babea4de138527bdddc49a838253dff Mon Sep 17 00:00:00 2001
From: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
Date: Mon, 26 Dec 2022 18:27:04 +0900
Subject: [PATCH 01/10] Update README.md
Signed-off-by: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
---
README.md | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
index 3b2ec08..7d38723 100644
--- a/README.md
+++ b/README.md
@@ -1,20 +1,15 @@
-# Kalimba-sheet-music-writer 1.0.1
+# Kalimba-sheet-music-writer 1.0.2
## Usage:
1. Select a file with the file selector.
2. Click Play!
That's it!
## Release notes:
-* Remove jQuery
-* Minor code fixes
-
## example:
-[Example page](https://urobot2011.github.io/Kalimba-sheet-music-writer/ "Example page")
+[Example page](https://urobot2011.github.io/Kalimba-sheet-music-writer-example/V1.0.2/ "Example page")
#### Kalimba-sheet-music-writer-example-page repository here:
[Kalimba-sheet-music-writer-example-page](https://github.com/urobot2011/Kalimba-sheet-music-writer-example-page "Kalimba-sheet-music-writer-example-page")
## Libraries used:
From 561ccd608d8d8cd57bab6dae9b9eb0e14233b1b5 Mon Sep 17 00:00:00 2001
From: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
Date: Wed, 28 Dec 2022 13:08:59 +0900
Subject: [PATCH 02/10] Update README.md
Signed-off-by: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
---
README.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 7d38723..3a73060 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,9 @@ That's it!
## Release notes:
* ...
## Updating:
-- [ ] ...
+- [ ] Notes setting function
+- [ ] linked with the keyboard
+- [ ] Works with Master Keyboard
## example:
[Example page](https://urobot2011.github.io/Kalimba-sheet-music-writer-example/V1.0.2/ "Example page")
From cbe75b2b0b69a2d5b10b1a71a92e83773f10a850 Mon Sep 17 00:00:00 2001
From: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
Date: Wed, 28 Dec 2022 15:22:04 +0900
Subject: [PATCH 03/10] Update index.html
Signed-off-by: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
---
index.html | 186 +++++++++++++++++++++++++++++++----------------------
1 file changed, 108 insertions(+), 78 deletions(-)
diff --git a/index.html b/index.html
index 479faf5..d667a35 100644
--- a/index.html
+++ b/index.html
@@ -1,82 +1,112 @@
-
-
-
- Kalimba sheet music writer V1.0.1
-
-
-
-
-
-
+ Loading soundfont...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Kalimba sheet music writer
1.0.2
+
+
+
+
+
+
+
+
+
+
From 5aab7f3b0e9353a65d6870c890c9e187cb87d227 Mon Sep 17 00:00:00 2001
From: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
Date: Wed, 28 Dec 2022 15:22:37 +0900
Subject: [PATCH 04/10] Update script.js
Signed-off-by: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
---
script.js | 98 +++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 84 insertions(+), 14 deletions(-)
diff --git a/script.js b/script.js
index 18175cf..17ba5e4 100644
--- a/script.js
+++ b/script.js
@@ -23,6 +23,70 @@ var stopbuttondiv = document.querySelector('#stop-button');
var resetbuttondiv = document.querySelector('#reset-button');
var tempobuttondiv = document.querySelector('.tempo');
+var shownumbersbuttondiv = document.querySelector('#show_numbers');
+
+window.addEventListener("keyup", (e) => console.log(e));
+window.addEventListener("keydown", (e) => console.log(e));
+
+var notetonumber = function(note) {
+ switch (note) {
+ case "C4":
+ return "1";
+ break;
+ case "D4":
+ return "2";
+ break;
+ case "E4":
+ return "3";
+ break;
+ case "F4":
+ return "4";
+ break;
+ case "G4":
+ return "5";
+ break;
+ case "A4":
+ return "6";
+ break;
+ case "B4":
+ return "7";
+ break;
+ case "C5":
+ return "1";
+ break;
+ case "D5":
+ return "2";
+ break;
+ case "E5":
+ return "3";
+ break;
+ case "F5":
+ return "4";
+ break;
+ case "G5":
+ return "5";
+ break;
+ case "A5":
+ return "6";
+ break;
+ case "B5":
+ return "7";
+ break;
+ case "C6":
+ return "1";
+ break;
+ case "D6":
+ return "2";
+ break;
+ case "E6":
+ return "3";
+ break;
+ default:
+ return "";
+ break;
+ }
+}
+
var changeTempo = function(tempo) {
Player.tempo = tempo;
}
@@ -38,7 +102,7 @@ var pause = function() {
}
var stop = function() {
- if(lesson_modediv.checked){
+ if (lesson_modediv.checked) {
lesson_modediv.checked = false;
clearTimeout(timeoutId);
clearTimeout(timeoutId2);
@@ -87,9 +151,15 @@ var playmidi = function(event) {
Player.setTempo(tempodiv.value);
if (event.name == 'Note on' && event.velocity > 0) {
//$('key-note-animation').append('');
- keynoteanimationdiv.insertAdjacentHTML("afterbegin", `
+ if (shownumbersbuttondiv.checked) {
+ keynoteanimationdiv.insertAdjacentHTML("afterbegin", `
+ ` + notetonumber(event.noteName) + `
+ `);
+ } else {
+ keynoteanimationdiv.insertAdjacentHTML("afterbegin", `
`);
+ }
}
setTimeout(function() {
if (event.name == 'Note on') {
@@ -110,7 +180,7 @@ var playmidi = function(event) {
}
var lesson_mode = function(event) {
- if(lesson_modediv.checked){
+ if (lesson_modediv.checked) {
playmidi(event);
timeoutId = setTimeout(function() {
pause();
@@ -125,10 +195,10 @@ var lesson_mode = function(event) {
// playmidi(event);
// }, 12000);
timeoutId2 = setTimeout(function() {
- play();
+ play();
}, 7500);
}
- if(!lesson_modediv.checked){
+ if (!lesson_modediv.checked) {
clearTimeout(timeoutId);
clearTimeout(timeoutId2);
clearTimeout(timeoutId3);
@@ -143,13 +213,13 @@ Soundfont.instrument(ac, 'kalimba').then(function(instrumentnow) {
instrument = instrumentnow;
loadingdiv.style.display = 'none';
selectfilediv.style.display = 'block';
-
+
keydivs.forEach((key) => {
key.addEventListener("click", function(e) {
instrument.play(e.target.dataset.note.replace(/C-1/gi, 'C4')); //.replace(/C-1/gi, 'C4')
});
});
-
+
loadFile = function() {
Player.stop();
var file = document.querySelector('input[type=file]').files[0];
@@ -161,26 +231,26 @@ Soundfont.instrument(ac, 'kalimba').then(function(instrumentnow) {
playmidi(event);
lesson_mode(event);
});
-
+
Player.loadArrayBuffer(reader.result);
-
+
playbuttondiv.removeAttribute('disabled');
-
+
play();
}, false);
}
-
+
loadDataUri = function(dataUri) {
bool1 = 0;
Player = new MidiPlayer.Player(function(event) {
playmidi(event);
lesson_mode(event);
});
-
+
Player.loadDataUri(dataUri);
-
+
playbuttondiv.removeAttribute('disabled');
-
+
}
loadDataUri(We_Wish_Merry_Christma);
});
From 9128bde01d7fadc71494200b7eb5692a6865e27e Mon Sep 17 00:00:00 2001
From: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
Date: Wed, 28 Dec 2022 15:22:56 +0900
Subject: [PATCH 05/10] Update README.md
Signed-off-by: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
---
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 3a73060..7dbc247 100644
--- a/README.md
+++ b/README.md
@@ -4,9 +4,10 @@
2. Click Play!
That's it!
## Release notes:
+* Notes setting function
* ...
## Updating:
-- [ ] Notes setting function
+- [x] Notes setting function
- [ ] linked with the keyboard
- [ ] Works with Master Keyboard
## example:
From 76eb1806840939ff093e34b2d38d97d76d426ab1 Mon Sep 17 00:00:00 2001
From: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
Date: Wed, 28 Dec 2022 18:11:32 +0900
Subject: [PATCH 06/10] Update README.md
Signed-off-by: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 7dbc247..3e06af1 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ That's it!
- [ ] Works with Master Keyboard
## example:
-[Example page](https://urobot2011.github.io/Kalimba-sheet-music-writer-example/V1.0.2/ "Example page")
+[Example page](https://urobot2011.github.io/Kalimba-sheet-music-writer-example-page/V1.0.2/ "Example page")
#### Kalimba-sheet-music-writer-example-page repository here:
[Kalimba-sheet-music-writer-example-page](https://github.com/urobot2011/Kalimba-sheet-music-writer-example-page "Kalimba-sheet-music-writer-example-page")
## Libraries used:
From 0017bd4cc50b90f795503b7db35b186169e46c63 Mon Sep 17 00:00:00 2001
From: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
Date: Thu, 29 Dec 2022 18:47:40 +0900
Subject: [PATCH 07/10] Update index.html
Signed-off-by: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
---
index.html | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/index.html b/index.html
index d667a35..847cbbd 100644
--- a/index.html
+++ b/index.html
@@ -41,8 +41,22 @@
From f27c1117500f40ddaed2cd9e3e0d83bbfe2116fe Mon Sep 17 00:00:00 2001
From: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
Date: Thu, 29 Dec 2022 18:48:22 +0900
Subject: [PATCH 08/10] Update script.js
Signed-off-by: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
---
script.js | 94 +++++++++++++++++++++----------------------------------
1 file changed, 36 insertions(+), 58 deletions(-)
diff --git a/script.js b/script.js
index 17ba5e4..807d7a8 100644
--- a/script.js
+++ b/script.js
@@ -24,67 +24,45 @@ var resetbuttondiv = document.querySelector('#reset-button');
var tempobuttondiv = document.querySelector('.tempo');
var shownumbersbuttondiv = document.querySelector('#show_numbers');
+var keyboardlayoutbuttondiv = document.querySelector('#keyboard_layout');
-window.addEventListener("keyup", (e) => console.log(e));
-window.addEventListener("keydown", (e) => console.log(e));
+window.addEventListener("keydown", function (e) {
+ var key = notetonote(keyboardtonote(e.key));
+ if (keyboardlayoutbuttondiv.checked) {
+ key = keyboardtonote(e.key);
+ }
+ console.log(key);
+ var notediv = document.querySelector('[data-note="' + key + '"]');
+ notediv.classList.add("key_active");
+ instrument.play(key);
+});
-var notetonumber = function(note) {
- switch (note) {
- case "C4":
- return "1";
- break;
- case "D4":
- return "2";
- break;
- case "E4":
- return "3";
- break;
- case "F4":
- return "4";
- break;
- case "G4":
- return "5";
- break;
- case "A4":
- return "6";
- break;
- case "B4":
- return "7";
- break;
- case "C5":
- return "1";
- break;
- case "D5":
- return "2";
- break;
- case "E5":
- return "3";
- break;
- case "F5":
- return "4";
- break;
- case "G5":
- return "5";
- break;
- case "A5":
- return "6";
- break;
- case "B5":
- return "7";
- break;
- case "C6":
- return "1";
- break;
- case "D6":
- return "2";
- break;
- case "E6":
- return "3";
- break;
- default:
- return "";
- break;
+window.addEventListener("keyup", function (e) {
+ var key = notetonote(keyboardtonote(e.key));
+ if (keyboardlayoutbuttondiv.checked) {
+ key = keyboardtonote(e.key);
}
+ console.log(key);
+ var notediv = document.querySelector('[data-note="' + key + '"]');
+ notediv.classList.remove("key_active");
+});
+
+var notetonumber = function(note) {
+ var notes = ["C4", "D4", "E4", "F4", "G4", "A4", "B4", "C5", "D5", "E5", "F5", "G5", "A5", "B5", "C6", "D6", "E6"];
+ var notenumbers = ["1", "2", "3", "4", "5", "6", "7", "1", "2", "3", "4", "5", "6", "7", "1", "2", "3"];
+ return notenumbers[notes.indexOf(note)];
+}
+
+var keyboardtonote = function(keyboard) {
+ var keyboards = ["`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "Backspace", "Insert", "Home", "PageUp"];
+ var notes = ["C4", "D4", "E4", "F4", "G4", "A4", "B4", "C5", "D5", "E5", "F5", "G5", "A5", "B5", "C6", "D6", "E6"];
+ return notes[keyboards.indexOf(keyboard)];
+}
+
+var notetonote = function(note) {
+ var notes = ["C4", "D4", "E4", "F4", "G4", "A4", "B4", "C5", "D5", "E5", "F5", "G5", "A5", "B5", "C6", "D6", "E6"];
+ var notes1 = ["D6", "B5", "G5", "E5", "C5", "A4", "F4", "D4", "C4", "E4", "G4", "B4", "D5", "F5", "A5", "C6", "E6"];
+ return notes1[notes.indexOf(note)];
}
var changeTempo = function(tempo) {
From fd64f415cae44114912dda2a2eb4c0f64dcc9f12 Mon Sep 17 00:00:00 2001
From: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
Date: Thu, 29 Dec 2022 18:48:55 +0900
Subject: [PATCH 09/10] Update README.md
Signed-off-by: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
---
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 3e06af1..3b5c3f2 100644
--- a/README.md
+++ b/README.md
@@ -5,10 +5,11 @@
That's it!
## Release notes:
* Notes setting function
+* linked with the keyboard
* ...
## Updating:
- [x] Notes setting function
-- [ ] linked with the keyboard
+- [x] linked with the keyboard
- [ ] Works with Master Keyboard
## example:
From aa88d0e76ec53e442efcdade5e46b6009a77ab47 Mon Sep 17 00:00:00 2001
From: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
Date: Fri, 30 Dec 2022 09:16:15 +0900
Subject: [PATCH 10/10] Update README.md
Signed-off-by: esp32-urobot <75105147+urobot2011@users.noreply.github.com>
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index 3b5c3f2..a11b5c2 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,7 @@ That's it!
## Updating:
- [x] Notes setting function
- [x] linked with the keyboard
+- [ ] Automatically adjust note length
- [ ] Works with Master Keyboard
## example: