-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
154 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"plugins": ["@babel/plugin-proposal-class-properties"], | ||
"presets": | ||
[ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
corejs: 3, | ||
useBuiltIns: "entry" | ||
} | ||
], | ||
"@babel/preset-react" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules/ | ||
/.webpack/ | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "composer", | ||
"version": "1.0.0", | ||
"description": "", | ||
"private": true, | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "webpack", | ||
"watch": "webpack --watch --mode development", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"browserslist": [ | ||
"last 2 Chrome versions" | ||
], | ||
"author": "", | ||
"dependencies": { | ||
"@babel/core": "^7.4.3", | ||
"@babel/plugin-proposal-class-properties": "^7.4.0", | ||
"@babel/preset-env": "^7.4.3", | ||
"@babel/preset-react": "^7.0.0", | ||
"babel-loader": "^8.0.5", | ||
"core-js": "^3.0.1", | ||
"react": "^16.8.6", | ||
"react-dom": "^16.8.6", | ||
"webpack": "^4.30.0", | ||
"webpack-cli": "^3.3.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from "react" | ||
import { KeyChange } from "../song/song.js" | ||
import { Key, scales, getScaleDegreeForPitch, getNameForPitch, getColorForScaleDegree, getColorRotationForScale } from "../util/theory.js" | ||
import { Rational } from "../util/rational.js" | ||
|
||
|
||
function NoteToolbox(props) | ||
{ | ||
return <div> | ||
<span>Key: { props.songKey.getName() }</span> | ||
<br/> | ||
|
||
{ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].map(pitch => | ||
{ | ||
const degree = getScaleDegreeForPitch(props.songKey, pitch + props.songKey.tonicPitch + props.songKey.tonicAccidental) | ||
const inKey = Math.floor(degree) == degree | ||
const noteName = getNameForPitch(props.songKey, pitch + props.songKey.tonicPitch + props.songKey.tonicAccidental) | ||
const colorRotation = getColorRotationForScale(props.songKey.scalePitches) | ||
const color = getColorForScaleDegree(colorRotation + degree) | ||
return <button key={pitch} style={{ position:"relative", top:(inKey ? "1em" : "0"), width:"3em", height:"4em", backgroundColor: color, border:"0", borderRadius:"0.25em", margin:"0.1em" }}> | ||
<span style={{ fontWeight:"bold" }}>{ noteName }</span> | ||
</button> | ||
} | ||
)} | ||
|
||
</div> | ||
} | ||
|
||
|
||
export default function Toolbox(props) | ||
{ | ||
const keyChange = props.editor.song.keyChanges.findActiveAt(props.editor.cursorTime.start) || new KeyChange(new Rational(0), new Key(0, 0, scales.major.pitches)) | ||
|
||
return <div style={{ fontFamily:"Verdana", fontSize:"18px" }}><NoteToolbox songKey={ keyChange.key }/></div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const path = require("path") | ||
|
||
module.exports = | ||
{ | ||
mode: "production", | ||
entry: | ||
{ | ||
main: path.resolve(__dirname, "src/main.js"), | ||
}, | ||
|
||
output: | ||
{ | ||
filename: "[name].js", | ||
path: path.resolve(__dirname, ".webpack") | ||
}, | ||
|
||
module: | ||
{ | ||
rules: | ||
[ | ||
{ | ||
test: /\.(js|jsx)$/, | ||
exclude: /node_modules/, | ||
use: | ||
{ | ||
loader: "babel-loader" | ||
} | ||
} | ||
] | ||
} | ||
} |