-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c69432d
commit 7a00973
Showing
3 changed files
with
59 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,69 @@ | ||
<script lang="ts"> | ||
import PitchNotation from '$/lib/notation/PitchNotation.svelte'; | ||
import FingerBoard, { type FingerInfo } from '$/lib/guitar/finger-board/FingerBoard.svelte'; | ||
import { identifyChordsFromPitches } from '$/utils/music/chords'; | ||
import { stringifyFinaleJazzChordSigns } from '$/utils/music/font'; | ||
import { | ||
getPitchFromNumber, | ||
getPitchesFromFingerPositions, | ||
sortPitches | ||
} from '$/utils/music/pitch'; | ||
import FingerBoard, { type FingerInfo } from '$/lib/guitar/finger-board/FingerBoard.svelte'; | ||
import ChordNotation from '$lib/notation/ChordNotation.svelte'; | ||
export let fingers: FingerInfo[] = []; | ||
$: pitches = sortPitches(getPitchesFromFingerPositions(fingers.map((finger) => finger.position))); | ||
$: chords = identifyChordsFromPitches(pitches); | ||
$: { | ||
console.log(chords?.bass, chords?.chords[0].symbols); | ||
} | ||
export let isFingerboardHidden = false; | ||
</script> | ||
|
||
{#if chords != undefined} | ||
{#each chords.chords as chord} | ||
<div class="mb-[0.5em] block h-fit select-none text-center text-[80px] leading-[1.2em]"> | ||
<ChordNotation | ||
root={getPitchFromNumber(chord.symbols.root).note} | ||
quality={chord.symbols.quality} | ||
extension={chord.symbols.extension ?? undefined} | ||
tensions={chord.tones.tensions} | ||
bass={getPitchFromNumber(chords.bass).note} | ||
/> | ||
<div class="relative flex h-full flex-col items-center justify-center"> | ||
{#if chords != undefined} | ||
{@const primaryChord = chords.chords.at(0)} | ||
<div class="flex flex-col items-center gap-8 lg:flex-row lg:gap-28"> | ||
{#if primaryChord} | ||
<div class="inline-block h-fit select-none text-center text-[80px] leading-[1.2em]"> | ||
<ChordNotation | ||
root={getPitchFromNumber(primaryChord.symbols.root).note} | ||
quality={primaryChord.symbols.quality} | ||
extension={primaryChord.symbols.extension} | ||
tensions={primaryChord.tones.tensions} | ||
bass={getPitchFromNumber(chords.bass).note} | ||
/> | ||
</div> | ||
{/if} | ||
<div class="flex flex-col"> | ||
{#each chords.chords.slice(1) as chord, idx} | ||
{#if idx === 0} | ||
<div class="inline-block h-fit select-none text-center text-[60px] leading-[1.2em]"> | ||
<ChordNotation | ||
root={getPitchFromNumber(chord.symbols.root).note} | ||
quality={chord.symbols.quality} | ||
extension={chord.symbols.extension} | ||
tensions={chord.tones.tensions} | ||
bass={getPitchFromNumber(chords.bass).note} | ||
/> | ||
</div> | ||
{:else} | ||
<div class="block h-fit select-none text-center text-[40px] leading-[1.2em]"> | ||
<ChordNotation | ||
root={getPitchFromNumber(chord.symbols.root).note} | ||
quality={chord.symbols.quality} | ||
extension={chord.symbols.extension} | ||
tensions={chord.tones.tensions} | ||
bass={getPitchFromNumber(chords.bass).note} | ||
/> | ||
</div> | ||
{/if} | ||
{/each} | ||
</div> | ||
</div> | ||
{/each} | ||
{/if} | ||
<p> | ||
{/if} | ||
</div> | ||
<!-- <p> | ||
{#each pitches as pitch} | ||
<PitchNotation note={pitch.note} octave={pitch.octave}></PitchNotation> | ||
{/each} | ||
<span class="font-chord"> | ||
{stringifyFinaleJazzChordSigns(['MinorSixth'])} | ||
{String.fromCodePoint(225 + 29)} | ||
</span> | ||
</p> | ||
{#if !isFingerboardHidden} | ||
<FingerBoard {fingers} fretRange={{ start: 0, end: 12, visibility: 'all' }} on:click /> | ||
{/if} | ||
</p> --> | ||
<FingerBoard | ||
class="mb-28 w-screen lg:w-[calc(100vw-14rem)]" | ||
{fingers} | ||
fretRange={{ start: 0, end: 12, visibility: 'all' }} | ||
on:click | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters