Skip to content

Commit e1bac8d

Browse files
authored
Merge pull request #36 from ishythefishy/theoretical-scales
Identify theoretical scales and provide a link to the alternative
2 parents 6244342 + 9080651 commit e1bac8d

20 files changed

+427
-192
lines changed

README.md

Lines changed: 21 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,36 @@
1-
# Fretonator
1+
# www.fretonator.com
22

3-
This project was generated using [Nx](https://nx.dev).
4-
5-
<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/nx-logo.png" width="450"></p>
6-
7-
🔎 **Nx is a set of Extensible Dev Tools for Monorepos.**
8-
9-
## Quick Start & Documentation
10-
11-
[Nx Documentation](https://nx.dev/angular)
12-
13-
[10-minute video showing all Nx features](https://nx.dev/angular/getting-started/what-is-nx)
14-
15-
[Interactive Tutorial](https://nx.dev/angular/tutorial/01-create-application)
16-
17-
## Adding capabilities to your workspace
18-
19-
Nx supports many plugins which add capabilities for developing different types of applications and different tools.
20-
21-
These capabilities include generating applications, libraries, etc as well as the devtools to test, and build projects as well.
22-
23-
Below are some plugins which you can add to your workspace:
24-
25-
- [Angular](https://angular.io)
26-
- `ng add @nrwl/angular`
27-
- [React](https://reactjs.org)
28-
- `ng add @nrwl/react`
29-
- Web (no framework frontends)
30-
- `ng add @nrwl/web`
31-
- [Nest](https://nestjs.com)
32-
- `ng add @nrwl/nest`
33-
- [Express](https://expressjs.com)
34-
- `ng add @nrwl/express`
35-
- [Node](https://nodejs.org)
36-
- `ng add @nrwl/node`
3+
[![Netlify Status](https://api.netlify.com/api/v1/badges/87d9f619-8f13-47e8-99cc-5167db7294a6/deploy-status)](https://app.netlify.com/sites/fretonator/deploys)
374

38-
## Generate an application
5+
<img src="https://www.fretonator.com/assets/img/og_twitter.png">
396

40-
Run `ng g @nrwl/angular:app my-app` to generate an application.
7+
## Thanks for checking out the Fretonator!
418

42-
> You can use any of the plugins above to generate applications as well.
9+
I’m a qualified music teacher that (somehow) ended up working as a lead software engineer (it’s a long story), and I built this for my husban️d.
4310

44-
When using Nx, you can create multiple applications and libraries in the same workspace.
11+
He’s a phenomenal guitarist, and over the past few years has worked on learning modes and scale theory for the guitar (with a little help from me). Obviously, the internet is great for this kind of stuff, but what he felt the world wide web was lacking was an interactive and informative tool to could use in his practice sessions that had everything he needed on one single page.
4512

46-
## Generate a library
13+
## Enter the Fretonator!
4714

48-
Run `ng g @nrwl/angular:lib my-lib` to generate a library.
15+
The Fretonator is your new interactive tool for learning common modes on the guitar, understanding the chord theory behind the modes, and most importantly - having a jam.
4916

50-
> You can also use any of the plugins above to generate libraries as well.
17+
I am gratefully welcoming feedback from musicians, pull requests from software engineers, and anything else you are willing to contribute.
5118

52-
Libraries are sharable across libraries and applications. They can be imported from `@fretonator/mylib`.
19+
Thank you and happy jamming!
5320

54-
## Development server
5521

56-
Run `ng serve my-app` for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
22+
## Technical
5723

58-
## Code scaffolding
24+
The Fretonator was built with:
5925

60-
Run `ng g component my-component --project=my-app` to generate a new component.
26+
```
27+
Angular
28+
Angular Universal
29+
Angular Prerender
30+
Netlify
31+
```
6132

62-
## Build
6333

64-
Run `ng build my-app` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
65-
66-
## Running unit tests
67-
68-
Run `ng test my-app` to execute the unit tests via [Jest](https://jestjs.io).
69-
70-
Run `nx affected:test` to execute the unit tests affected by a change.
71-
72-
## Running end-to-end tests
73-
74-
Run `ng e2e my-app` to execute the end-to-end tests via [Cypress](https://www.cypress.io).
75-
76-
Run `nx affected:e2e` to execute the end-to-end tests affected by a change.
77-
78-
## Understand your workspace
79-
80-
Run `nx dep-graph` to see a diagram of the dependencies of your projects.
81-
82-
## Further help
83-
84-
Visit the [Nx Documentation](https://nx.dev/angular) to learn more.
34+
```
35+
This project was generated using [Nx](https://nx.dev).
36+
```

apps/fretonator-web/src/app/common/fretonator/fretonator.component.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@
5555

5656
<div class="infoContainer">
5757
<app-scale-map [mode]="mode"
58-
[scale]="scale"></app-scale-map>
58+
[scale]="scale"
59+
[isTheoretical]="scale | isTheoreticalScale"
60+
[modeDisplayString]="modeDisplayString"
61+
[note]="note"
62+
[noteExtenderString]="noteExtenderString"></app-scale-map>
5963

6064
<app-interval-map [intervalMap]="intervalMap"></app-interval-map>
6165

apps/fretonator-web/src/app/common/fretonator/fretonator.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@ export class FretonatorComponent {
1212
@Input() intervalMap: [];
1313
@Input() chordMap: ChordMap;
1414
@Input() mode: Mode;
15+
@Input() modeDisplayString: string;
16+
@Input() note: string;
17+
@Input() noteExtenderString: string;
18+
1519
frets = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
1620
}

apps/fretonator-web/src/app/common/fretonator/fretonator.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import { GetFretFromFretMapPipe } from './get-fret-from-fret-map.pipe';
55
import { ChordMapModule } from './chord-map/chord-map.module';
66
import { IntervalMapModule } from './interval-map/interval-map.module';
77
import { ScaleMapModule } from './scale-map/scale-map.module';
8+
import { IsTheoreticalScalePipe } from './is-theoretical-scale.pipe';
89

910
@NgModule({
1011
declarations: [
1112
FretonatorComponent,
1213
GetFretFromFretMapPipe,
14+
IsTheoreticalScalePipe,
1315
],
1416
imports: [
1517
CommonModule,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { IsTheoreticalScalePipe } from './is-theoretical-scale.pipe';
2+
3+
describe('IsTheoreticalScalePipe', () => {
4+
let pipe: IsTheoreticalScalePipe;
5+
6+
beforeEach(() => {
7+
pipe = new IsTheoreticalScalePipe();
8+
});
9+
it('create an instance', () => {
10+
expect(pipe).toBeTruthy();
11+
});
12+
13+
it('returns true for a scale with a double flat in', () => {
14+
expect(pipe.transform(['C', 'D𝄫'])).toBe(true);
15+
});
16+
17+
it('returns true for a scale with a double sharp in', () => {
18+
expect(pipe.transform(['Cx', 'D'])).toBe(true);
19+
});
20+
21+
it('returns false for scales without double flat or double sharp', () => {
22+
expect(pipe.transform(['C', 'D'])).toBe(false);
23+
});
24+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Pipe, PipeTransform } from '@angular/core';
2+
import { Scale } from '../../util/types';
3+
4+
@Pipe({
5+
name: 'isTheoreticalScale'
6+
})
7+
export class IsTheoreticalScalePipe implements PipeTransform {
8+
9+
transform(scale: Scale): boolean {
10+
for (const note of scale) {
11+
if(note.indexOf('x') !== -1 || note.indexOf('𝄫') !== -1) {
12+
return true;
13+
}
14+
}
15+
return false;
16+
}
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { GetEnharmonicEquivalentPipe } from './get-enharmonic-equivalent.pipe';
2+
3+
describe('GetHarmonicEquivalentPipe', () => {
4+
it('create an instance', () => {
5+
const pipe = new GetEnharmonicEquivalentPipe();
6+
expect(pipe).toBeTruthy();
7+
});
8+
9+
it('returns A♭ for G#', () => {
10+
const pipe = new GetEnharmonicEquivalentPipe();
11+
expect(pipe.transform('G#')).toBe('A♭');
12+
})
13+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Pipe, PipeTransform } from '@angular/core';
2+
import { Enharmonics } from '../../../util/constants';
3+
4+
@Pipe({
5+
name: 'getEnharmonicEquivalent'
6+
})
7+
export class GetEnharmonicEquivalentPipe implements PipeTransform {
8+
9+
transform(note: string): string {
10+
for (const group of Enharmonics) {
11+
if (group.indexOf(note) === 0) {
12+
return group[1]
13+
}
14+
15+
if (group.indexOf(note) === 1) {
16+
return group[0]
17+
}
18+
}
19+
}
20+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { GetEnharmonicRouterLinkPipe } from './get-enharmonic-router-link.pipe';
2+
3+
describe('GetEnharmonicRouterLinkPipe', () => {
4+
let pipe;
5+
beforeEach(() => {
6+
pipe = new GetEnharmonicRouterLinkPipe();
7+
});
8+
it('create an instance', () => {
9+
expect(pipe).toBeTruthy();
10+
});
11+
12+
it('returns correctly for g sharp ionian', () => {
13+
expect(pipe.transform('g', 'sharp', 'ionian')).toStrictEqual(['/', 'a', 'flat', 'ionian']);
14+
});
15+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Pipe, PipeTransform } from '@angular/core';
2+
import { RouterLink } from '@angular/router';
3+
import { Enharmonics } from '../../../util/constants';
4+
5+
@Pipe({
6+
name: 'getEnharmonicRouterLink'
7+
})
8+
export class GetEnharmonicRouterLinkPipe implements PipeTransform {
9+
10+
transform(note: string, noteExtenderString: string, mode: string): string[] {
11+
let newNote;
12+
13+
for(const group of Enharmonics) {
14+
if (group[0].includes(note.toUpperCase())) {
15+
newNote = group[1].charAt(0).toLowerCase();
16+
}
17+
18+
if (group[1].includes(note.toUpperCase())) {
19+
newNote = group[0].charAt(0).toLowerCase();
20+
}
21+
}
22+
23+
const newNoteExtender = noteExtenderString === 'sharp' ? 'flat' : 'sharp';
24+
25+
return ['/', newNote, newNoteExtender, mode];
26+
}
27+
28+
}

0 commit comments

Comments
 (0)