Skip to content

Commit

Permalink
run prettier based on .prettierrc
Browse files Browse the repository at this point in the history
  • Loading branch information
philippotto committed Oct 29, 2017
1 parent 50021b7 commit c7ee7f2
Show file tree
Hide file tree
Showing 36 changed files with 420 additions and 239 deletions.
14 changes: 10 additions & 4 deletions app/scripts/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ export default class App extends Component {
super(props, context);
this.state = {
activeGame: "pitch",
showPrivacyPolicy: false
showPrivacyPolicy: false,
};
}

selectGame(newGame) {
this.setState({
activeGame: newGame
activeGame: newGame,
});

AnalyticsService.sendEvent("GameSelection", newGame);
Expand Down Expand Up @@ -87,7 +87,10 @@ export default class App extends Component {
</div>
<div className="row">
<div className="col-md-12 col-xs-12">
<p>Sheet Music Tutor is still under development. Be first to find out when it gets updates.</p>
<p>
Sheet Music Tutor is still under development. Be first to find out when it gets
updates.
</p>
</div>
</div>
<NewsletterForm />
Expand All @@ -100,7 +103,10 @@ export default class App extends Component {
</div>
<div className="row">
<div className="col-md-12 col-xs-12">
<p>Follow us on social media to stay up to date on new features or to give us feedback.</p>
<p>
Follow us on social media to stay up to date on new features or to give us
feedback.
</p>
</div>
</div>
<div className="row">
Expand Down
14 changes: 7 additions & 7 deletions app/scripts/AppFreezer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ let defaultSettings = {
accuracyGoal: 0.85,
timeGoal: 2000,
amount: 5,
newNotesShare: 0.6
newNotesShare: 0.6,
},
chordSizeRanges: {
treble: [1, 3],
bass: [1, 3]
bass: [1, 3],
},
keySignature: [7, 7],
useAccidentals: false,
midi: {
inputs: Freezer.createLeaf([]),
activeInputIndex: 0
}
activeInputIndex: 0,
},
},
rhythmReading: {
barDuration: 3000,
Expand All @@ -29,8 +29,8 @@ let defaultSettings = {
eighthNotes: true,
sixteenthNotes: false,
dottedNotes: false,
triplets: false
}
triplets: false,
},
};

const savedSettings = localStorage.getItem("SheetMusicTutor-settings");
Expand All @@ -41,7 +41,7 @@ if (savedSettings) {
}

const AppFreezer = new Freezer({
settings: defaultSettings
settings: defaultSettings,
});

AppFreezer.on("update", () => {
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/services/analytics_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
hitType: "event",
eventCategory,
eventAction,
eventValue
eventValue,
});
}
},
};
58 changes: 34 additions & 24 deletions app/scripts/services/bar_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const options = {
chordsPerBar: 4,
levels: {
bass: [2, 3],
treble: [4, 5]
treble: [4, 5],
},
maximumInterval: 12
maximumInterval: 12,
};

