Skip to content

Commit

Permalink
Merge pull request #36 from ishythefishy/theoretical-scales
Browse files Browse the repository at this point in the history
Identify theoretical scales and provide a link to the alternative
  • Loading branch information
whitep4nth3r authored Jun 6, 2020
2 parents 6244342 + 9080651 commit e1bac8d
Show file tree
Hide file tree
Showing 20 changed files with 427 additions and 192 deletions.
90 changes: 21 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,84 +1,36 @@
# Fretonator
# www.fretonator.com

This project was generated using [Nx](https://nx.dev).

<p align="center"><img src="https://raw.githubusercontent.com/nrwl/nx/master/nx-logo.png" width="450"></p>

🔎 **Nx is a set of Extensible Dev Tools for Monorepos.**

## Quick Start & Documentation

[Nx Documentation](https://nx.dev/angular)

[10-minute video showing all Nx features](https://nx.dev/angular/getting-started/what-is-nx)

[Interactive Tutorial](https://nx.dev/angular/tutorial/01-create-application)

## Adding capabilities to your workspace

Nx supports many plugins which add capabilities for developing different types of applications and different tools.

These capabilities include generating applications, libraries, etc as well as the devtools to test, and build projects as well.

Below are some plugins which you can add to your workspace:

- [Angular](https://angular.io)
- `ng add @nrwl/angular`
- [React](https://reactjs.org)
- `ng add @nrwl/react`
- Web (no framework frontends)
- `ng add @nrwl/web`
- [Nest](https://nestjs.com)
- `ng add @nrwl/nest`
- [Express](https://expressjs.com)
- `ng add @nrwl/express`
- [Node](https://nodejs.org)
- `ng add @nrwl/node`
[![Netlify Status](https://api.netlify.com/api/v1/badges/87d9f619-8f13-47e8-99cc-5167db7294a6/deploy-status)](https://app.netlify.com/sites/fretonator/deploys)

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

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

> You can use any of the plugins above to generate applications as well.
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.

When using Nx, you can create multiple applications and libraries in the same workspace.
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.

## Generate a library
## Enter the Fretonator!

Run `ng g @nrwl/angular:lib my-lib` to generate a library.
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.

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

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

## Development server

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.
## Technical

## Code scaffolding
The Fretonator was built with:

Run `ng g component my-component --project=my-app` to generate a new component.
```
Angular
Angular Universal
Angular Prerender
Netlify
```

## Build

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.

## Running unit tests

Run `ng test my-app` to execute the unit tests via [Jest](https://jestjs.io).

Run `nx affected:test` to execute the unit tests affected by a change.

## Running end-to-end tests

Run `ng e2e my-app` to execute the end-to-end tests via [Cypress](https://www.cypress.io).

Run `nx affected:e2e` to execute the end-to-end tests affected by a change.

## Understand your workspace

Run `nx dep-graph` to see a diagram of the dependencies of your projects.

## Further help

Visit the [Nx Documentation](https://nx.dev/angular) to learn more.
```
This project was generated using [Nx](https://nx.dev).
```
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@

<div class="infoContainer">
<app-scale-map [mode]="mode"
[scale]="scale"></app-scale-map>
[scale]="scale"
[isTheoretical]="scale | isTheoreticalScale"
[modeDisplayString]="modeDisplayString"
[note]="note"
[noteExtenderString]="noteExtenderString"></app-scale-map>

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ export class FretonatorComponent {
@Input() intervalMap: [];
@Input() chordMap: ChordMap;
@Input() mode: Mode;
@Input() modeDisplayString: string;
@Input() note: string;
@Input() noteExtenderString: string;

frets = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { GetFretFromFretMapPipe } from './get-fret-from-fret-map.pipe';
import { ChordMapModule } from './chord-map/chord-map.module';
import { IntervalMapModule } from './interval-map/interval-map.module';
import { ScaleMapModule } from './scale-map/scale-map.module';
import { IsTheoreticalScalePipe } from './is-theoretical-scale.pipe';

@NgModule({
declarations: [
FretonatorComponent,
GetFretFromFretMapPipe,
IsTheoreticalScalePipe,
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { IsTheoreticalScalePipe } from './is-theoretical-scale.pipe';

describe('IsTheoreticalScalePipe', () => {
let pipe: IsTheoreticalScalePipe;

beforeEach(() => {
pipe = new IsTheoreticalScalePipe();
});
it('create an instance', () => {
expect(pipe).toBeTruthy();
});

it('returns true for a scale with a double flat in', () => {
expect(pipe.transform(['C', 'D𝄫'])).toBe(true);
});

it('returns true for a scale with a double sharp in', () => {
expect(pipe.transform(['Cx', 'D'])).toBe(true);
});

it('returns false for scales without double flat or double sharp', () => {
expect(pipe.transform(['C', 'D'])).toBe(false);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Pipe, PipeTransform } from '@angular/core';
import { Scale } from '../../util/types';

@Pipe({
name: 'isTheoreticalScale'
})
export class IsTheoreticalScalePipe implements PipeTransform {

transform(scale: Scale): boolean {
for (const note of scale) {
if(note.indexOf('x') !== -1 || note.indexOf('𝄫') !== -1) {
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { GetEnharmonicEquivalentPipe } from './get-enharmonic-equivalent.pipe';

describe('GetHarmonicEquivalentPipe', () => {
it('create an instance', () => {
const pipe = new GetEnharmonicEquivalentPipe();
expect(pipe).toBeTruthy();
});

it('returns A♭ for G#', () => {
const pipe = new GetEnharmonicEquivalentPipe();
expect(pipe.transform('G#')).toBe('A♭');
})
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Pipe, PipeTransform } from '@angular/core';
import { Enharmonics } from '../../../util/constants';

@Pipe({
name: 'getEnharmonicEquivalent'
})
export class GetEnharmonicEquivalentPipe implements PipeTransform {

transform(note: string): string {
for (const group of Enharmonics) {
if (group.indexOf(note) === 0) {
return group[1]
}

if (group.indexOf(note) === 1) {
return group[0]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { GetEnharmonicRouterLinkPipe } from './get-enharmonic-router-link.pipe';

describe('GetEnharmonicRouterLinkPipe', () => {
let pipe;
beforeEach(() => {
pipe = new GetEnharmonicRouterLinkPipe();
});
it('create an instance', () => {
expect(pipe).toBeTruthy();
});

it('returns correctly for g sharp ionian', () => {
expect(pipe.transform('g', 'sharp', 'ionian')).toStrictEqual(['/', 'a', 'flat', 'ionian']);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Pipe, PipeTransform } from '@angular/core';
import { RouterLink } from '@angular/router';
import { Enharmonics } from '../../../util/constants';

@Pipe({
name: 'getEnharmonicRouterLink'
})
export class GetEnharmonicRouterLinkPipe implements PipeTransform {

transform(note: string, noteExtenderString: string, mode: string): string[] {
let newNote;

for(const group of Enharmonics) {
if (group[0].includes(note.toUpperCase())) {
newNote = group[1].charAt(0).toLowerCase();
}

if (group[1].includes(note.toUpperCase())) {
newNote = group[0].charAt(0).toLowerCase();
}
}

const newNoteExtender = noteExtenderString === 'sharp' ? 'flat' : 'sharp';

return ['/', newNote, newNoteExtender, mode];
}

}
Loading

0 comments on commit e1bac8d

Please sign in to comment.