defined some structural concepts

This commit is contained in:
2022-03-31 18:14:55 -05:00
parent c604afb0dd
commit cc68852e9b
4 changed files with 138 additions and 118 deletions

View File

@@ -1,70 +1,4 @@
# Getting Started with Create React App As is the way, this project was bootstrapped with Create React App.
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). The first goal is specific:
Can JavaScript write musical counterpoint according to the rules laid out in Johann Joseph Fux's *Gradus Ad Parnassum*?
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload when you make changes.\
You may also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

View File

@@ -2,37 +2,6 @@
text-align: center; text-align: center;
} }
.App-logo { .monospaces {
height: 40vmin; font-family: monospace;
pointer-events: none; }
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

View File

@@ -1,23 +1,27 @@
import logo from './logo.svg';
import './App.css'; import './App.css';
import { cantusFirmus, Pitch } from './components/PitchLogic';
function App() { function App() {
const handleTranspose = (cantus, amount) => {
let newFirmus = [];
for (let pitch of cantus) {
const thing = new Pitch(pitch.getNote() + amount);
newFirmus.push(thing);
}
console.log(newFirmus);
return newFirmus;
}
return ( return (
<div className="App"> <div className="App">
<header className="App-header"> <h1>Procedural Music Generation with Javascript</h1>
<img src={logo} className="App-logo" alt="logo" /> <h2>This project will contain some initial thoughts about establishing a uniform syntax for representing and manipulating constructs in traditional music theory as code.</h2>
<p>
Edit <code>src/App.js</code> and save to reload. <h3>First Species: Note against Note</h3>
</p> <p>This variety of counterpoint consists of a chain of simultaneous consonances between two voices.<br/>The goal here is to handle and resolve legal dissonance within strict parameters.</p>
<a
className="App-link" <h4>Cantus Firmus:</h4>
href="https://reactjs.org" <p className="monospaced">{cantusFirmus.returnLetters()}</p>
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div> </div>
); );
} }

View File

@@ -0,0 +1,113 @@
export const letterNames = {
0: 'B',
1: 'C',
2: 'C-sharp',
3: 'D',
4: 'D-sharp',
5: 'E',
6: 'F',
7: 'F-sharp',
8: 'G',
9: 'G-sharp',
10: 'A',
11: 'A-sharp',
}
export class Pitch {
// constructor expects to receive an integer representing a pitch
constructor(note) {
this.note = note;
this.duration = 1;
}
getNote() {
return this.note;
}
getDuration() {
return this.duration;
}
upOctave() {
this.note += 12;
}
downOctave() {
this.note -= 12;
}
transposeByAmount(amount) {
// a positive int will transpose up, negative int will transpose down
this.note += amount;
}
}
export class Cantus {
constructor(...notes) {
this.melody = notes;
}
getMelody() {
return this.melody;
}
returnLetters() {
let output = [];
for (let pitch of this.melody[0]) {
let reduced = pitch.getNote() % 12;
output.push(`${letterNames[reduced]} `);
}
return output;
}
}
export class Sonority {
// constructor receives an array of Pitch class objects
constructor([...notes]) {
this.sonority = [...notes];
this.numVoices = null;
this.consonance = null;
this.harmonicPull = null;
}
getSonority() {
return this.sonority;
}
setConsonance() {
this.consonance = 1;
}
}
export class Sequence {
constructor(...cantii) {
this.sequence = [...cantii];
}
getSequence() {
return this.sequence;
}
}
export const cantusFirmus = new Cantus([
new Pitch(3), // D
new Pitch(6), // F
new Pitch(5), // E
new Pitch(3), // D
new Pitch(8), // G
new Pitch(6), // F
new Pitch(10), // A
new Pitch(8), // G
new Pitch(6), // F
new Pitch(5), // E
new Pitch(3) // D
]);