File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
apps/fretonator-web/src/app/common/playback Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -10,17 +10,18 @@ const SYNTH_PLAY_DURATION = 2000;
10
10
export class NotePlaybackService {
11
11
private context : AudioContext ;
12
12
13
- constructor ( ) {
14
- try {
15
- // Feature sniff for web audio API
16
- this . context = new ( window . AudioContext || window [ 'webkitAudioContext' ] ) ;
17
- } catch ( e ) {
18
- // No browser support :(
19
- }
20
- }
13
+ constructor ( ) { }
21
14
22
15
playNote ( stringName , fret ) {
23
- if ( this . context ) {
16
+ if ( ! this . context ) {
17
+ try {
18
+ // Feature sniff for web audio API
19
+ this . context = new ( window . AudioContext || window [ 'webkitAudioContext' ] ) ;
20
+ } catch ( e ) {
21
+ // No browser support :(
22
+ }
23
+ }
24
+ if ( this . context ) {
24
25
const noteFrequency = this . getFrequency ( stringName , fret ) ;
25
26
this . pluckString ( noteFrequency ) ;
26
27
}
You can’t perform that action at this time.
0 commit comments