From 4acb87aaf4bba61a6ae515650339f117225bff2e Mon Sep 17 00:00:00 2001 From: NattapolChan <66078943+NattapolChan@users.noreply.github.com> Date: Mon, 4 Sep 2023 03:23:55 +0800 Subject: [PATCH] chore(src/components|dummydata): add new dummy & fix interval --- src/components/tabs/playbar.tsx | 8 +- src/components/tabs/testnotemapping.tsx | 4 +- src/dummydata/dummytab.ts | 363 +++++++++++++++--------- 3 files changed, 239 insertions(+), 136 deletions(-) diff --git a/src/components/tabs/playbar.tsx b/src/components/tabs/playbar.tsx index 5886b30..4cbb3fc 100644 --- a/src/components/tabs/playbar.tsx +++ b/src/components/tabs/playbar.tsx @@ -3,6 +3,7 @@ import React, { useEffect } from 'react' import { Status } from 'use-timer/lib/types' import { Note } from "tone/build/esm/core/type/NoteUnits" import { tabToNote } from './testnotemapping' +import { Instrument } from 'tone/build/esm/instrument/Instrument' type PlayBarProps = { bar: Array> | null @@ -14,7 +15,6 @@ const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)); const PlayBar = ({bar, status, guitarAcoustic} : PlayBarProps) => { useEffect(()=>{ - // console.log(bar) for (let i=0;i<8;i++) { let notes: Array = [] if (bar===null || bar===undefined) continue @@ -25,14 +25,12 @@ const PlayBar = ({bar, status, guitarAcoustic} : PlayBarProps) => { if (note===null) continue notes.push(note) } - console.log(notes) if (notes.length===0) continue try{ - guitarAcoustic.playNote(notes, 1) + guitarAcoustic.playNote(notes, 0.5, `+${i*0.135}`, 0.20) } catch(err){ - console.log(err) - console.log(notes) + console.log(err) } // guitarAcoustic?.playNote(notes, 1) } diff --git a/src/components/tabs/testnotemapping.tsx b/src/components/tabs/testnotemapping.tsx index 67d23f6..161d92d 100644 --- a/src/components/tabs/testnotemapping.tsx +++ b/src/components/tabs/testnotemapping.tsx @@ -11,7 +11,7 @@ const dummyNote: Array = [ export const tabToNote = ( fretId: number, stringId: number) => { // return null if string not exist / no note played - const noteAtZero : Array = ["E2", "A2", "D3", "G3", "B3", "E4"] + const noteAtZero : Array = ["E4", "B3", "G3", "D3", "A2", "E2"] const thisNoteAtZero = noteAtZero[stringId] const number = dummyNote.indexOf(thisNoteAtZero) if (fretId == -1) return null @@ -63,4 +63,4 @@ const Test = () => { ) } -export default Test; \ No newline at end of file +export default Test; diff --git a/src/dummydata/dummytab.ts b/src/dummydata/dummytab.ts index a4554d3..7f360b5 100644 --- a/src/dummydata/dummytab.ts +++ b/src/dummydata/dummytab.ts @@ -2,167 +2,272 @@ import { songObjectType } from "@/type/tabs" export const dummyTab : songObjectType = { bpm: 120, // dont care for now timeSig: [4, 4], // dont care for now - stringTune: ['E', 'A', 'D', 'G', 'B', 'e'], + stringTune: ['e', 'A', 'D', 'G', 'B', 'E'], tab: [ [ - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], + [-1, -1, 0, -1, -1, -1], + [-1, 0, -1, -1, -1, -1], + [3, -1, -1, 2, -1, -1], + [-1, -1, -1, -1, -1, -1], + [2, -1, 0, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [3, 0, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], ], [ + [2, -1, 0, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [3, -1, -1, -1, 3, -1], + [-1, -1, -1, -1, -1, -1], + [-1, 3, 0, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [3, -1, -1, -1, 3, -1], + [-1, -1, -1, -1, -1, -1], + ], + [ + [-1, 1, 0, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + ], + [ + [-1, -1, 0, -1, -1, -1], + [-1, 0, -1, -1, -1, -1], + [3, -1, -1, 2, -1, -1], + [-1, -1, -1, -1, -1, -1], + [2, -1, 0, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [3, 0, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + ], + [ + [2, -1, 0, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [3, -1, -1, -1, 3, -1], + [-1, -1, -1, -1, -1, -1], + [-1, 3, 0, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [3, -1, -1, -1, 3, -1], + [-1, -1, -1, -1, -1, -1], + ], + [ + [-1, 1, 0, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + ], + [ + [-1, -1, 0, -1, -1, -1], + [-1, 0, -1, -1, -1, -1], + [3, -1, -1, 2, -1, -1], + [-1, 0, -1, -1, -1, -1], + [2, -1, 0, -1, -1, -1], + [3, -1, -1, -1, -1, -1], + [-1, -1, -1, 2, -1, -1], + [-1, 0, -1, -1, -1, -1], + ], + [ + [2,-1,0,-1,-1,-1], + [3,-1,-1,0,-1,-1], + [-1,-1,-1,-1,3,-1], + [-1,-1,0,-1,-1,-1], + [-1,3,-1,-1,-1,-1], + [3,-1,-1,-1,-1,-1], + [-1,-1,-1,-1,3,-1], + [-1,-1,0,-1,-1,-1], + ], + [ + [-1, 1, -1, -1, -1, -1], + [-1, -1, -1, 0, -1, -1], + [-1, -1, 4, -1, -1, 3], + [-1, -1, -1, -1, -1, -1], + [-1, 1, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [-1, 3, 0, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + ], + [ + [-1, 0, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, 2, -1, 0, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, 0, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, -1, -1], + ], + [ + [-1, -1, 0, -1, -1, -1], + [-1, -1, -1, 4, -1, -1], + [-1, -1, 0, -1, -1, 0], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, -1, 2, -1], + [-1, -1, -1, -1, -1, -1], + [-1, -1, -1, 2, -1, -1], + [-1, -1, -1, -1, -1, -1], + ], + [ + [-1, -1, 0, -1, -1, -1], + [-1, -1, 2, -1, -1, -1], + [-1, 0, -1, -1, 3, -1], + [-1, -1, -1, 2, -1, -1], + [-1, -1, 0, -1, -1, -1], + [-1, -1, 2, -1, -1, -1], + [-1, 0, -1, -1, -1, -1], + [-1, -1, -1, -1, 3, -1], + ], + [ + [-1, 0, 0, -1, -1, -1], + [-1, 1, -1, -1, -1, -1], + [-1, 3, -1, -1, -1, 3], + [-1, -1, -1, 0, -1, -1], + [-1, 0, 0, -1, -1, -1], + [-1, 1, -1, -1, -1, -1], + [-1, 3, -1, -1, -1, -1], [-1, -1, -1, -1, -1, 3], - [-1, -1, -1, 4, -1, 3], - [-1, -1, -1, -1, -1, 3], - [-1, -1, -1, 4, -1, 3], - [-1, -1, -1, 4, -1, 3], - [-1, -1, -1, -1, -1, 3], - [-1, -1, -1, 4, -1, 3], - [-1, -1, -1, 4, -1, 3], ], [ - [-1, 0, 0, 2, 3, 2], - [-1, 0, 0, 2, 3, 2], - [-1, 0, 0, 2, 3, 2], - [-1, 0, 0, 2, 3, 2], - [-1, 0, 0, 2, 3, 2], - [-1, 0, 0, 2, 3, 2], - [-1, 0, 0, 2, 3, 2], - [-1, 0, 0, 2, 3, 2], + [-1,0,0,-1,-1,-1], + [-1,1,-1,-1,-1,-1], + [-1,3,-1,-1,-1,3], + [-1,-1,-1,0,-1,-1], + [-1,0,0,-1,-1,-1], + [-1,3,-1,-1,-1,-1], + [-1,-1,-1,-1,-1,3], ], [ - [-1, 0, 0, 2, 3, 2], - [-1, 0, 0, 2, 3, 2], - [-1, 0, 0, 2, 3, 2], - [-1, 0, 0, 2, 3, 2], - [-1, 0, 0, 2, 3, 2], - [-1, 0, 0, 2, 3, 2], - [-1, 0, 0, 2, 3, 2], - [-1, 0, 0, 2, 3, 2], + [-1,1,-1,-1,-1,-1], + [-1,0,-1,-1,-1,-1], + [-1,-1,2,0,-1,-1], + [-1,-1,-1,0,-1,-1], + [-1,1,-1,-1,-1,-1], + [-1,0,-1,-1,-1,-1], + [-1,-1,2,-1,-1,-1], ], [ - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], + [-1,-1,-1,4,-1,-1], + [-1,-1,-1,-1,-1,-1], + [3,-1,-1,2,-1,-1], + [2,-1,0,-1,-1,-1], + [3,-1,-1,-1,-1,-1], + [-1,-1,-1,2,-1,-1], + [-1,0,-1,-1,-1,-1], ], [ - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], + [2,-1,0,-1,-1,-1], + [3,-1,-1,0,-1,-1], + [-1,-1,-1,-1,3,-1], + [-1,-1,0,-1,-1,-1], + [-1,3,-1,-1,-1,-1], + [3,-1,-1,-1,-1,-1], + [-1,-1,-1,-1,3,-1], + [-1,-1,0,-1,-1,-1], ], [ - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], + [-1,1,-1,-1,-1,-1], + [-1,-1,-1,0,-1,-1], + [-1,-1,4,-1,-1,3], + [-1,-1,-1,-1,-1,-1], + [-1,1,-1,-1,-1,-1], + [-1,-1,-1,-1,-1,-1], + [-1,3,0,-1,-1,-1], + [-1,-1,-1,-1,-1,-1], ], [ - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], + [7,-1,-1,-1,-1,-1], + [-1,-1,-1,-1,-1,-1], + [5,-1,-1,0,-1,-1], + [-1,-1,-1,-1,-1,-1], + [-1,-1,-1,0,-1,-1], + [5,-1,-1,-1,-1,-1], + [7,-1,-1,-1,-1,-1], + [5,-1,-1,-1,-1,-1], ], [ - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], + [3,-1,-1,-1,-1,-1], + [2,-1,-1,-1,-1,-1], + [3,-1,-1,-1,-1,0], + [-1,-1,-1,-1,-1,-1], + [-1,-1,-1,2,-1,-1], + [-1,-1,-1,-1,-1,-1], + [-1,-1,0,-1,-1,-1], + [-1,-1,-1,-1,-1,-1], ], [ - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], + [-1,-1,0,-1,-1,-1], + [-1,-1,2,-1,-1,-1], + [-1,0,-1,-1,3,-1], + [-1,-1,-1,-1,-1,-1], + [-1,-1,-1,2,-1,-1], + [-1,-1,-1,-1,-1,-1], + [-1,-1,0,-1,-1,-1], + [-1,-1,-1,-1,-1,-1], ], [ - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], + [-1,0,0,-1,-1,-1], + [-1,1,-1,-1,-1,-1], + [-1,3,-1,-1,-1,3], + [-1,-1,-1,-1,-1,-1], + [-1,-1,-1,0,-1,-1], + [-1,-1,-1,-1,-1,-1], + [-1,-1,0,-1,-1,-1], + [-1,-1,-1,-1,-1,-1], ], [ - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], + [-1,1,-1,-1,-1,-1], + [-1,0,-1,-1,-1,-1], + [-1,-1,2,0,-1,-1], + [-1,-1,-1,0,-1,-1], + [-1,-1,-1,0,-1,-1], + [-1,-1,0,-1,-1,-1], + [3,-1,-1,-1,-1,-1], + [5,-1,-1,-1,-1,-1], ], [ - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], + [3,-1,-1,-1,-1,-1], + [2,-1,-1,-1,-1,-1], + [3,-1,-1,-1,-1,0], + [-1,-1,0,-1,-1,-1], + [-1,3,-1,-1,-1,-1], + [-1,-1,-1,-1,-1,0], + [3,-1,-1,-1,-1,-1], + [5,-1,-1,-1,-1,-1], ], [ - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], + [3,-1,-1,-1,-1,-1], + [2,-1,-1,-1,-1,-1], + [3,-1,-1,-1,3,-1], + [-1,-1,0,-1,-1,-1], + [-1,3,-1,-1,-1,-1], + [-1,-1,-1,-1,3,-1], + [3,-1,-1,-1,-1,-1], + [5,-1,-1,-1,-1,-1], ], [ - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], - [2, 2, 4, 4, 3, 2], + [3,-1,-1,-1,-1,-1], + [2,-1,-1,-1,-1,-1], + [3,-1,-1,-1,-1,3], + [5,-1,-1,-1,-1,-1], + [7,-1,-1,-1,0,-1], + [8,-1,-1,-1,-1,-1], + [10,-1,-1,-1,-1,7], + [7,-1,-1,-1,-1,-1], ], [ - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], - [3, 5, 5, 4, 3, 3], + [-1,10,-1,-1,-1,-1], + [-1,8,-1,-1,-1,-1], + [-1,7,-1,0,-1,-1], + [-1,-1,-1,-1,-1,-1], + [-1,-1,7,-1,-1,-1], + [-1,-1,-1,-1,0,-1], + [3,-1,-1,-1,-1,-1], + [5,-1,-1,-1,-1,-1], ], [ [2, 2, 4, 4, 3, 2], @@ -276,4 +381,4 @@ export const userTabs = [ date: 'Mar 16, 2020', datetime: '2020-03-16', }, -] \ No newline at end of file +]