Skip to content

Commit 8607752

Browse files
committed
add types in domain and remove sample.ts in sound folder
1 parent a85378b commit 8607752

File tree

7 files changed

+30
-26
lines changed

7 files changed

+30
-26
lines changed

frontend/src/app/components/sequencer/sequencer.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import {SelectInputComponent} from "../select-input/select-input.component";
1919
})
2020
export class SequencerComponent implements OnInit {
2121
beat = {} as Beat;
22-
genre = {} as BeatsGroupedByGenre;
23-
beatBehaviourSubject: Subject<Beat>;
22+
genre = {} as BeatsGroupedByGenre;
23+
private readonly beatBehaviourSubject: Subject<Beat>;
2424
genresLabel: string[] = [];
2525
selectedGenreLabel: string = "";
2626
beats: string[] = [];

frontend/src/app/domain/beat.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Track } from "./track";
22

3-
export interface Beat {
4-
id: string;
5-
label: string;
6-
bpm: number;
7-
genre: string;
8-
tracks: Track[];
3+
export type Beat = {
4+
readonly id: string;
5+
readonly label: string;
6+
readonly bpm: number;
7+
readonly genre: string;
8+
readonly tracks: ReadonlyArray<Track>;
99
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Beat} from "./beat";
22

3-
export interface BeatsGroupedByGenre {
4-
label: string;
5-
beats: Beat[];
3+
export type BeatsGroupedByGenre = {
4+
readonly label: string;
5+
readonly beats: Beat[];
66
}

frontend/src/app/domain/track.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export interface Track {
2-
name: string;
3-
fileName: string;
4-
steps: boolean[];
1+
export type Track = {
2+
readonly name: string;
3+
readonly fileName: string;
4+
readonly steps: boolean[];
55
}
File renamed without changes.

frontend/src/app/services/sound/sound-generator.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Injectable} from "@angular/core";
22
import {Track} from "../../domain/track";
3-
import {Sample} from "../../domain/sample";
3+
import {Sample} from "./sample";
44

55
@Injectable({providedIn: "root"})
66
export class SoundGeneratorService {

frontend/src/app/services/sound/sound.service.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Injectable} from '@angular/core';
2-
import {Sample} from '../../domain/sample';
2+
import {Sample} from './sample';
33
import {Track} from '../../domain/track';
44
import {AudioFilesService} from "../files/audio-files.service";
55
import {SoundGeneratorService} from "./sound-generator.service";
@@ -9,17 +9,21 @@ import {LoadingBarService} from '@ngx-loading-bar/core';
99
providedIn: 'root'
1010
})
1111
export class SoundService {
12-
static maxBpm = 1300;
13-
static minBpm = 30;
12+
private readonly audioFilesService = new AudioFilesService();
13+
private readonly context: AudioContext;
14+
15+
static readonly maxBpm = 1300;
16+
static readonly minBpm = 30;
17+
1418
bpm: number = 120;
1519
isPlaying: boolean = false;
1620
index: number = 0;
17-
private samples: Sample[] = [];
18-
private context: AudioContext;
19-
private tracks: Track[] = [];
20-
private playbackSource: AudioBufferSourceNode;
21+
22+
private samples: Array<Sample> = [];
23+
private tracks: Array<Track> = [];
24+
2125
private stepNumber: number = 16;
22-
private audioFilesService = new AudioFilesService();
26+
private playbackSource: AudioBufferSourceNode;
2327
private loopBuffer: AudioBuffer | null = null;
2428

2529
constructor(
@@ -98,8 +102,8 @@ export class SoundService {
98102
this.bpm = bpm;
99103
}
100104

101-
setTracks(tracks: Track[]) {
102-
this.tracks = tracks;
105+
setTracks(tracks: readonly Track[]) {
106+
this.tracks = [...tracks];
103107
const trackNames = tracks.map(x => x.fileName);
104108
this.loadTracks(trackNames);
105109
}

0 commit comments

Comments
 (0)