From 9bac8871a97856749ab7f609d25f84f0e89245a7 Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Tue, 5 Mar 2024 01:52:45 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=E9=9F=B3=E9=AB=98=E8=A3=9C=E6=AD=A3?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=A4=E3=81=A4=E9=96=8B=E7=99=BA=E6=99=82?= =?UTF-8?q?=E3=81=AE=E3=81=BF=E6=A9=9F=E8=83=BD=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Sing/ToolBar.vue | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/components/Sing/ToolBar.vue b/src/components/Sing/ToolBar.vue index fc3707f07a..fada590a3d 100644 --- a/src/components/Sing/ToolBar.vue +++ b/src/components/Sing/ToolBar.vue @@ -3,16 +3,19 @@
- + + import { computed, watch, ref, onMounted, onUnmounted } from "vue"; import { useStore } from "@/store"; +import { isProduction } from "@/type/preload"; + import { getSnapTypes, isTriplet, From 5720a2b5ab66064f3f8f4148101d9b286009e93b Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Tue, 5 Mar 2024 01:55:39 +0900 Subject: [PATCH 2/6] =?UTF-8?q?VoiceKey=E2=86=92GuidePitch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Sing/ToolBar.vue | 10 +++---- src/sing/domain.ts | 8 ++--- src/sing/storeHelper.ts | 2 +- src/store/project.ts | 6 ++-- src/store/singing.ts | 52 +++++++++++++++++---------------- src/store/type.ts | 16 +++++----- 6 files changed, 48 insertions(+), 46 deletions(-) diff --git a/src/components/Sing/ToolBar.vue b/src/components/Sing/ToolBar.vue index fada590a3d..f9feaaf0a9 100644 --- a/src/components/Sing/ToolBar.vue +++ b/src/components/Sing/ToolBar.vue @@ -135,7 +135,7 @@ import { isValidBeatType, isValidBeats, isValidBpm, - isValidVoiceKeyShift, + isValidGuidePitchShift, } from "@/sing/domain"; import CharacterMenuButton from "@/components/Sing/CharacterMenuButton/MenuButton.vue"; import { useHotkeyManager } from "@/plugins/hotkeyPlugin"; @@ -188,7 +188,7 @@ const redo = () => { const tempos = computed(() => store.state.tempos); const timeSignatures = computed(() => store.state.timeSignatures); -const keyShift = computed(() => store.getters.SELECTED_TRACK.voiceKeyShift); +const keyShift = computed(() => store.getters.SELECTED_TRACK.guidePitchShift); const bpmInputBuffer = ref(120); const beatsInputBuffer = ref(4); @@ -242,7 +242,7 @@ const setBeatTypeInputBuffer = (beatTypeStr: string | number | null) => { const setKeyShiftInputBuffer = (keyShiftStr: string | number | null) => { const keyShiftValue = Number(keyShiftStr); - if (!isValidVoiceKeyShift(keyShiftValue)) { + if (!isValidGuidePitchShift(keyShiftValue)) { return; } keyShiftInputBuffer.value = keyShiftValue; @@ -271,8 +271,8 @@ const setTimeSignature = () => { }; const setKeyShift = () => { - const voiceKeyShift = keyShiftInputBuffer.value; - store.dispatch("COMMAND_SET_VOICE_KEY_SHIFT", { voiceKeyShift }); + const guidePitchShift = keyShiftInputBuffer.value; + store.dispatch("COMMAND_SET_GUIDE_PITCH_SHIFT", { guidePitchShift }); }; const playheadTicks = ref(0); diff --git a/src/sing/domain.ts b/src/sing/domain.ts index 63952b58d7..ca3b9dc162 100644 --- a/src/sing/domain.ts +++ b/src/sing/domain.ts @@ -279,10 +279,10 @@ export function isValidSnapType(snapType: number, tpqn: number) { return getSnapTypes(tpqn).some((value) => value === snapType); } -export function isValidVoiceKeyShift(voiceKeyShift: number) { +export function isValidGuidePitchShift(guidePitchShift: number) { return ( - Number.isInteger(voiceKeyShift) && - voiceKeyShift <= 24 && - voiceKeyShift >= -24 + Number.isInteger(guidePitchShift) && + guidePitchShift <= 24 && + guidePitchShift >= -24 ); } diff --git a/src/sing/storeHelper.ts b/src/sing/storeHelper.ts index 1b8345ef95..1acaf3a801 100644 --- a/src/sing/storeHelper.ts +++ b/src/sing/storeHelper.ts @@ -9,7 +9,7 @@ export const DEFAULT_BEAT_TYPE = 4; export const generatePhraseHash = async (obj: { singer: Singer | undefined; notesKeyShift: number; - voiceKeyShift: number; + guidePitchShift: number; tpqn: number; tempos: Tempo[]; notes: Note[]; diff --git a/src/store/project.ts b/src/store/project.ts index 2064844eef..656180cdfb 100755 --- a/src/store/project.ts +++ b/src/store/project.ts @@ -111,8 +111,8 @@ const applySongProjectToStore = async ( await dispatch("SET_SINGER", { singer: tracks[0].singer, }); - await dispatch("SET_VOICE_KEY_SHIFT", { - voiceKeyShift: tracks[0].voiceKeyShift, + await dispatch("SET_GUIDE_PITCH_SHIFT", { + guidePitchShift: tracks[0].guidePitchShift, }); await dispatch("SET_SCORE", { score: { @@ -432,7 +432,7 @@ export const projectStore = createPartialStore({ { singer: undefined, notesKeyShift: 0, - voiceKeyShift: 0, + guidePitchShift: 0, notes: [], }, ], diff --git a/src/store/singing.ts b/src/store/singing.ts index 4ba8f477cf..1be9bb2642 100644 --- a/src/store/singing.ts +++ b/src/store/singing.ts @@ -44,7 +44,7 @@ import { isValidSnapType, isValidTempo, isValidTimeSignature, - isValidVoiceKeyShift, + isValidGuidePitchShift, secondToTick, tickToSecond, } from "@/sing/domain"; @@ -145,7 +145,7 @@ export const generateSingingStoreInitialScore = () => { { singer: undefined, notesKeyShift: 0, - voiceKeyShift: 0, + guidePitchShift: 0, notes: [], }, ], @@ -230,18 +230,18 @@ export const singingStore = createPartialStore({ }, }, - SET_VOICE_KEY_SHIFT: { - mutation(state, { voiceKeyShift }: { voiceKeyShift: number }) { - state.tracks[selectedTrackIndex].voiceKeyShift = voiceKeyShift; + SET_GUIDE_PITCH_SHIFT: { + mutation(state, { guidePitchShift }: { guidePitchShift: number }) { + state.tracks[selectedTrackIndex].guidePitchShift = guidePitchShift; }, async action( { dispatch, commit }, - { voiceKeyShift }: { voiceKeyShift: number } + { guidePitchShift }: { guidePitchShift: number } ) { - if (!isValidVoiceKeyShift(voiceKeyShift)) { - throw new Error("The voiceKeyShift is invalid."); + if (!isValidGuidePitchShift(guidePitchShift)) { + throw new Error("The guidePitchShift is invalid."); } - commit("SET_VOICE_KEY_SHIFT", { voiceKeyShift }); + commit("SET_GUIDE_PITCH_SHIFT", { guidePitchShift }); dispatch("RENDER"); }, @@ -747,7 +747,7 @@ export const singingStore = createPartialStore({ const searchPhrases = async ( singer: Singer | undefined, notesKeyShift: number, - voiceKeyShift: number, + guidePitchShift: number, tpqn: number, tempos: Tempo[], notes: Note[] @@ -768,7 +768,7 @@ export const singingStore = createPartialStore({ const hash = await generatePhraseHash({ singer, notesKeyShift, - voiceKeyShift, + guidePitchShift, tpqn, tempos, notes: phraseNotes, @@ -776,7 +776,7 @@ export const singingStore = createPartialStore({ foundPhrases.set(hash, { singer, notesKeyShift, - voiceKeyShift, + guidePitchShift, tpqn, tempos, notes: phraseNotes, @@ -877,12 +877,12 @@ export const singingStore = createPartialStore({ return frameAudioQuery.phonemes.map((value) => value.phoneme).join(" "); }; - const shiftVoiceKey = ( - voiceKeyShift: number, + const shiftGuidePitch = ( + guidePitchShift: number, frameAudioQuery: FrameAudioQuery ) => { frameAudioQuery.f0 = frameAudioQuery.f0.map((value) => { - return value * Math.pow(2, voiceKeyShift / 12); + return value * Math.pow(2, guidePitchShift / 12); }); }; @@ -943,7 +943,7 @@ export const singingStore = createPartialStore({ const track = getters.SELECTED_TRACK; const singer = track.singer ? { ...track.singer } : undefined; const notesKeyShift = track.notesKeyShift; - const voiceKeyShift = track.voiceKeyShift; + const guidePitchShift = track.guidePitchShift; const notes = track.notes .map((value) => ({ ...value })) .filter((value) => !state.overlappingNoteIds.has(value.id)); @@ -952,7 +952,7 @@ export const singingStore = createPartialStore({ const foundPhrases = await searchPhrases( singer, notesKeyShift, - voiceKeyShift, + guidePitchShift, tpqn, tempos, notes @@ -1052,7 +1052,7 @@ export const singingStore = createPartialStore({ `Fetched frame audio query. Phonemes are "${phonemes}".` ); - shiftVoiceKey(phrase.voiceKeyShift, frameAudioQuery); + shiftGuidePitch(phrase.guidePitchShift, frameAudioQuery); const startTime = calcStartTime( phrase.notes, @@ -1977,18 +1977,20 @@ export const singingCommandStore = transformCommandStore( dispatch("RENDER"); }, }, - COMMAND_SET_VOICE_KEY_SHIFT: { - mutation(draft, { voiceKeyShift }) { - singingStore.mutations.SET_VOICE_KEY_SHIFT(draft, { voiceKeyShift }); + COMMAND_SET_GUIDE_PITCH_SHIFT: { + mutation(draft, { guidePitchShift }) { + singingStore.mutations.SET_GUIDE_PITCH_SHIFT(draft, { + guidePitchShift, + }); }, async action( { dispatch, commit }, - { voiceKeyShift }: { voiceKeyShift: number } + { guidePitchShift }: { guidePitchShift: number } ) { - if (!isValidVoiceKeyShift(voiceKeyShift)) { - throw new Error("The voiceKeyShift is invalid."); + if (!isValidGuidePitchShift(guidePitchShift)) { + throw new Error("The guidePitchShift is invalid."); } - commit("COMMAND_SET_VOICE_KEY_SHIFT", { voiceKeyShift }); + commit("COMMAND_SET_GUIDE_PITCH_SHIFT", { guidePitchShift }); dispatch("RENDER"); }, diff --git a/src/store/type.ts b/src/store/type.ts index 0f2df9fb0b..f35d33ea08 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -752,7 +752,7 @@ export type Singer = z.infer; export const trackSchema = z.object({ singer: singerSchema.optional(), notesKeyShift: z.number(), - voiceKeyShift: z.number(), + guidePitchShift: z.number(), notes: z.array(noteSchema), }); export type Track = z.infer; @@ -766,7 +766,7 @@ export type PhraseState = export type Phrase = { singer?: Singer; notesKeyShift: number; - voiceKeyShift: number; + guidePitchShift: number; tpqn: number; tempos: Tempo[]; notes: Note[]; @@ -818,9 +818,9 @@ export type SingingStoreTypes = { action(payload: { singer?: Singer }): void; }; - SET_VOICE_KEY_SHIFT: { - mutation: { voiceKeyShift: number }; - action(payload: { voiceKeyShift: number }): void; + SET_GUIDE_PITCH_SHIFT: { + mutation: { guidePitchShift: number }; + action(payload: { guidePitchShift: number }): void; }; SET_SCORE: { @@ -1033,9 +1033,9 @@ export type SingingCommandStoreTypes = { action(payload: { singer: Singer }): void; }; - COMMAND_SET_VOICE_KEY_SHIFT: { - mutation: { voiceKeyShift: number }; - action(payload: { voiceKeyShift: number }): void; + COMMAND_SET_GUIDE_PITCH_SHIFT: { + mutation: { guidePitchShift: number }; + action(payload: { guidePitchShift: number }): void; }; COMMAND_SET_TEMPO: { From 7f46ce898cdf61160d0d6d591d6c54b765b34f50 Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Tue, 5 Mar 2024 02:44:20 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=E3=81=A8=E3=82=8A=E3=81=82=E3=81=88?= =?UTF-8?q?=E3=81=9A=E5=AE=9F=E8=A3=85=E3=81=A8=E3=81=97=E3=81=A6=E3=81=AF?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Sing/ToolBar.vue | 12 +++---- src/sing/domain.ts | 8 ++--- src/sing/storeHelper.ts | 2 +- src/store/project.ts | 6 ++-- src/store/singing.ts | 56 ++++++++++++++++++--------------- src/store/type.ts | 18 +++++------ 6 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/components/Sing/ToolBar.vue b/src/components/Sing/ToolBar.vue index f9feaaf0a9..aaff221d38 100644 --- a/src/components/Sing/ToolBar.vue +++ b/src/components/Sing/ToolBar.vue @@ -8,7 +8,7 @@ { const tempos = computed(() => store.state.tempos); const timeSignatures = computed(() => store.state.timeSignatures); -const keyShift = computed(() => store.getters.SELECTED_TRACK.guidePitchShift); +const keyShift = computed(() => store.getters.SELECTED_TRACK.guideKeyShift); const bpmInputBuffer = ref(120); const beatsInputBuffer = ref(4); @@ -242,7 +242,7 @@ const setBeatTypeInputBuffer = (beatTypeStr: string | number | null) => { const setKeyShiftInputBuffer = (keyShiftStr: string | number | null) => { const keyShiftValue = Number(keyShiftStr); - if (!isValidGuidePitchShift(keyShiftValue)) { + if (!isValidKeyShift(keyShiftValue)) { return; } keyShiftInputBuffer.value = keyShiftValue; @@ -271,8 +271,8 @@ const setTimeSignature = () => { }; const setKeyShift = () => { - const guidePitchShift = keyShiftInputBuffer.value; - store.dispatch("COMMAND_SET_GUIDE_PITCH_SHIFT", { guidePitchShift }); + const guideKeyShift = keyShiftInputBuffer.value; + store.dispatch("COMMAND_SET_GUIDE_KEY_SHIFT", { guideKeyShift }); }; const playheadTicks = ref(0); diff --git a/src/sing/domain.ts b/src/sing/domain.ts index ca3b9dc162..80d9dbd6d5 100644 --- a/src/sing/domain.ts +++ b/src/sing/domain.ts @@ -279,10 +279,6 @@ export function isValidSnapType(snapType: number, tpqn: number) { return getSnapTypes(tpqn).some((value) => value === snapType); } -export function isValidGuidePitchShift(guidePitchShift: number) { - return ( - Number.isInteger(guidePitchShift) && - guidePitchShift <= 24 && - guidePitchShift >= -24 - ); +export function isValidKeyShift(keyShift: number) { + return Number.isInteger(keyShift) && keyShift <= 24 && keyShift >= -24; } diff --git a/src/sing/storeHelper.ts b/src/sing/storeHelper.ts index 1acaf3a801..92d6fb1d9f 100644 --- a/src/sing/storeHelper.ts +++ b/src/sing/storeHelper.ts @@ -9,7 +9,7 @@ export const DEFAULT_BEAT_TYPE = 4; export const generatePhraseHash = async (obj: { singer: Singer | undefined; notesKeyShift: number; - guidePitchShift: number; + guideKeyShift: number; tpqn: number; tempos: Tempo[]; notes: Note[]; diff --git a/src/store/project.ts b/src/store/project.ts index 656180cdfb..e65dc8d929 100755 --- a/src/store/project.ts +++ b/src/store/project.ts @@ -111,8 +111,8 @@ const applySongProjectToStore = async ( await dispatch("SET_SINGER", { singer: tracks[0].singer, }); - await dispatch("SET_GUIDE_PITCH_SHIFT", { - guidePitchShift: tracks[0].guidePitchShift, + await dispatch("SET_GUIDE_KEY_SHIFT", { + guideKeyShift: tracks[0].guideKeyShift, }); await dispatch("SET_SCORE", { score: { @@ -432,7 +432,7 @@ export const projectStore = createPartialStore({ { singer: undefined, notesKeyShift: 0, - guidePitchShift: 0, + guideKeyShift: 0, notes: [], }, ], diff --git a/src/store/singing.ts b/src/store/singing.ts index 1be9bb2642..50e62b647b 100644 --- a/src/store/singing.ts +++ b/src/store/singing.ts @@ -44,7 +44,7 @@ import { isValidSnapType, isValidTempo, isValidTimeSignature, - isValidGuidePitchShift, + isValidKeyShift, secondToTick, tickToSecond, } from "@/sing/domain"; @@ -145,7 +145,7 @@ export const generateSingingStoreInitialScore = () => { { singer: undefined, notesKeyShift: 0, - guidePitchShift: 0, + guideKeyShift: 0, notes: [], }, ], @@ -230,18 +230,18 @@ export const singingStore = createPartialStore({ }, }, - SET_GUIDE_PITCH_SHIFT: { - mutation(state, { guidePitchShift }: { guidePitchShift: number }) { - state.tracks[selectedTrackIndex].guidePitchShift = guidePitchShift; + SET_GUIDE_KEY_SHIFT: { + mutation(state, { guideKeyShift }: { guideKeyShift: number }) { + state.tracks[selectedTrackIndex].guideKeyShift = guideKeyShift; }, async action( { dispatch, commit }, - { guidePitchShift }: { guidePitchShift: number } + { guideKeyShift }: { guideKeyShift: number } ) { - if (!isValidGuidePitchShift(guidePitchShift)) { - throw new Error("The guidePitchShift is invalid."); + if (!isValidKeyShift(guideKeyShift)) { + throw new Error("The guideKeyShift is invalid."); } - commit("SET_GUIDE_PITCH_SHIFT", { guidePitchShift }); + commit("SET_GUIDE_KEY_SHIFT", { guideKeyShift }); dispatch("RENDER"); }, @@ -747,7 +747,7 @@ export const singingStore = createPartialStore({ const searchPhrases = async ( singer: Singer | undefined, notesKeyShift: number, - guidePitchShift: number, + guideKeyShift: number, tpqn: number, tempos: Tempo[], notes: Note[] @@ -768,7 +768,7 @@ export const singingStore = createPartialStore({ const hash = await generatePhraseHash({ singer, notesKeyShift, - guidePitchShift, + guideKeyShift, tpqn, tempos, notes: phraseNotes, @@ -776,7 +776,7 @@ export const singingStore = createPartialStore({ foundPhrases.set(hash, { singer, notesKeyShift, - guidePitchShift, + guideKeyShift, tpqn, tempos, notes: phraseNotes, @@ -803,6 +803,7 @@ export const singingStore = createPartialStore({ tempos: Tempo[], tpqn: number, notesKeyShift: number, + guideKeyShift: number, frameRate: number, restDurationSeconds: number ) => { @@ -834,8 +835,10 @@ export const singingStore = createPartialStore({ .replace("うぉ", "ウォ") .replace("は", "ハ") .replace("へ", "ヘ"); + // トランスポーズする + const key = note.noteNumber + notesKeyShift - guideKeyShift; notesForRequestToEngine.push({ - key: note.noteNumber + notesKeyShift, + key, frameLength: noteFrameLength, lyric, }); @@ -878,11 +881,11 @@ export const singingStore = createPartialStore({ }; const shiftGuidePitch = ( - guidePitchShift: number, + guideKeyShift: number, frameAudioQuery: FrameAudioQuery ) => { frameAudioQuery.f0 = frameAudioQuery.f0.map((value) => { - return value * Math.pow(2, guidePitchShift / 12); + return value * Math.pow(2, guideKeyShift / 12); }); }; @@ -943,7 +946,7 @@ export const singingStore = createPartialStore({ const track = getters.SELECTED_TRACK; const singer = track.singer ? { ...track.singer } : undefined; const notesKeyShift = track.notesKeyShift; - const guidePitchShift = track.guidePitchShift; + const guideKeyShift = track.guideKeyShift; const notes = track.notes .map((value) => ({ ...value })) .filter((value) => !state.overlappingNoteIds.has(value.id)); @@ -952,7 +955,7 @@ export const singingStore = createPartialStore({ const foundPhrases = await searchPhrases( singer, notesKeyShift, - guidePitchShift, + guideKeyShift, tpqn, tempos, notes @@ -1037,6 +1040,7 @@ export const singingStore = createPartialStore({ phrase.tempos, phrase.tpqn, phrase.notesKeyShift, + phrase.guideKeyShift, frameRate, restDurationSeconds ).catch((error) => { @@ -1052,7 +1056,7 @@ export const singingStore = createPartialStore({ `Fetched frame audio query. Phonemes are "${phonemes}".` ); - shiftGuidePitch(phrase.guidePitchShift, frameAudioQuery); + shiftGuidePitch(phrase.guideKeyShift, frameAudioQuery); const startTime = calcStartTime( phrase.notes, @@ -1977,20 +1981,20 @@ export const singingCommandStore = transformCommandStore( dispatch("RENDER"); }, }, - COMMAND_SET_GUIDE_PITCH_SHIFT: { - mutation(draft, { guidePitchShift }) { - singingStore.mutations.SET_GUIDE_PITCH_SHIFT(draft, { - guidePitchShift, + COMMAND_SET_GUIDE_KEY_SHIFT: { + mutation(draft, { guideKeyShift }) { + singingStore.mutations.SET_GUIDE_KEY_SHIFT(draft, { + guideKeyShift, }); }, async action( { dispatch, commit }, - { guidePitchShift }: { guidePitchShift: number } + { guideKeyShift }: { guideKeyShift: number } ) { - if (!isValidGuidePitchShift(guidePitchShift)) { - throw new Error("The guidePitchShift is invalid."); + if (!isValidKeyShift(guideKeyShift)) { + throw new Error("The guideKeyShift is invalid."); } - commit("COMMAND_SET_GUIDE_PITCH_SHIFT", { guidePitchShift }); + commit("COMMAND_SET_GUIDE_KEY_SHIFT", { guideKeyShift }); dispatch("RENDER"); }, diff --git a/src/store/type.ts b/src/store/type.ts index f35d33ea08..4822b88261 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -751,8 +751,8 @@ export type Singer = z.infer; export const trackSchema = z.object({ singer: singerSchema.optional(), - notesKeyShift: z.number(), - guidePitchShift: z.number(), + notesKeyShift: z.number(), // ノートのトランスポーズ量 + guideKeyShift: z.number(), // 歌い方のトランスポーズ量 notes: z.array(noteSchema), }); export type Track = z.infer; @@ -766,7 +766,7 @@ export type PhraseState = export type Phrase = { singer?: Singer; notesKeyShift: number; - guidePitchShift: number; + guideKeyShift: number; tpqn: number; tempos: Tempo[]; notes: Note[]; @@ -818,9 +818,9 @@ export type SingingStoreTypes = { action(payload: { singer?: Singer }): void; }; - SET_GUIDE_PITCH_SHIFT: { - mutation: { guidePitchShift: number }; - action(payload: { guidePitchShift: number }): void; + SET_GUIDE_KEY_SHIFT: { + mutation: { guideKeyShift: number }; + action(payload: { guideKeyShift: number }): void; }; SET_SCORE: { @@ -1033,9 +1033,9 @@ export type SingingCommandStoreTypes = { action(payload: { singer: Singer }): void; }; - COMMAND_SET_GUIDE_PITCH_SHIFT: { - mutation: { guidePitchShift: number }; - action(payload: { guidePitchShift: number }): void; + COMMAND_SET_GUIDE_KEY_SHIFT: { + mutation: { guideKeyShift: number }; + action(payload: { guideKeyShift: number }): void; }; COMMAND_SET_TEMPO: { From 6bdee78994ff22b4dbce8c854efeb123c4ca79fc Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Tue, 5 Mar 2024 03:02:36 +0900 Subject: [PATCH 4/6] =?UTF-8?q?keyRangeAdjustment=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Sing/ToolBar.vue | 8 +++-- src/sing/storeHelper.ts | 2 +- src/store/project.ts | 5 ++-- src/store/singing.ts | 53 +++++++++++++++++---------------- src/store/type.ts | 15 +++++----- 5 files changed, 44 insertions(+), 39 deletions(-) diff --git a/src/components/Sing/ToolBar.vue b/src/components/Sing/ToolBar.vue index aaff221d38..9940e9e95c 100644 --- a/src/components/Sing/ToolBar.vue +++ b/src/components/Sing/ToolBar.vue @@ -188,7 +188,9 @@ const redo = () => { const tempos = computed(() => store.state.tempos); const timeSignatures = computed(() => store.state.timeSignatures); -const keyShift = computed(() => store.getters.SELECTED_TRACK.guideKeyShift); +const keyShift = computed( + () => store.getters.SELECTED_TRACK.keyRangeAdjustment +); const bpmInputBuffer = ref(120); const beatsInputBuffer = ref(4); @@ -271,8 +273,8 @@ const setTimeSignature = () => { }; const setKeyShift = () => { - const guideKeyShift = keyShiftInputBuffer.value; - store.dispatch("COMMAND_SET_GUIDE_KEY_SHIFT", { guideKeyShift }); + const keyRangeAdjustment = keyShiftInputBuffer.value; + store.dispatch("COMMAND_SET_KEY_RANGE_ADJUSTMENT", { keyRangeAdjustment }); }; const playheadTicks = ref(0); diff --git a/src/sing/storeHelper.ts b/src/sing/storeHelper.ts index 92d6fb1d9f..4497103014 100644 --- a/src/sing/storeHelper.ts +++ b/src/sing/storeHelper.ts @@ -9,7 +9,7 @@ export const DEFAULT_BEAT_TYPE = 4; export const generatePhraseHash = async (obj: { singer: Singer | undefined; notesKeyShift: number; - guideKeyShift: number; + keyRangeAdjustment: number; tpqn: number; tempos: Tempo[]; notes: Note[]; diff --git a/src/store/project.ts b/src/store/project.ts index e65dc8d929..8565305e4e 100755 --- a/src/store/project.ts +++ b/src/store/project.ts @@ -111,8 +111,8 @@ const applySongProjectToStore = async ( await dispatch("SET_SINGER", { singer: tracks[0].singer, }); - await dispatch("SET_GUIDE_KEY_SHIFT", { - guideKeyShift: tracks[0].guideKeyShift, + await dispatch("SET_KEY_RANGE_ADJUSTMENT", { + keyRangeAdjustment: tracks[0].keyRangeAdjustment, }); await dispatch("SET_SCORE", { score: { @@ -433,6 +433,7 @@ export const projectStore = createPartialStore({ singer: undefined, notesKeyShift: 0, guideKeyShift: 0, + keyRangeAdjustment: 0, notes: [], }, ], diff --git a/src/store/singing.ts b/src/store/singing.ts index 50e62b647b..c432b70e99 100644 --- a/src/store/singing.ts +++ b/src/store/singing.ts @@ -146,6 +146,7 @@ export const generateSingingStoreInitialScore = () => { singer: undefined, notesKeyShift: 0, guideKeyShift: 0, + keyRangeAdjustment: 0, notes: [], }, ], @@ -230,18 +231,18 @@ export const singingStore = createPartialStore({ }, }, - SET_GUIDE_KEY_SHIFT: { - mutation(state, { guideKeyShift }: { guideKeyShift: number }) { - state.tracks[selectedTrackIndex].guideKeyShift = guideKeyShift; + SET_KEY_RANGE_ADJUSTMENT: { + mutation(state, { keyRangeAdjustment }: { keyRangeAdjustment: number }) { + state.tracks[selectedTrackIndex].keyRangeAdjustment = keyRangeAdjustment; }, async action( { dispatch, commit }, - { guideKeyShift }: { guideKeyShift: number } + { keyRangeAdjustment }: { keyRangeAdjustment: number } ) { - if (!isValidKeyShift(guideKeyShift)) { - throw new Error("The guideKeyShift is invalid."); + if (!isValidKeyShift(keyRangeAdjustment)) { + throw new Error("The keyRangeAdjustment is invalid."); } - commit("SET_GUIDE_KEY_SHIFT", { guideKeyShift }); + commit("SET_KEY_RANGE_ADJUSTMENT", { keyRangeAdjustment }); dispatch("RENDER"); }, @@ -747,7 +748,7 @@ export const singingStore = createPartialStore({ const searchPhrases = async ( singer: Singer | undefined, notesKeyShift: number, - guideKeyShift: number, + keyRangeAdjustment: number, tpqn: number, tempos: Tempo[], notes: Note[] @@ -768,7 +769,7 @@ export const singingStore = createPartialStore({ const hash = await generatePhraseHash({ singer, notesKeyShift, - guideKeyShift, + keyRangeAdjustment, tpqn, tempos, notes: phraseNotes, @@ -776,7 +777,7 @@ export const singingStore = createPartialStore({ foundPhrases.set(hash, { singer, notesKeyShift, - guideKeyShift, + keyRangeAdjustment, tpqn, tempos, notes: phraseNotes, @@ -803,7 +804,7 @@ export const singingStore = createPartialStore({ tempos: Tempo[], tpqn: number, notesKeyShift: number, - guideKeyShift: number, + keyRangeAdjustment: number, frameRate: number, restDurationSeconds: number ) => { @@ -836,7 +837,7 @@ export const singingStore = createPartialStore({ .replace("は", "ハ") .replace("へ", "ヘ"); // トランスポーズする - const key = note.noteNumber + notesKeyShift - guideKeyShift; + const key = note.noteNumber + notesKeyShift - keyRangeAdjustment; notesForRequestToEngine.push({ key, frameLength: noteFrameLength, @@ -881,11 +882,11 @@ export const singingStore = createPartialStore({ }; const shiftGuidePitch = ( - guideKeyShift: number, + keyShift: number, frameAudioQuery: FrameAudioQuery ) => { frameAudioQuery.f0 = frameAudioQuery.f0.map((value) => { - return value * Math.pow(2, guideKeyShift / 12); + return value * Math.pow(2, keyShift / 12); }); }; @@ -946,7 +947,7 @@ export const singingStore = createPartialStore({ const track = getters.SELECTED_TRACK; const singer = track.singer ? { ...track.singer } : undefined; const notesKeyShift = track.notesKeyShift; - const guideKeyShift = track.guideKeyShift; + const keyRangeAdjustment = track.keyRangeAdjustment; const notes = track.notes .map((value) => ({ ...value })) .filter((value) => !state.overlappingNoteIds.has(value.id)); @@ -955,7 +956,7 @@ export const singingStore = createPartialStore({ const foundPhrases = await searchPhrases( singer, notesKeyShift, - guideKeyShift, + keyRangeAdjustment, tpqn, tempos, notes @@ -1040,7 +1041,7 @@ export const singingStore = createPartialStore({ phrase.tempos, phrase.tpqn, phrase.notesKeyShift, - phrase.guideKeyShift, + phrase.keyRangeAdjustment, frameRate, restDurationSeconds ).catch((error) => { @@ -1056,7 +1057,7 @@ export const singingStore = createPartialStore({ `Fetched frame audio query. Phonemes are "${phonemes}".` ); - shiftGuidePitch(phrase.guideKeyShift, frameAudioQuery); + shiftGuidePitch(phrase.keyRangeAdjustment, frameAudioQuery); const startTime = calcStartTime( phrase.notes, @@ -1981,20 +1982,20 @@ export const singingCommandStore = transformCommandStore( dispatch("RENDER"); }, }, - COMMAND_SET_GUIDE_KEY_SHIFT: { - mutation(draft, { guideKeyShift }) { - singingStore.mutations.SET_GUIDE_KEY_SHIFT(draft, { - guideKeyShift, + COMMAND_SET_KEY_RANGE_ADJUSTMENT: { + mutation(draft, { keyRangeAdjustment }) { + singingStore.mutations.SET_KEY_RANGE_ADJUSTMENT(draft, { + keyRangeAdjustment, }); }, async action( { dispatch, commit }, - { guideKeyShift }: { guideKeyShift: number } + { keyRangeAdjustment }: { keyRangeAdjustment: number } ) { - if (!isValidKeyShift(guideKeyShift)) { - throw new Error("The guideKeyShift is invalid."); + if (!isValidKeyShift(keyRangeAdjustment)) { + throw new Error("The keyRangeAdjustment is invalid."); } - commit("COMMAND_SET_GUIDE_KEY_SHIFT", { guideKeyShift }); + commit("COMMAND_SET_KEY_RANGE_ADJUSTMENT", { keyRangeAdjustment }); dispatch("RENDER"); }, diff --git a/src/store/type.ts b/src/store/type.ts index 4822b88261..e94835599c 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -753,6 +753,7 @@ export const trackSchema = z.object({ singer: singerSchema.optional(), notesKeyShift: z.number(), // ノートのトランスポーズ量 guideKeyShift: z.number(), // 歌い方のトランスポーズ量 + keyRangeAdjustment: z.number(), // 音域補正量 notes: z.array(noteSchema), }); export type Track = z.infer; @@ -766,7 +767,7 @@ export type PhraseState = export type Phrase = { singer?: Singer; notesKeyShift: number; - guideKeyShift: number; + keyRangeAdjustment: number; tpqn: number; tempos: Tempo[]; notes: Note[]; @@ -818,9 +819,9 @@ export type SingingStoreTypes = { action(payload: { singer?: Singer }): void; }; - SET_GUIDE_KEY_SHIFT: { - mutation: { guideKeyShift: number }; - action(payload: { guideKeyShift: number }): void; + SET_KEY_RANGE_ADJUSTMENT: { + mutation: { keyRangeAdjustment: number }; + action(payload: { keyRangeAdjustment: number }): void; }; SET_SCORE: { @@ -1033,9 +1034,9 @@ export type SingingCommandStoreTypes = { action(payload: { singer: Singer }): void; }; - COMMAND_SET_GUIDE_KEY_SHIFT: { - mutation: { guideKeyShift: number }; - action(payload: { guideKeyShift: number }): void; + COMMAND_SET_KEY_RANGE_ADJUSTMENT: { + mutation: { keyRangeAdjustment: number }; + action(payload: { keyRangeAdjustment: number }): void; }; COMMAND_SET_TEMPO: { From 703b0e50ffcca464a902e3780f54081fbe1ad1dc Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Wed, 6 Mar 2024 00:43:32 +0900 Subject: [PATCH 5/6] =?UTF-8?q?(note|guide)KeyShift=E3=82=92=E6=B6=88?= =?UTF-8?q?=E3=81=97=E3=80=81=E8=A3=9C=E6=AD=A3=E2=86=92=E8=AA=BF=E6=95=B4?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Sing/ToolBar.vue | 2 +- src/sing/storeHelper.ts | 1 - src/store/project.ts | 2 -- src/store/singing.ts | 11 +---------- src/store/type.ts | 5 +---- 5 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/components/Sing/ToolBar.vue b/src/components/Sing/ToolBar.vue index 9940e9e95c..ce4de58073 100644 --- a/src/components/Sing/ToolBar.vue +++ b/src/components/Sing/ToolBar.vue @@ -8,7 +8,7 @@ ({ tracks: [ { singer: undefined, - notesKeyShift: 0, - guideKeyShift: 0, keyRangeAdjustment: 0, notes: [], }, diff --git a/src/store/singing.ts b/src/store/singing.ts index c432b70e99..c12813cc96 100644 --- a/src/store/singing.ts +++ b/src/store/singing.ts @@ -144,8 +144,6 @@ export const generateSingingStoreInitialScore = () => { tracks: [ { singer: undefined, - notesKeyShift: 0, - guideKeyShift: 0, keyRangeAdjustment: 0, notes: [], }, @@ -747,7 +745,6 @@ export const singingStore = createPartialStore({ async action({ state, getters, commit, dispatch }) { const searchPhrases = async ( singer: Singer | undefined, - notesKeyShift: number, keyRangeAdjustment: number, tpqn: number, tempos: Tempo[], @@ -768,7 +765,6 @@ export const singingStore = createPartialStore({ const phraseLastNote = phraseNotes[phraseNotes.length - 1]; const hash = await generatePhraseHash({ singer, - notesKeyShift, keyRangeAdjustment, tpqn, tempos, @@ -776,7 +772,6 @@ export const singingStore = createPartialStore({ }); foundPhrases.set(hash, { singer, - notesKeyShift, keyRangeAdjustment, tpqn, tempos, @@ -803,7 +798,6 @@ export const singingStore = createPartialStore({ notes: Note[], tempos: Tempo[], tpqn: number, - notesKeyShift: number, keyRangeAdjustment: number, frameRate: number, restDurationSeconds: number @@ -837,7 +831,7 @@ export const singingStore = createPartialStore({ .replace("は", "ハ") .replace("へ", "ヘ"); // トランスポーズする - const key = note.noteNumber + notesKeyShift - keyRangeAdjustment; + const key = note.noteNumber - keyRangeAdjustment; notesForRequestToEngine.push({ key, frameLength: noteFrameLength, @@ -946,7 +940,6 @@ export const singingStore = createPartialStore({ const tempos = state.tempos.map((value) => ({ ...value })); const track = getters.SELECTED_TRACK; const singer = track.singer ? { ...track.singer } : undefined; - const notesKeyShift = track.notesKeyShift; const keyRangeAdjustment = track.keyRangeAdjustment; const notes = track.notes .map((value) => ({ ...value })) @@ -955,7 +948,6 @@ export const singingStore = createPartialStore({ // フレーズを更新する const foundPhrases = await searchPhrases( singer, - notesKeyShift, keyRangeAdjustment, tpqn, tempos, @@ -1040,7 +1032,6 @@ export const singingStore = createPartialStore({ phrase.notes, phrase.tempos, phrase.tpqn, - phrase.notesKeyShift, phrase.keyRangeAdjustment, frameRate, restDurationSeconds diff --git a/src/store/type.ts b/src/store/type.ts index e94835599c..efeb26839a 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -751,9 +751,7 @@ export type Singer = z.infer; export const trackSchema = z.object({ singer: singerSchema.optional(), - notesKeyShift: z.number(), // ノートのトランスポーズ量 - guideKeyShift: z.number(), // 歌い方のトランスポーズ量 - keyRangeAdjustment: z.number(), // 音域補正量 + keyRangeAdjustment: z.number(), // 音域調整量 notes: z.array(noteSchema), }); export type Track = z.infer; @@ -766,7 +764,6 @@ export type PhraseState = export type Phrase = { singer?: Singer; - notesKeyShift: number; keyRangeAdjustment: number; tpqn: number; tempos: Tempo[]; From 7ad267a58066332716742c0011f751f1b091e257 Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Wed, 6 Mar 2024 23:39:00 +0900 Subject: [PATCH 6/6] =?UTF-8?q?keyShift=E3=82=92=E5=85=A8=E3=81=A6KeyRange?= =?UTF-8?q?Adjustment=E3=81=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Sing/ToolBar.vue | 30 ++++++++++++++++-------------- src/sing/domain.ts | 8 ++++++-- src/store/singing.ts | 10 +++++----- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/components/Sing/ToolBar.vue b/src/components/Sing/ToolBar.vue index ce4de58073..d5cf21512a 100644 --- a/src/components/Sing/ToolBar.vue +++ b/src/components/Sing/ToolBar.vue @@ -7,13 +7,13 @@ { const tempos = computed(() => store.state.tempos); const timeSignatures = computed(() => store.state.timeSignatures); -const keyShift = computed( +const keyRangeAdjustment = computed( () => store.getters.SELECTED_TRACK.keyRangeAdjustment ); const bpmInputBuffer = ref(120); const beatsInputBuffer = ref(4); const beatTypeInputBuffer = ref(4); -const keyShiftInputBuffer = ref(0); +const keyRangeAdjustmentInputBuffer = ref(0); watch( tempos, @@ -214,8 +214,8 @@ watch( { deep: true } ); -watch(keyShift, () => { - keyShiftInputBuffer.value = keyShift.value; +watch(keyRangeAdjustment, () => { + keyRangeAdjustmentInputBuffer.value = keyRangeAdjustment.value; }); const setBpmInputBuffer = (bpmStr: string | number | null) => { @@ -242,12 +242,14 @@ const setBeatTypeInputBuffer = (beatTypeStr: string | number | null) => { beatTypeInputBuffer.value = beatTypeValue; }; -const setKeyShiftInputBuffer = (keyShiftStr: string | number | null) => { - const keyShiftValue = Number(keyShiftStr); - if (!isValidKeyShift(keyShiftValue)) { +const setKeyRangeAdjustmentInputBuffer = ( + KeyRangeAdjustmentStr: string | number | null +) => { + const KeyRangeAdjustmentValue = Number(KeyRangeAdjustmentStr); + if (!isValidKeyRangeAdjustment(KeyRangeAdjustmentValue)) { return; } - keyShiftInputBuffer.value = keyShiftValue; + keyRangeAdjustmentInputBuffer.value = KeyRangeAdjustmentValue; }; const setTempo = () => { @@ -272,8 +274,8 @@ const setTimeSignature = () => { }); }; -const setKeyShift = () => { - const keyRangeAdjustment = keyShiftInputBuffer.value; +const setKeyRangeAdjustment = () => { + const keyRangeAdjustment = keyRangeAdjustmentInputBuffer.value; store.dispatch("COMMAND_SET_KEY_RANGE_ADJUSTMENT", { keyRangeAdjustment }); }; diff --git a/src/sing/domain.ts b/src/sing/domain.ts index 80d9dbd6d5..2f65927870 100644 --- a/src/sing/domain.ts +++ b/src/sing/domain.ts @@ -279,6 +279,10 @@ export function isValidSnapType(snapType: number, tpqn: number) { return getSnapTypes(tpqn).some((value) => value === snapType); } -export function isValidKeyShift(keyShift: number) { - return Number.isInteger(keyShift) && keyShift <= 24 && keyShift >= -24; +export function isValidKeyRangeAdjustment(keyRangeAdjustment: number) { + return ( + Number.isInteger(keyRangeAdjustment) && + keyRangeAdjustment <= 24 && + keyRangeAdjustment >= -24 + ); } diff --git a/src/store/singing.ts b/src/store/singing.ts index c12813cc96..f6fbcd2b6b 100644 --- a/src/store/singing.ts +++ b/src/store/singing.ts @@ -44,7 +44,7 @@ import { isValidSnapType, isValidTempo, isValidTimeSignature, - isValidKeyShift, + isValidKeyRangeAdjustment, secondToTick, tickToSecond, } from "@/sing/domain"; @@ -237,7 +237,7 @@ export const singingStore = createPartialStore({ { dispatch, commit }, { keyRangeAdjustment }: { keyRangeAdjustment: number } ) { - if (!isValidKeyShift(keyRangeAdjustment)) { + if (!isValidKeyRangeAdjustment(keyRangeAdjustment)) { throw new Error("The keyRangeAdjustment is invalid."); } commit("SET_KEY_RANGE_ADJUSTMENT", { keyRangeAdjustment }); @@ -876,11 +876,11 @@ export const singingStore = createPartialStore({ }; const shiftGuidePitch = ( - keyShift: number, + pitchShift: number, frameAudioQuery: FrameAudioQuery ) => { frameAudioQuery.f0 = frameAudioQuery.f0.map((value) => { - return value * Math.pow(2, keyShift / 12); + return value * Math.pow(2, pitchShift / 12); }); }; @@ -1983,7 +1983,7 @@ export const singingCommandStore = transformCommandStore( { dispatch, commit }, { keyRangeAdjustment }: { keyRangeAdjustment: number } ) { - if (!isValidKeyShift(keyRangeAdjustment)) { + if (!isValidKeyRangeAdjustment(keyRangeAdjustment)) { throw new Error("The keyRangeAdjustment is invalid."); } commit("COMMAND_SET_KEY_RANGE_ADJUSTMENT", { keyRangeAdjustment });