|
@@ -10,6 +10,7 @@ import tockWav from "/src/assets/tock.mp3";
|
|
|
|
|
|
const tickData = reactive({
|
|
|
len: 0,
|
|
|
+ denominator: undefined as undefined | number,
|
|
|
reduceLen: 0,
|
|
|
tickEnd: false,
|
|
|
/** 节拍器时间 */
|
|
@@ -95,9 +96,11 @@ const createAudio = (src: string): Promise<HTMLAudioElement | null> => {
|
|
|
|
|
|
/** 设置节拍器
|
|
|
* @param beat 节拍数
|
|
|
+ * @param denominator 节拍器分母
|
|
|
*/
|
|
|
-export const handleInitTick = (beat: number) => {
|
|
|
+export const handleInitTick = (beat: number, denominator?: number) => {
|
|
|
tickData.len = beat;
|
|
|
+ tickData.denominator = denominator;
|
|
|
// 节拍器的个数除以2 直到小于等于4为止
|
|
|
while (beat > 4 && beat % 2 === 0) {
|
|
|
beat = beat / 2;
|
|
@@ -111,8 +114,7 @@ export const handleStartTick = async () => {
|
|
|
tickData.show = true;
|
|
|
tickData.tickEnd = false;
|
|
|
tickData.index = 0;
|
|
|
- // tickData.beatLengthInMilliseconds = (60 / state.speed) * 1000;
|
|
|
- tickData.beatLengthInMilliseconds = (state.times[0].xmlMp3BeatFixTime * 1000) / tickData.len || (60 / state.speed) * 1000;
|
|
|
+ tickData.beatLengthInMilliseconds = tickData.denominator ? 4 / tickData.denominator * (60 / state.speed) * 1000 : (60 / state.speed) * 1000;
|
|
|
for(let i = 0; i <= useLen.value; i++){
|
|
|
// 提前结束, 直接放回false
|
|
|
if (tickData.tickEnd) return false;
|