export const unitObj = {
   "1/1": 1 / 1,
   "1/2": 1 / 2,
   "1/4": 1 / 4,
   "1/8": 1 / 8,
   "1/16": 1 / 16,
   "1/2.": (1 / 2) * 1.5,
   "1/4.": (1 / 4) * 1.5,
   "1/8.": (1 / 8) * 1.5
} as Record<string, any>

/**
 * 速度转换，几分音符的速度转为几分音符的速度
 */
export const speedBeatTo = (speedBeat: { unit: string; speed: number }, unit: string) => {
   return (unitObj[speedBeat.unit] * speedBeat.speed) / unitObj[unit]
}

/** 谱面速度节拍器转为 约定的节拍器符号 */
export function beatUnitTo(beatUnit: string, isDot: boolean) {
   let multiple = "1/4"
   switch (beatUnit) {
      case "1024th":
         multiple = "1/1024"
         break
      case "512th":
         multiple = "1/512"
         break
      case "256th":
         multiple = "1/256"
         break
      case "128th":
         multiple = "1/128"
         break
      case "64th":
         multiple = "1/64"
         break
      case "32nd":
         multiple = "1/32"
         break
      case "16th":
         multiple = "1/16"
         break
      case "eighth":
         multiple = "1/8"
         break
      case "quarter":
         multiple = "1/4"
         break
      case "half":
         multiple = "1/2"
         break
      case "whole":
         multiple = "1/1"
      default:
         break
   }
   isDot && (multiple += ".")
   return multiple
}

/** 几分音符对应的速度图片 */
export const unitImgs = {
   "1/1": 'speed1',
   "1/2": 'speed2',
   "1/4": 'speed3',
   "1/8": 'speed4',
   "1/16": 'spee5',
   "1/2.": 'speed6',
   "1/4.": 'speed7',
   "1/8.": 'speed8',
} as Record<string, any>