-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
* Improve: レンダリング順を改善 * Fix: 値を修正 * Fix: toEqualを使う * 音域補正用のパラメーターを増やしつつ、開発時のみの機能に (#1902) * 音高補正にしつつ開発時のみ機能に * VoiceKey→GuidePitch * とりあえず実装としては完成 * keyRangeAdjustmentに * (note|guide)KeyShiftを消し、補正→調整にする * keyShiftを全てKeyRangeAdjustmentへ * Update: mainに追従 * Improve: レビューを反映 Co-Authored-By: Hiroshiba <[email protected]> * Change: findPriorPhrases -> selectPriorPhrases * Delete: 不要な型アサーションを削除 Co-Authored-By: sigprogramming <[email protected]> * Add: 型アサーションを追加 * Update src/sing/domain.ts * Update src/sing/domain.ts --------- Co-authored-by: Hiroshiba <[email protected]> Co-authored-by: Hiroshiba <[email protected]> Co-authored-by: sigprogramming <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { it, expect } from "vitest"; | ||
import { Phrase, PhraseState } from "@/store/type"; | ||
import { DEFAULT_TPQN } from "@/sing/storeHelper"; | ||
import { selectPriorPhrase } from "@/sing/domain"; | ||
import { EngineId, StyleId } from "@/type/preload"; | ||
|
||
const tempos = [ | ||
{ | ||
position: 0, | ||
bpm: 60, | ||
}, | ||
]; | ||
const createPhrase = ( | ||
start: number, | ||
end: number, | ||
state: PhraseState | ||
): Phrase => { | ||
return { | ||
Check failure on line 18 in tests/unit/lib/selectPriorPhrase.spec.ts GitHub Actions / lint
Check failure on line 18 in tests/unit/lib/selectPriorPhrase.spec.ts GitHub Actions / build-and-upload (linux-cpu-prepackage)
Check failure on line 18 in tests/unit/lib/selectPriorPhrase.spec.ts GitHub Actions / build-and-upload (linux-nvidia-prepackage)
Check failure on line 18 in tests/unit/lib/selectPriorPhrase.spec.ts GitHub Actions / build-test
Check failure on line 18 in tests/unit/lib/selectPriorPhrase.spec.ts GitHub Actions / build-and-upload (windows-cpu-prepackage)
Check failure on line 18 in tests/unit/lib/selectPriorPhrase.spec.ts GitHub Actions / build-and-upload (linux-nvidia-prepackage)
Check failure on line 18 in tests/unit/lib/selectPriorPhrase.spec.ts GitHub Actions / build-and-upload (linux-cpu-prepackage)
Check failure on line 18 in tests/unit/lib/selectPriorPhrase.spec.ts GitHub Actions / build-and-upload (windows-directml-prepackage)
Check failure on line 18 in tests/unit/lib/selectPriorPhrase.spec.ts GitHub Actions / build-and-upload (windows-nvidia-prepackage)
Check failure on line 18 in tests/unit/lib/selectPriorPhrase.spec.ts GitHub Actions / build-and-upload (macos-cpu-prepackage)
Check failure on line 18 in tests/unit/lib/selectPriorPhrase.spec.ts GitHub Actions / build-and-upload (windows-cpu-prepackage)
Check failure on line 18 in tests/unit/lib/selectPriorPhrase.spec.ts GitHub Actions / build-and-upload (windows-directml-prepackage)
Check failure on line 18 in tests/unit/lib/selectPriorPhrase.spec.ts GitHub Actions / build-and-upload (windows-nvidia-prepackage)
Check failure on line 18 in tests/unit/lib/selectPriorPhrase.spec.ts GitHub Actions / build-and-upload (macos-cpu-prepackage)
|
||
notes: [], | ||
startTicks: start * DEFAULT_TPQN, | ||
endTicks: end * DEFAULT_TPQN, | ||
keyRangeAdjustment: 0, | ||
state, | ||
tempos, | ||
tpqn: DEFAULT_TPQN, | ||
singer: { | ||
engineId: EngineId("00000000-0000-0000-0000-000000000000"), | ||
styleId: StyleId(0), | ||
}, | ||
}; | ||
}; | ||
const basePhrases = new Map<string, Phrase>([ | ||
["1", createPhrase(0, 1, "WAITING_TO_BE_RENDERED")], | ||
["2", createPhrase(1, 2, "WAITING_TO_BE_RENDERED")], | ||
["3", createPhrase(2, 3, "WAITING_TO_BE_RENDERED")], | ||
["4", createPhrase(3, 4, "WAITING_TO_BE_RENDERED")], | ||
["5", createPhrase(4, 5, "WAITING_TO_BE_RENDERED")], | ||
]); | ||
|
||
it("しっかり優先順位に従って探している", () => { | ||
const phrases = structuredClone(basePhrases); | ||
const position = 2.5 * DEFAULT_TPQN; | ||
for (const expectation of [ | ||
// 再生位置が含まれるPhrase | ||
"3", | ||
// 再生位置より後のPhrase | ||
"4", // 早い方 | ||
"5", // 遅い方 | ||
// 再生位置より前のPhrase | ||
"1", // 早い方 | ||
"2", // 遅い方 | ||
]) { | ||
const [key] = selectPriorPhrase(phrases, position); | ||
expect(key).toEqual(expectation); | ||
if (key == undefined) { | ||
// 型アサーションのためにthrowを使う | ||
throw new Error("key is undefined"); | ||
} | ||
phrases.delete(key); | ||
} | ||
|
||
// もう再生可能なPhraseがないのでthrow | ||
expect(() => { | ||
selectPriorPhrase(phrases, position); | ||
}).toThrow("Received empty phrases"); | ||
}); |