function sampleWithoutReplacement(options) {
Expand All @@ -30,17 +30,19 @@ function randomInvokeAOrB(probability, functionA, functionB) {

export default {
generateKeySignature: function(settings) {
const keySignatureIndex = _.sample(_.range(settings.keySignature[0], settings.keySignature[1] + 1));
const keySignatureIndex = _.sample(
_.range(settings.keySignature[0], settings.keySignature[1] + 1),
);
return KeyConverter.keySignatureValueToString(keySignatureIndex);
},

generateEmptyRhythmBar: function() {
return {
keys: {
treble: [],
bass: []
bass: [],
},
durations: []
durations: [],
};
},

Expand All @@ -52,7 +54,11 @@ export default {
const generateRandomDurations = () => {
const durations = [];
while (calcBarLength(durations) < 1) {
const possibleNotes = _.flatten([[4, 2], settings.eighthNotes ? 8 : null, settings.sixteenthNotes ? 16 : null]);
const possibleNotes = _.flatten([
[4, 2],
settings.eighthNotes ? 8 : null,
settings.sixteenthNotes ? 16 : null,
]);

let newDuration = _.sample(possibleNotes);
if (settings.rests && Math.random() < settings.restProbability) {
Expand All @@ -78,16 +84,16 @@ export default {
new Vex.Flow.StaveNote({
clef: "treble",
keys: ["a/4"],
duration: duration > 0 ? `${duration}` : `${duration}r`
})
duration: duration > 0 ? `${duration}` : `${duration}r`,
}),
);

return {
keys: {
treble: staveNotes,
bass: []
bass: [],
},
durations
durations,
};
},

Expand All @@ -97,7 +103,7 @@ export default {
new: level.keys.treble.concat(level.keys.bass).length,
old: LevelService.getAllNotesUntilLevelIndex(level.index).length,
trebleAndNew: level.keys.treble.length,
trebleAndOld: LevelService.getAllNotesUntilLevelIndex(level.index, "treble").length
trebleAndOld: LevelService.getAllNotesUntilLevelIndex(level.index, "treble").length,
};
if (amounts.new === amounts.trebleAndNew && amounts.old === amounts.trebleAndOld) {
// there are no bass notes
Expand All @@ -107,10 +113,11 @@ export default {
const frequencies = {
new: settings.automaticDifficulty.newNotesShare,
trebleGivenNew: amounts.trebleAndNew / (amounts.new || 1),
trebleGivenOld: amounts.trebleAndOld / (amounts.old || 1)
trebleGivenOld: amounts.trebleAndOld / (amounts.old || 1),
};
const trebleProbability =
frequencies.trebleGivenNew * frequencies.new + frequencies.trebleGivenOld * (1 - frequencies.new);
frequencies.trebleGivenNew * frequencies.new +
frequencies.trebleGivenOld * (1 - frequencies.new);
return trebleProbability;
};

Expand All @@ -124,7 +131,7 @@ export default {
}
const lengths = {
treble: _.max(settings.chordSizeRanges.treble),
bass: _.max(settings.chordSizeRanges.bass)
bass: _.max(settings.chordSizeRanges.bass),
};
if (lengths.treble > 0 && lengths.bass > 0) {
return _.sample([[0, 1], [1, 0]]);
Expand All @@ -151,7 +158,7 @@ export default {
if (level) {
return {
new: level.keys[clef],
old: LevelService.getAllNotesUntilLevelIndex(level.index, clef)
old: LevelService.getAllNotesUntilLevelIndex(level.index, clef),
};
}
const levels = clef === "treble" ? [4, 5] : [2, 3];
Expand All @@ -160,7 +167,7 @@ export default {

const [possibleTrebleNotes, possibleBassNotes] = [
generatePossibleNotes("treble"),
generatePossibleNotes("bass")
generatePossibleNotes("bass"),
];

const [trebleAmount, bassAmount] = this.getClefAmounts(settings, onePerTime, level);
Expand All @@ -170,14 +177,14 @@ export default {

return [
this.generateNotesForBeat(settings, "treble", trebleAmount, possibleTrebleNotes),
this.generateNotesForBeat(settings, "bass", bassAmount, possibleBassNotes)
this.generateNotesForBeat(settings, "bass", bassAmount, possibleBassNotes),
];
})
}),
);

return {
treble: trebleNotes,
bass: bassNotes
bass: bassNotes,
};
},

Expand All @@ -202,7 +209,7 @@ export default {
return randomInvokeAOrB(
newNoteProbability,
() => sampleWithoutReplacement(newPossibleNotes),
() => sampleWithoutReplacement(oldPossibleNotes)
() => sampleWithoutReplacement(oldPossibleNotes),
);
});
},
Expand All @@ -219,7 +226,7 @@ export default {
const rest = new Vex.Flow.StaveNote({
clef: clef,
keys: [clef === "treble" ? "a/4" : "c/3"],
duration: `${options.chordsPerBar}r`
duration: `${options.chordsPerBar}r`,
});
return rest;
}
Expand All @@ -232,9 +239,12 @@ export default {
const staveChord = new Vex.Flow.StaveNote({
clef: clef,
keys: randomNoteSet.sort((keyA, keyB) => {
return KeyConverter.getKeyNumberForKeyString(keyA, "C") - KeyConverter.getKeyNumberForKeyString(keyB, "C");
return (
KeyConverter.getKeyNumberForKeyString(keyA, "C") -
KeyConverter.getKeyNumberForKeyString(keyB, "C")
);
}),
duration: `${options.chordsPerBar}`
duration: `${options.chordsPerBar}`,
});

randomNoteSet.forEach(({ note, modifier }, index) => {
Expand All @@ -244,5 +254,5 @@ export default {
});

return staveChord;
}
},
};
25 changes: 21 additions & 4 deletions app/scripts/services/key_converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,26 @@ const keySignatureOffsets = {
Ab: ["b", "e", "a", "d"],
Db: ["b", "e", "a", "d", "g"],
Gb: ["b", "e", "a", "d", "g", "c"],
Cb: ["b", "e", "a", "d", "g", "c", "f"]
Cb: ["b", "e", "a", "d", "g", "c", "f"],
};

const keySignatures = ["C#", "F#", "B", "E", "A", "D", "G", "C", "F", "Bb", "Eb", "Ab", "Db", "Gb", "Cb"];
const keySignatures = [
"C#",
"F#",
"B",
"E",
"A",
"D",
"G",
"C",
"F",
"Bb",
"Eb",
"Ab",
"Db",
"Gb",
"Cb",
];
const octaveNotes = ["c", "c#", "d", "d#", "e", "f", "f#", "g", "g#", "a", "a#", "b"];

const keyMap = initializeKeyMap();
Expand Down Expand Up @@ -137,7 +153,8 @@ const KeyConverter = {
[keyString, flatDifference] = stripKey(keyString, "b");
[keyString, sharpDifference] = stripKey(keyString, "#");

const keyNumber = KeyConverter.getKeyNumberForCanonicalKeyString(keyString) + sharpDifference - flatDifference;
const keyNumber =
KeyConverter.getKeyNumberForCanonicalKeyString(keyString) + sharpDifference - flatDifference;

return KeyConverter.getKeyStringForKeyNumber(keyNumber);
},
Expand Down Expand Up @@ -175,7 +192,7 @@ const KeyConverter = {
.map(KeyConverter.getNoteFromKeyString);

return _.difference(octaveNotes, cScaleNotes);
}
},
};

export default KeyConverter;
Loading

0 comments on commit c7ee7f2

Please sign in to comment.