Files
pocket-chords/app/app/lib/mock.ts

145 lines
3.5 KiB
TypeScript

import type { Song, SongSummary } from "./types";
const OCEAN: Song = {
meta: {
title: "A Drop In The Ocean",
artist: "Ron Pope",
capo: null,
original_key: "Em",
tuning: null,
tempo: null,
},
sections: [
{
kind: "chorus",
label: "Chorus",
lines: [
{
text: "A drop in the ocean,",
chords: [{ offset: 0, chord: "Em" }, { offset: 12, chord: "C" }],
},
{
text: "A change in the weather,",
chords: [{ offset: 2, chord: "G" }, { offset: 16, chord: "D" }],
},
{
text: "I was praying that you and me might end up together.",
chords: [
{ offset: 6, chord: "Em" },
{ offset: 17, chord: "C" },
{ offset: 33, chord: "G" },
{ offset: 44, chord: "D" },
],
},
],
},
{
kind: "verse",
label: "Verse",
lines: [
{
text: "I don't wanna waste the weekend,",
chords: [{ offset: 0, chord: "C" }, { offset: 15, chord: "G" }],
},
{
text: "If you don't love me, pretend",
chords: [{ offset: 3, chord: "D" }, { offset: 21, chord: "Em" }],
},
{
text: "A few more hours, then it's time to go.",
chords: [{ offset: 2, chord: "C" }, { offset: 18, chord: "G" }, { offset: 30, chord: "D" }],
},
],
},
{
kind: "bridge",
label: "Bridge",
lines: [
{
text: "Still I can't let you be,",
chords: [{ offset: 0, chord: "Am" }, { offset: 11, chord: "G" }, { offset: 13, chord: "D" }],
},
],
},
],
};
const NAKED: Song = {
meta: {
title: "Naked",
artist: "James Arthur",
capo: null,
original_key: "G",
tuning: null,
tempo: null,
},
sections: [
{
kind: "chorus",
label: "Chorus",
lines: [
{
text: "I'm not going to wait until you're done",
chords: [{ offset: 0, chord: "G" }, { offset: 18, chord: "Bm" }],
},
{
text: "Pretending you don't need anyone",
chords: [{ offset: 16, chord: "Em" }, { offset: 27, chord: "C" }],
},
{
text: "I'm standing here naked",
chords: [{ offset: 19, chord: "G" }],
},
],
},
{
kind: "verse",
label: "Verse",
lines: [
{
text: "I lay awake thinking of all I wasted",
chords: [{ offset: 0, chord: "G" }, { offset: 22, chord: "Bm" }],
},
{
text: "All of the time we had I took for granted",
chords: [{ offset: 11, chord: "Em" }, { offset: 32, chord: "C" }],
},
],
},
],
};
const SONGS_MAP: Record<string, Song> = {
"song-ocean": OCEAN,
"song-naked": NAKED,
};
export function previewChords(song: Song): string[] {
const seen = new Set<string>();
const result: string[] = [];
for (const section of song.sections) {
for (const line of section.lines) {
for (const cp of line.chords) {
if (!seen.has(cp.chord)) {
seen.add(cp.chord);
result.push(cp.chord);
}
}
}
if (result.length >= 5) break;
}
return result.slice(0, 5);
}
export const MOCK_SONGS: SongSummary[] = Object.entries(SONGS_MAP).map(
([id, song]) => ({
id,
meta: song.meta,
preview_chords: previewChords(song),
})
);
export function getMockSong(id: string): Song | null {
return SONGS_MAP[id] ?? null;
}