diff --git a/frontend/src/app/adapters/secondary/genres-adapter.service.ts b/frontend/src/app/adapters/secondary/genres-adapter.service.ts index 03a5f0e..b7103e3 100644 --- a/frontend/src/app/adapters/secondary/genres-adapter.service.ts +++ b/frontend/src/app/adapters/secondary/genres-adapter.service.ts @@ -18,7 +18,7 @@ export class GenresAdapterService implements IManageGenres { const effect = Effect.tryPromise({ try: async () => { const beats = await lastValueFrom(this.http.get(this.beatsUrl)); - const genres = this.groupBy(beats, (beat) => beat.genre!); + const genres = this.groupBy(beats, (beat) => beat.genre); return Object.keys(genres).map((genre) => ({ label: genre, beats: genres[genre], diff --git a/frontend/src/app/adapters/secondary/in-memory-data.service.ts b/frontend/src/app/adapters/secondary/in-memory-data.service.ts index edcda00..2ddb576 100644 --- a/frontend/src/app/adapters/secondary/in-memory-data.service.ts +++ b/frontend/src/app/adapters/secondary/in-memory-data.service.ts @@ -1,7 +1,6 @@ import {InMemoryDbService} from "angular-in-memory-web-api"; import {Injectable} from "@angular/core"; import {Beat} from "../../domain/beat"; -import {Genre} from "../../domain/genre"; @Injectable({ providedIn: 'root', @@ -12,6 +11,7 @@ export class InMemoryDataService implements InMemoryDbService { id: "metal", label: "Metal", bpm: 180, + genre: "Metal", tracks: [ { name: "Snare", @@ -29,12 +29,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: "XXXXXXXXXXXXXXXX".split('').map(step => step === 'X') } ] - } as Beat; + }; const technoBeat: Beat = { id: "techno", label: "4 on the floor", bpm: 128, + genre: "Techno", tracks: [ { name: "Snare", @@ -52,12 +53,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: "X X X X ".split('').map(step => step === 'X') } ] - } as Beat; + }; const rockBeat: Beat = { id: "rock-beat", label: "Rock", bpm: 145, + genre: "Metal", tracks: [ { name: "Snare", @@ -75,12 +77,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: "X X ".split('').map(step => step === 'X') } ] - } as Beat; + }; const rockBeatVariation: Beat = { id: "rock-beat-variation", label: "Rock variation", bpm: 145, + genre: "Metal", tracks: [ { name: "Snare", @@ -98,12 +101,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: "X X ".split('').map(step => step === 'X') } ] - } as Beat; + }; const psytranceBeat: Beat = { id: "psytrance", label: "Psytrance", bpm: 135, + genre: "Trance", tracks: [ { name: "Closed hats", @@ -131,12 +135,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: " XXX XXX XXX XXX".split('').map(step => step === 'X') } ] - } as Beat + } const offBeatTechnoClap: Beat = { id: "off-beat-techno-clap", label: "OffBeat clap", bpm: 128, + genre: "Techno", tracks: [ { name: "Clap", @@ -154,12 +159,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: "X X X X X X X X ".split('').map(step => step === 'X') } ] - } as Beat; + }; const jerseyClubBeat: Beat = { id: "jersey-club", label: "Jersey club", bpm: 140, + genre: "Breakbeat", tracks: [ { name: "Bed squeak (low)", @@ -183,12 +189,13 @@ export class InMemoryDataService implements InMemoryDbService { } ], //source: "https://youtu.be/qJtvgAYAuvs?si=ifBHVgsfUL32E2R0" - } as Beat; + }; const halfTimeGroove: Beat = { id: "half-time-groove", label: "Half time groove", bpm: 145, + genre: "Metal", tracks: [ { name: "Snare", @@ -206,12 +213,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: "X ".split('').map(step => step === 'X') } ] - } as Beat; + }; const garageTwoStep: Beat = { id: "garage", label: "Garage", bpm: 130, + genre: "Garage", tracks: [ { name: "Snare", @@ -229,12 +237,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: "X X ".split('').map(step => step === 'X') } ] - } as Beat; + }; const gabberBeat: Beat = { id: "gabber", label: "Gabber", bpm: 200, + genre: "Techno", tracks: [ { name: "Crash Cymbal", @@ -257,12 +266,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: "X X X X X X X X ".split('').map(step => step === 'X') } ] - } as Beat; + }; const ebmBeat: Beat = { id: "ebm", label: "EBM", bpm: 120, + genre: "Industrial", tracks: [ { name: "Clap", @@ -293,12 +303,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: "X X X X X X X X ".split('').map(step => step === 'X') } ] - } as Beat; + }; const dubBeat: Beat = { id: "dub", label: "Dub", bpm: 140, + genre: "Dub", tracks: [ { name: "Kick", @@ -339,12 +350,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: "X X ".split('').map(step => step === 'X') } ] - } as Beat; + }; const blastBeat: Beat = { id: "blast-beat", label: "Blast beat", bpm: 180, + genre: "Metal", tracks: [ { name: "Snare", @@ -362,12 +374,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: "X_X_X_X_X_X_X_X_".split('').map(step => step === 'X') } ] - } as Beat; + }; const breakcoreBeat: Beat = { id: "breakcore", label: "Breakcore", bpm: 180, + genre: "Breakbeat", tracks: [ { name: "Snare (accent)", @@ -391,12 +404,13 @@ export class InMemoryDataService implements InMemoryDbService { } ], //source: "https://onlinesequencer.net/2502318" - } as Beat; + }; const drumAndBassBeat: Beat = { id: "drum-n-bass", label: "Drum & bass", bpm: 170, + genre: "Garage", tracks: [ { name: "Snare", @@ -414,12 +428,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: "X X ".split('').map(step => step === 'X') } ] - } as Beat; + }; const standardDancehallBeat: Beat = { id: "dancehall-standard", label: "Standard dancehall", bpm: 105, + genre: "Dancehall", tracks: [ { name: "Hats", @@ -437,12 +452,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: "X X X X X X ".split('').map(step => step === 'X') } ] - } as Beat; + }; const reggaetonBeat: Beat = { id: "dancehall-reggaeton", label: "Reggaeton", bpm: 105, + genre: "Dancehall", tracks: [ { name: "Hats", @@ -460,12 +476,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: "X X X X ".split('').map(step => step === 'X') } ] - } as Beat; + }; const modernDancehallBeat: Beat = { id: "dancehall-modern", label: "Modern dancehall", bpm: 105, + genre: "Dancehall", tracks: [ { name: "Hats", @@ -483,12 +500,13 @@ export class InMemoryDataService implements InMemoryDbService { steps: "X X ".split('').map(step => step === 'X') } ] - } as Beat; + }; const punkBeatQuarterNoteGroove: Beat = { id: "punk-beat-quarter-note-groove", label: "Quarter note groove", bpm: 170, + genre: "Punk", tracks: [ { name: "Hats", @@ -507,12 +525,13 @@ export class InMemoryDataService implements InMemoryDbService { } ] //source : https://freedrumlessons.com/drum-lessons/punk-drum-beats.php - } as Beat + }; const punkBeatQuarterNoteGrooveVariation: Beat = { id: "punk-beat-quarter-note-groove-variation", label: "Quarter note groove variation", bpm: 170, + genre: "Punk", tracks: [ { name: "Hats", @@ -531,12 +550,13 @@ export class InMemoryDataService implements InMemoryDbService { } ] //source : https://freedrumlessons.com/drum-lessons/punk-drum-beats.php - } as Beat + }; const punkBeatEightNoteFill: Beat = { id: "punk-beat-eight-note-fill", label: "Eight note fill", bpm: 170, + genre: "Punk", tracks: [ { name: "Hats", @@ -555,50 +575,9 @@ export class InMemoryDataService implements InMemoryDbService { } ] //source : https://freedrumlessons.com/drum-lessons/punk-drum-beats.php - } as Beat + }; - const beats: Beat[] = [modernDancehallBeat, standardDancehallBeat, reggaetonBeat, drumAndBassBeat, breakcoreBeat, blastBeat, dubBeat, ebmBeat, metalBeat, technoBeat, rockBeat, rockBeatVariation, psytranceBeat, offBeatTechnoClap, jerseyClubBeat, halfTimeGroove, garageTwoStep, gabberBeat]; - - const genres: Genre[] = [ - { - label: "Techno", - beats: [technoBeat, gabberBeat, offBeatTechnoClap] - }, - { - label: "Garage", - beats: [garageTwoStep, drumAndBassBeat] - }, - { - label: "Breakbeat", - beats: [jerseyClubBeat, breakcoreBeat] - }, - { - label: "Dancehall", - beats: [reggaetonBeat, standardDancehallBeat, modernDancehallBeat] - }, - { - label: "Trance", - beats: [psytranceBeat] - }, - { - label: "Dub", - beats: [dubBeat] - }, - { - label: "Indus", - beats: [ebmBeat] - }, - { - label: "Metal", - beats: [metalBeat, halfTimeGroove, rockBeat, rockBeatVariation, blastBeat] - }, - { - label: "Punk", - beats: [punkBeatQuarterNoteGroove, punkBeatQuarterNoteGrooveVariation, punkBeatEightNoteFill] - } - ]; - - - return {genres, beats}; + const beats: Beat[] = [technoBeat, modernDancehallBeat, standardDancehallBeat, reggaetonBeat, drumAndBassBeat, breakcoreBeat, blastBeat, dubBeat, ebmBeat, metalBeat, rockBeat, rockBeatVariation, psytranceBeat, offBeatTechnoClap, jerseyClubBeat, halfTimeGroove, garageTwoStep, gabberBeat, punkBeatQuarterNoteGroove, punkBeatQuarterNoteGrooveVariation, punkBeatEightNoteFill]; + return {beats}; } } diff --git a/frontend/src/app/domain/beat.ts b/frontend/src/app/domain/beat.ts index 41027e2..a4df153 100644 --- a/frontend/src/app/domain/beat.ts +++ b/frontend/src/app/domain/beat.ts @@ -5,5 +5,5 @@ export interface Beat { label: string; bpm: number; tracks: Track[]; - genre: string | undefined; + genre: string; }