1
- import { Component , ElementRef , EventEmitter , Input , OnChanges , OnInit , Output , ViewChild } from '@angular/core' ;
1
+ import {
2
+ ChangeDetectorRef ,
3
+ Component ,
4
+ ElementRef ,
5
+ EventEmitter ,
6
+ Input ,
7
+ OnChanges ,
8
+ OnInit ,
9
+ Output ,
10
+ ViewChild
11
+ } from '@angular/core' ;
2
12
import { FretMap , Mode } from '../../../util/types' ;
3
13
import { NotePlaybackService } from '../../playback/note-playback.service' ;
4
14
import { AbstractDataService } from '../../abstract-data/abstract-data.service' ;
@@ -19,6 +29,30 @@ export enum NoteDisplays {
19
29
noteNames = 'noteNames'
20
30
}
21
31
32
+ enum Tunings {
33
+ standard = 'standard' ,
34
+ dropD = 'dropD'
35
+ }
36
+
37
+ const TuningReturner = {
38
+ 'standard' : [
39
+ { stringName : 'E' , string : 'E' } ,
40
+ { stringName : 'A' , string : 'A' } ,
41
+ { stringName : 'D' , string : 'D' } ,
42
+ { stringName : 'G' , string : 'G' } ,
43
+ { stringName : 'B' , string : 'B' } ,
44
+ { stringName : 'e' , string : 'E' }
45
+ ] ,
46
+ 'dropD' : [
47
+ { stringName : 'D' , string : 'D' } ,
48
+ { stringName : 'A' , string : 'A' } ,
49
+ { stringName : 'D' , string : 'D' } ,
50
+ { stringName : 'G' , string : 'G' } ,
51
+ { stringName : 'B' , string : 'B' } ,
52
+ { stringName : 'e' , string : 'E' }
53
+ ]
54
+ } ;
55
+
22
56
const FretReturner = {
23
57
'twelve' : [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 ] ,
24
58
'twentyFour' : [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 ]
@@ -27,7 +61,8 @@ const FretReturner = {
27
61
const StorageKeys = {
28
62
fretMode : 'fretonator_fretMode' ,
29
63
orientation : 'fretonator_orientation' ,
30
- noteNameDisplay : 'fretonator_noteNameDisplay'
64
+ noteNameDisplay : 'fretonator_noteNameDisplay' ,
65
+ tuning : 'fretonator_tuning'
31
66
} ;
32
67
33
68
@Component ( {
@@ -46,19 +81,24 @@ export class FretboardComponent implements OnChanges, OnInit {
46
81
orientation ;
47
82
fretMode ;
48
83
frets ;
84
+ strings ;
85
+ tuning ;
49
86
highlightedDegrees = new Set < ScaleDegrees > ( ) ;
50
87
noteNameDisplay = NoteDisplays . noteNames ;
51
88
52
89
constructor ( public playbackService : NotePlaybackService ,
53
- private localStorage : AbstractDataService ) {
90
+ private localStorage : AbstractDataService ,
91
+ private cd : ChangeDetectorRef ) {
54
92
}
55
93
56
94
ngOnInit ( ) {
57
95
this . loadPropFromStorage ( StorageKeys . fretMode , 'fretMode' , FretModes . twelve ) ;
58
96
this . loadPropFromStorage ( StorageKeys . orientation , 'orientation' , Orientations . right ) ;
59
97
this . loadPropFromStorage ( StorageKeys . noteNameDisplay , 'noteNameDisplay' , NoteDisplays . noteNames ) ;
98
+ this . loadPropFromStorage ( StorageKeys . tuning , 'tuning' , Tunings . standard ) ;
60
99
61
100
this . toggleHighlight ( ScaleDegrees . tonic ) ;
101
+ this . configureStrings ( ) ;
62
102
this . configureFretboard ( ) ;
63
103
}
64
104
@@ -84,6 +124,14 @@ export class FretboardComponent implements OnChanges, OnInit {
84
124
return NoteDisplays ;
85
125
}
86
126
127
+ get Tunings ( ) {
128
+ return Tunings ;
129
+ }
130
+
131
+ configureStrings ( ) {
132
+ this . strings = TuningReturner [ this . tuning ] ;
133
+ }
134
+
87
135
configureFretboard ( ) {
88
136
this . frets = FretReturner [ this . fretMode ] ;
89
137
this . loadExpandedChange . emit ( this . fretMode === FretModes . twentyFour ) ;
@@ -101,6 +149,12 @@ export class FretboardComponent implements OnChanges, OnInit {
101
149
this . configureFretboard ( ) ;
102
150
}
103
151
152
+ setTuning ( tuning : Tunings ) {
153
+ this . tuning = tuning ;
154
+ this . localStorage . setItem ( StorageKeys . tuning , this . tuning ) ;
155
+ this . configureStrings ( ) ;
156
+ }
157
+
104
158
toggleHighlight ( degree : ScaleDegrees ) {
105
159
this . highlightedDegrees . has ( degree ) ? this . highlightedDegrees . delete ( degree ) : this . highlightedDegrees . add ( degree ) ;
106
160
}
0 commit comments