diff --git a/public/howtouse.md b/public/howtouse.md index 749e2ffc74..aa4e894f55 100644 --- a/public/howtouse.md +++ b/public/howtouse.md @@ -206,6 +206,7 @@ Apple Silicon搭載のMacとRosettaの詳しい情報はこちらのリソース - スライダーの値を変更します - Ctrl キーを押しながらマウスホイールを使うと更に細かく調整できます - スライダー →スライダー、緑色の棒。 + - Alt キーを押しながらイントネーションや長さを調整することで、同じアクセント区間内を同時に調整できます diff --git a/src/components/AudioDetail.vue b/src/components/AudioDetail.vue index 9c93e00886..69e9b1f95a 100644 --- a/src/components/AudioDetail.vue +++ b/src/components/AudioDetail.vue @@ -59,8 +59,8 @@ :accentPhraseIndex="accentPhraseIndex" :value="mora.pitch" :uiLocked="uiLocked" - :min="3" - :max="6.5" + :min="minPitch" + :max="maxPitch" :disable="mora.pitch == 0.0" :type="'pitch'" :clip="false" @@ -84,8 +84,8 @@ :accentPhraseIndex="accentPhraseIndex" :value="mora.consonantLength" :uiLocked="uiLocked" - :min="0" - :max="0.3" + :min="minMoraLength" + :max="maxMoraLength" :step="0.001" :type="'consonant'" :clip="true" @@ -99,8 +99,8 @@ :accentPhraseIndex="accentPhraseIndex" :value="mora.vowelLength" :uiLocked="uiLocked" - :min="0" - :max="0.3" + :min="minMoraLength" + :max="maxMoraLength" :step="0.001" :type="'vowel'" :clip="mora.consonant ? true : false" @@ -323,22 +323,39 @@ export default defineComponent({ }); }; + const maxPitch = 6.5; + const minPitch = 3; + const maxMoraLength = 0.3; + const minMoraLength = 0; const changeMoraData = ( accentPhraseIndex: number, moraIndex: number, data: number, type: MoraDataType ) => { - if (type == "pitch") { - lastPitches.value[accentPhraseIndex][moraIndex] = data; + if (!altKeyFlag.value) { + if (type == "pitch") { + lastPitches.value[accentPhraseIndex][moraIndex] = data; + } + store.dispatch("COMMAND_SET_AUDIO_MORA_DATA", { + audioKey: props.activeAudioKey, + accentPhraseIndex, + moraIndex, + data, + type, + }); + } else { + if (accentPhrases.value === undefined) { + throw Error("accentPhrases.value === undefined"); + } + store.dispatch("COMMAND_SET_AUDIO_MORA_DATA_ACCENT_PHRASE", { + audioKey: props.activeAudioKey, + accentPhraseIndex, + moraIndex, + data, + type, + }); } - store.dispatch("COMMAND_SET_AUDIO_MORA_DATA", { - audioKey: props.activeAudioKey, - accentPhraseIndex, - moraIndex, - data, - type, - }); }; // audio play @@ -524,15 +541,13 @@ export default defineComponent({ }; const shiftKeyFlag = ref(false); + const altKeyFlag = ref(false); - const setShiftKeyFlag = (event: KeyboardEvent) => { + const keyEventListter = (event: KeyboardEvent) => { shiftKeyFlag.value = event.shiftKey; + altKeyFlag.value = event.altKey; }; - function resetShiftKeyFlag(event: KeyboardEvent) { - if (event.key === "Shift") shiftKeyFlag.value = false; - } - const handleChangeVoicing = ( mora: Mora, accentPhraseIndex: number, @@ -558,16 +573,20 @@ export default defineComponent({ }; onMounted(() => { - window.addEventListener("keyup", resetShiftKeyFlag); - document.addEventListener("keydown", setShiftKeyFlag); + window.addEventListener("keyup", keyEventListter); + document.addEventListener("keydown", keyEventListter); }); onUnmounted(() => { - window.removeEventListener("keyup", resetShiftKeyFlag); - document.removeEventListener("keydown", setShiftKeyFlag); + window.removeEventListener("keyup", keyEventListter); + document.removeEventListener("keydown", keyEventListter); }); return { + maxPitch, + minPitch, + maxMoraLength, + minMoraLength, selectDetail, selectedDetail, uiLocked, diff --git a/src/store/audio.ts b/src/store/audio.ts index 12ae663af8..79b19e71f3 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -1661,6 +1661,18 @@ export const audioCommandStore: VoiceVoxStoreOptions< ) { commit("COMMAND_SET_AUDIO_MORA_DATA", payload); }, + COMMAND_SET_AUDIO_MORA_DATA_ACCENT_PHRASE( + { commit }, + payload: { + audioKey: string; + accentPhraseIndex: number; + moraIndex: number; + data: number; + type: MoraDataType; + } + ) { + commit("COMMAND_SET_AUDIO_MORA_DATA_ACCENT_PHRASE", payload); + }, COMMAND_SET_AUDIO_SPEED_SCALE( { commit }, payload: { audioKey: string; speedScale: number } @@ -1953,6 +1965,88 @@ export const audioCommandStore: VoiceVoxStoreOptions< ) { audioStore.mutations.SET_AUDIO_MORA_DATA(draft, payload); }, + COMMAND_SET_AUDIO_MORA_DATA_ACCENT_PHRASE( + draft, + payload: { + audioKey: string; + accentPhraseIndex: number; + moraIndex: number; + data: number; + type: MoraDataType; + } + ) { + const maxPitch = 6.5; + const minPitch = 3; + const maxMoraLength = 0.3; + const minMoraLength = 0; + const { audioKey, accentPhraseIndex, moraIndex, data, type } = payload; + const audioItem = draft.audioItems[audioKey]; + if (audioItem.query === undefined) { + throw Error("draft.audioItems[audioKey].query === undefined"); + } + const accentPhrase = audioItem.query.accentPhrases[accentPhraseIndex]; + const targetMora = accentPhrase.moras[moraIndex]; + + let diffData = data; + switch (type) { + case "pitch": + diffData -= targetMora.pitch; + break; + case "consonant": + if (targetMora.consonantLength !== undefined) { + diffData -= targetMora.consonantLength; + } + break; + case "vowel": + diffData -= targetMora.vowelLength; + break; + } + + accentPhrase.moras.forEach((mora, moraIndex) => { + switch (type) { + case "pitch": + if (mora.pitch > 0) { + const newData = Math.max( + minPitch, + Math.min(maxPitch, mora.pitch + diffData) + ); + audioStore.mutations.SET_AUDIO_MORA_DATA(draft, { + audioKey, + accentPhraseIndex, + moraIndex, + data: newData, + type, + }); + } + break; + case "consonant": + case "vowel": + if (mora.consonantLength !== undefined) { + audioStore.mutations.SET_AUDIO_MORA_DATA(draft, { + audioKey, + accentPhraseIndex, + moraIndex, + data: Math.max( + minMoraLength, + Math.min(maxMoraLength, mora.consonantLength + diffData) + ), + type: "consonant", + }); + } + audioStore.mutations.SET_AUDIO_MORA_DATA(draft, { + audioKey, + accentPhraseIndex, + moraIndex, + data: Math.max( + minMoraLength, + Math.min(maxMoraLength, mora.vowelLength + diffData) + ), + type: "vowel", + }); + break; + } + }); + }, COMMAND_SET_AUDIO_SPEED_SCALE( draft, payload: { audioKey: string; speedScale: number } diff --git a/src/store/type.ts b/src/store/type.ts index c00af87e90..df8f22b20f 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -442,6 +442,23 @@ type AudioCommandStoreTypes = { }): void; }; + COMMAND_SET_AUDIO_MORA_DATA_ACCENT_PHRASE: { + mutation: { + audioKey: string; + accentPhraseIndex: number; + moraIndex: number; + data: number; + type: MoraDataType; + }; + action(payload: { + audioKey: string; + accentPhraseIndex: number; + moraIndex: number; + data: number; + type: MoraDataType; + }): void; + }; + COMMAND_SET_AUDIO_SPEED_SCALE: { mutation: { audioKey: string; speedScale: number }; action(payload: { audioKey: string; speedScale: number }): void;