Skip to content

Commit

Permalink
add genre name in beat
Browse files Browse the repository at this point in the history
  • Loading branch information
Babali42 committed Jan 25, 2025
1 parent a55992f commit 464f763
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class GenresAdapterService implements IManageGenres {
const effect = Effect.tryPromise({
try: async () => {
const beats = await lastValueFrom(this.http.get<Beat[]>(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],
Expand Down
109 changes: 44 additions & 65 deletions frontend/src/app/adapters/secondary/in-memory-data.service.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -12,6 +11,7 @@ export class InMemoryDataService implements InMemoryDbService {
id: "metal",
label: "Metal",
bpm: 180,
genre: "Metal",
tracks: [
{
name: "Snare",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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)",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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)",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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};
}
}
2 changes: 1 addition & 1 deletion frontend/src/app/domain/beat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export interface Beat {
label: string;
bpm: number;
tracks: Track[];
genre: string | undefined;
genre: string;
}

0 comments on commit 464f763

Please sign in to comment.