Skip to content

Commit

Permalink
chore(src/components|dummydata): add new dummy & fix interval
Browse files Browse the repository at this point in the history
  • Loading branch information
NattapolChan committed Sep 3, 2023
1 parent cb2b6bc commit 4acb87a
Show file tree
Hide file tree
Showing 3 changed files with 239 additions and 136 deletions.
8 changes: 3 additions & 5 deletions src/components/tabs/playbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Array<fretRange>> | null
Expand All @@ -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<Note> = []
if (bar===null || bar===undefined) continue
Expand All @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/tabs/testnotemapping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const dummyNote: Array<Note> = [

export const tabToNote = ( fretId: number, stringId: number) => {
// return null if string not exist / no note played
const noteAtZero : Array<Note> = ["E2", "A2", "D3", "G3", "B3", "E4"]
const noteAtZero : Array<Note> = ["E4", "B3", "G3", "D3", "A2", "E2"]
const thisNoteAtZero = noteAtZero[stringId]
const number = dummyNote.indexOf(thisNoteAtZero)
if (fretId == -1) return null
Expand Down Expand Up @@ -63,4 +63,4 @@ const Test = () => {
)
}

export default Test;
export default Test;
Loading

0 comments on commit 4acb87a

Please sign in to comment.