Skip to content

Commit

Permalink
Bug fixes and updates to Chords experiment
Browse files Browse the repository at this point in the history
Use Poppins instead of Roboto, remove chord label, fixes for iOS tapper, decrease time between chords
  • Loading branch information
bretmorris committed Feb 22, 2018
1 parent 8297462 commit 3f9e5cd
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 35 deletions.
7 changes: 2 additions & 5 deletions chords/app/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

require(["domready", "main.scss", "interface/Piano", "sound/Arp", "interface/ChordLabel",
require(["domready", "main.scss", "interface/Piano", "sound/Arp",
"interface/Toggle", "StartiOS", "Translation"],
function(domready, mainStyle, Piano, Arp, ChordLabel, Toggle, StartiOS, Translation){
function(domready, mainStyle, Piano, Arp, Toggle, StartiOS, Translation){

//get the origin

Expand All @@ -37,8 +37,6 @@ require(["domready", "main.scss", "interface/Piano", "sound/Arp", "interface/Cho
var lowestNote = "C3";
var highestNote = "C5";

var label = new ChordLabel(container);

//the piano
var piano = new Piano(container, lowestNote, highestNote);

Expand All @@ -56,7 +54,6 @@ require(["domready", "main.scss", "interface/Piano", "sound/Arp", "interface/Cho
piano.onNotes = function(notes, root, mode){
chordSelected = true;
arp.play(notes);
label.setChord(root, mode);
};

toggle.onChange = function(mode){
Expand Down
22 changes: 9 additions & 13 deletions chords/app/StartiOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,20 @@
define(["StartAudioContext", "Tone/core/Tone"], function (StartAudioContext, Tone) {

return function(){
//send the ready message to the parent
// send the ready message to the parent
var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
var isAndroid = /Android/.test(navigator.userAgent) && !window.MSStream;

//full screen button on iOS
if (isIOS){
//make a full screen element and put it in front
// full screen button on iOS
if (isIOS || isAndroid) {
// make a full screen element and put it in front
var iOSTapper = document.createElement("div");
iOSTapper.id = "iOSTap";
iOSTapper.addEventListener("touchstart", function(e){
e.preventDefault();
});
document.body.appendChild(iOSTapper);
StartAudioContext.setContext(Tone.context);
StartAudioContext.on(iOSTapper);
StartAudioContext.onStarted(function(){
iOSTapper.remove();
window.parent.postMessage('ready','*');
});
new StartAudioContext(Tone.context, iOSTapper).then(function() {
iOSTapper.remove();
window.parent.postMessage('ready','*');
});
} else {
window.parent.postMessage('ready','*');
}
Expand Down
22 changes: 16 additions & 6 deletions chords/app/Translation.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ define(function () {

var languageText = null;

function capitalize(str){
return str.charAt(0).toUpperCase() + str.substr(1);
}

//the number of attempts to get the translation
var tries = 0;

/**
* localize the given word into the desired language
* @param {String} word
Expand All @@ -34,10 +41,13 @@ define(function () {
languageText = json;
callback();
} else {
console.log('Error: ' + xhr.status); // An error occurred during the request.
if (tries < 3){
tries++;
this.load("en", callback);
}
}
}
};
}.bind(this);
xhr.send(null);
},
localize : function(phrase){
Expand All @@ -52,11 +62,11 @@ define(function () {
}
},
localizeChord : function(key, mode){
if (languageText){
// return languageText.Chords_UI_Major_Chords.message;
return key + " " + " " + mode + " chord";
var transKey = key+"_"+capitalize(mode)+"_Chord";
if (languageText && languageText[transKey]){
return languageText[transKey].message;
} else {
return note;
return key + " " + " " + mode + " chord";
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion chords/app/interface/Piano.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function (PianoComp, pianoStyle, teoria, Tone) {
* the delay time between sequential notes
* @type {Number}
*/
Piano.prototype.delayTime = 0.2;
Piano.prototype.delayTime = 0.05;

Piano.prototype.clicked = function(midiNote){
this.setChord(midiNote);
Expand Down
2 changes: 1 addition & 1 deletion chords/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Chords</title>
<link href='https://fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Poppins:400,300' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="build/Main.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion chords/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"teoria": "^2.1.1",
"url-loader": "*",
"webfontloader": "^1.6.10",
"webpack": "*"
"webpack": "^1.12.11"
}
}
4 changes: 2 additions & 2 deletions chords/style/box.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@import "common.scss";

@import url(https://fonts.googleapis.com/css?family=Roboto:400,300,100);
@import url(https://fonts.googleapis.com/css?family=Poppins:400,300,100);

body {
width: 100%;
height: 100%;
margin: 0px;
font-family: "Roboto", sans-serif;
font-family: "Poppins", sans-serif;
font-weight: 400;
}

Expand Down
2 changes: 1 addition & 1 deletion chords/style/chordlabel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $labelSize : 25px;
height: $labelSize;
font-size: $labelSize;
line-height: $labelSize;
font-family: "Roboto", sans-serif;
font-family: "Poppins", sans-serif;
font-weight: 300;
color: $darkGrey;
}
Expand Down
4 changes: 4 additions & 0 deletions chords/style/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ body, html, #Container{
-webkit-tap-highlight-color: rgba(0,0,0,0);

#Container {
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
position: absolute;
}

Expand Down
3 changes: 0 additions & 3 deletions chords/style/piano.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ $pianoWidth: 390px;

#Piano {
position: relative;
left: 0px;
width: 100%;
min-width: 300px;
max-width: 400px;
height: $pianoHeight;
left: 50%;
transform: translate(-50%, 0px);
}
2 changes: 1 addition & 1 deletion chords/style/toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $HandleSize : 30px;
$transitionTime: 0.2s;

#ToggleContainer {
height: $toggleHeight;
margin-top: 20vh;
position: relative;

.Label {
Expand Down
2 changes: 1 addition & 1 deletion chords/style/toggleswitch.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $blue: rgb(30, 170, 241);
cursor: pointer;
position: absolute;
top: 50%;
font-family: "Roboto", sans-serif;
font-family: "Poppins", sans-serif;
font-weight: 300;
color: $grey;
font-size: $railHeight;
Expand Down

0 comments on commit 3f9e5cd

Please sign in to comment.