From cc68852e9bd85d65c111610a1f9089a171e4091c Mon Sep 17 00:00:00 2001 From: Mikayla Dobson Date: Thu, 31 Mar 2022 18:14:55 -0500 Subject: [PATCH] defined some structural concepts --- README.md | 72 +--------------------- src/App.css | 37 +----------- src/App.js | 34 ++++++----- src/components/PitchLogic.js | 113 +++++++++++++++++++++++++++++++++++ 4 files changed, 138 insertions(+), 118 deletions(-) create mode 100644 src/components/PitchLogic.js diff --git a/README.md b/README.md index 58beeac..5d1d669 100644 --- a/README.md +++ b/README.md @@ -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). - -## 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) +The first goal is specific: +Can JavaScript write musical counterpoint according to the rules laid out in Johann Joseph Fux's *Gradus Ad Parnassum*? \ No newline at end of file diff --git a/src/App.css b/src/App.css index 74b5e05..a2a0f8e 100644 --- a/src/App.css +++ b/src/App.css @@ -2,37 +2,6 @@ text-align: center; } -.App-logo { - height: 40vmin; - 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); - } -} +.monospaces { + font-family: monospace; +} \ No newline at end of file diff --git a/src/App.js b/src/App.js index 3784575..31aabc6 100644 --- a/src/App.js +++ b/src/App.js @@ -1,23 +1,27 @@ -import logo from './logo.svg'; import './App.css'; +import { cantusFirmus, Pitch } from './components/PitchLogic'; 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 (
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
+

Procedural Music Generation with Javascript

+

This project will contain some initial thoughts about establishing a uniform syntax for representing and manipulating constructs in traditional music theory as code.

+ +

First Species: Note against Note

+

This variety of counterpoint consists of a chain of simultaneous consonances between two voices.
The goal here is to handle and resolve legal dissonance within strict parameters.

+ +

Cantus Firmus:

+

{cantusFirmus.returnLetters()}

); } diff --git a/src/components/PitchLogic.js b/src/components/PitchLogic.js new file mode 100644 index 0000000..76b24b7 --- /dev/null +++ b/src/components/PitchLogic.js @@ -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 +]); \ No newline at end of file