Skip to content

Commit

Permalink
Merge branch 'main' into redesign-preset-manage-dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba authored Dec 21, 2024
2 parents cf94498 + f1e3966 commit 01822f2
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 57 deletions.
85 changes: 42 additions & 43 deletions src/components/Talk/AudioInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ import {
MorphingInfo,
Preset,
PresetKey,
PresetSliderKey,
Voice,
} from "@/type/preload";
import {
Expand Down Expand Up @@ -348,14 +349,12 @@ const selectedAudioKeys = computed(() =>
: [props.activeAudioKey],
);
type ParameterKey = keyof Omit<Preset, "name" | "morphingInfo">; // NOTE: パラメーターの種類はPresetのキーと同じ
/** パラメーターを制御するための元情報リスト */
type ParameterConfig = {
label: string;
sliderProps: Omit<PreviewSliderHelperProps, "onChange">;
onChange: PreviewSliderHelperProps["onChange"]; // NOTE: onChangeだけ使い回すので分離している
key: ParameterKey;
key: PresetSliderKey;
};
const parameterConfigs = computed<ParameterConfig[]>(() => [
{
Expand All @@ -364,11 +363,11 @@ const parameterConfigs = computed<ParameterConfig[]>(() => [
modelValue: () => query.value?.speedScale ?? null,
disable: () =>
uiLocked.value || !supportedFeatures.value?.adjustSpeedScale,
max: SLIDER_PARAMETERS.SPEED.max,
min: SLIDER_PARAMETERS.SPEED.min,
step: SLIDER_PARAMETERS.SPEED.step,
scrollStep: SLIDER_PARAMETERS.SPEED.scrollStep,
scrollMinStep: SLIDER_PARAMETERS.SPEED.scrollMinStep,
max: SLIDER_PARAMETERS.speedScale.max,
min: SLIDER_PARAMETERS.speedScale.min,
step: SLIDER_PARAMETERS.speedScale.step,
scrollStep: SLIDER_PARAMETERS.speedScale.scrollStep,
scrollMinStep: SLIDER_PARAMETERS.speedScale.scrollMinStep,
},
onChange: (speedScale: number) =>
store.actions.COMMAND_MULTI_SET_AUDIO_SPEED_SCALE({
Expand All @@ -383,10 +382,10 @@ const parameterConfigs = computed<ParameterConfig[]>(() => [
modelValue: () => query.value?.pitchScale ?? null,
disable: () =>
uiLocked.value || !supportedFeatures.value?.adjustPitchScale,
max: SLIDER_PARAMETERS.PITCH.max,
min: SLIDER_PARAMETERS.PITCH.min,
step: SLIDER_PARAMETERS.PITCH.step,
scrollStep: SLIDER_PARAMETERS.PITCH.scrollStep,
max: SLIDER_PARAMETERS.pitchScale.max,
min: SLIDER_PARAMETERS.pitchScale.min,
step: SLIDER_PARAMETERS.pitchScale.step,
scrollStep: SLIDER_PARAMETERS.pitchScale.scrollStep,
},
onChange: (pitchScale: number) =>
store.actions.COMMAND_MULTI_SET_AUDIO_PITCH_SCALE({
Expand All @@ -401,11 +400,11 @@ const parameterConfigs = computed<ParameterConfig[]>(() => [
modelValue: () => query.value?.intonationScale ?? null,
disable: () =>
uiLocked.value || !supportedFeatures.value?.adjustIntonationScale,
max: SLIDER_PARAMETERS.INTONATION.max,
min: SLIDER_PARAMETERS.INTONATION.min,
step: SLIDER_PARAMETERS.INTONATION.step,
scrollStep: SLIDER_PARAMETERS.INTONATION.scrollStep,
scrollMinStep: SLIDER_PARAMETERS.INTONATION.scrollMinStep,
max: SLIDER_PARAMETERS.intonationScale.max,
min: SLIDER_PARAMETERS.intonationScale.min,
step: SLIDER_PARAMETERS.intonationScale.step,
scrollStep: SLIDER_PARAMETERS.intonationScale.scrollStep,
scrollMinStep: SLIDER_PARAMETERS.intonationScale.scrollMinStep,
},
onChange: (intonationScale: number) =>
store.actions.COMMAND_MULTI_SET_AUDIO_INTONATION_SCALE({
Expand All @@ -420,11 +419,11 @@ const parameterConfigs = computed<ParameterConfig[]>(() => [
modelValue: () => query.value?.volumeScale ?? null,
disable: () =>
uiLocked.value || !supportedFeatures.value?.adjustVolumeScale,
max: SLIDER_PARAMETERS.VOLUME.max,
min: SLIDER_PARAMETERS.VOLUME.min,
step: SLIDER_PARAMETERS.VOLUME.step,
scrollStep: SLIDER_PARAMETERS.VOLUME.scrollStep,
scrollMinStep: SLIDER_PARAMETERS.VOLUME.scrollMinStep,
max: SLIDER_PARAMETERS.volumeScale.max,
min: SLIDER_PARAMETERS.volumeScale.min,
step: SLIDER_PARAMETERS.volumeScale.step,
scrollStep: SLIDER_PARAMETERS.volumeScale.scrollStep,
scrollMinStep: SLIDER_PARAMETERS.volumeScale.scrollMinStep,
},
onChange: (volumeScale: number) =>
store.actions.COMMAND_MULTI_SET_AUDIO_VOLUME_SCALE({
Expand All @@ -439,11 +438,11 @@ const parameterConfigs = computed<ParameterConfig[]>(() => [
modelValue: () => query.value?.pauseLengthScale ?? null,
disable: () =>
uiLocked.value || !supportedFeatures.value?.adjustPauseLength,
max: SLIDER_PARAMETERS.PAUSE_LENGTH_SCALE.max,
min: SLIDER_PARAMETERS.PAUSE_LENGTH_SCALE.min,
step: SLIDER_PARAMETERS.PAUSE_LENGTH_SCALE.step,
scrollStep: SLIDER_PARAMETERS.PAUSE_LENGTH_SCALE.scrollStep,
scrollMinStep: SLIDER_PARAMETERS.PAUSE_LENGTH_SCALE.scrollMinStep,
max: SLIDER_PARAMETERS.pauseLengthScale.max,
min: SLIDER_PARAMETERS.pauseLengthScale.min,
step: SLIDER_PARAMETERS.pauseLengthScale.step,
scrollStep: SLIDER_PARAMETERS.pauseLengthScale.scrollStep,
scrollMinStep: SLIDER_PARAMETERS.pauseLengthScale.scrollMinStep,
},
onChange: (pauseLengthScale: number) =>
store.actions.COMMAND_MULTI_SET_AUDIO_PAUSE_LENGTH_SCALE({
Expand All @@ -457,11 +456,11 @@ const parameterConfigs = computed<ParameterConfig[]>(() => [
sliderProps: {
modelValue: () => query.value?.prePhonemeLength ?? null,
disable: () => uiLocked.value,
max: SLIDER_PARAMETERS.PRE_PHONEME_LENGTH.max,
min: SLIDER_PARAMETERS.PRE_PHONEME_LENGTH.min,
step: SLIDER_PARAMETERS.PRE_PHONEME_LENGTH.step,
scrollStep: SLIDER_PARAMETERS.PRE_PHONEME_LENGTH.scrollStep,
scrollMinStep: SLIDER_PARAMETERS.PRE_PHONEME_LENGTH.scrollMinStep,
max: SLIDER_PARAMETERS.prePhonemeLength.max,
min: SLIDER_PARAMETERS.prePhonemeLength.min,
step: SLIDER_PARAMETERS.prePhonemeLength.step,
scrollStep: SLIDER_PARAMETERS.prePhonemeLength.scrollStep,
scrollMinStep: SLIDER_PARAMETERS.prePhonemeLength.scrollMinStep,
},
onChange: (prePhonemeLength: number) =>
store.actions.COMMAND_MULTI_SET_AUDIO_PRE_PHONEME_LENGTH({
Expand All @@ -475,11 +474,11 @@ const parameterConfigs = computed<ParameterConfig[]>(() => [
sliderProps: {
modelValue: () => query.value?.postPhonemeLength ?? null,
disable: () => uiLocked.value,
max: SLIDER_PARAMETERS.POST_PHONEME_LENGTH.max,
min: SLIDER_PARAMETERS.POST_PHONEME_LENGTH.min,
step: SLIDER_PARAMETERS.POST_PHONEME_LENGTH.step,
scrollStep: SLIDER_PARAMETERS.POST_PHONEME_LENGTH.scrollStep,
scrollMinStep: SLIDER_PARAMETERS.POST_PHONEME_LENGTH.scrollMinStep,
max: SLIDER_PARAMETERS.postPhonemeLength.max,
min: SLIDER_PARAMETERS.postPhonemeLength.min,
step: SLIDER_PARAMETERS.postPhonemeLength.step,
scrollStep: SLIDER_PARAMETERS.postPhonemeLength.scrollStep,
scrollMinStep: SLIDER_PARAMETERS.postPhonemeLength.scrollMinStep,
},
onChange: (postPhonemeLength: number) =>
store.actions.COMMAND_MULTI_SET_AUDIO_POST_PHONEME_LENGTH({
Expand All @@ -495,7 +494,7 @@ type Parameter = {
label: string;
slider: PreviewSliderHelper;
onChange: PreviewSliderHelperProps["onChange"];
key: ParameterKey;
key: PresetSliderKey;
};
const parameters = computed<Parameter[]>(() =>
parameterConfigs.value.map((parameterConfig) => ({
Expand Down Expand Up @@ -665,11 +664,11 @@ const morphingRateSlider = previewSliderHelper({
modelValue: () => audioItem.value.morphingInfo?.rate ?? null,
disable: () => uiLocked.value,
onChange: setMorphingRate,
max: SLIDER_PARAMETERS.MORPHING_RATE.max,
min: SLIDER_PARAMETERS.MORPHING_RATE.min,
step: SLIDER_PARAMETERS.MORPHING_RATE.step,
scrollStep: SLIDER_PARAMETERS.MORPHING_RATE.scrollStep,
scrollMinStep: SLIDER_PARAMETERS.MORPHING_RATE.scrollMinStep,
max: SLIDER_PARAMETERS.morphingRate.max,
min: SLIDER_PARAMETERS.morphingRate.min,
step: SLIDER_PARAMETERS.morphingRate.step,
scrollStep: SLIDER_PARAMETERS.morphingRate.scrollStep,
scrollMinStep: SLIDER_PARAMETERS.morphingRate.scrollMinStep,
});
// プリセット
Expand Down
38 changes: 24 additions & 14 deletions src/store/utility.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as diff from "fast-array-diff";
import {
CharacterInfo,
PresetSliderKey,
StyleInfo,
StyleType,
ToolbarButtonTagType,
Expand Down Expand Up @@ -40,14 +41,23 @@ export function sanitizeFileName(fileName: string): string {
return fileName.replace(sanitizer, "");
}

type SliderParameter = {
max: () => number;
min: () => number;
step: () => number;
scrollStep: () => number;
scrollMinStep?: () => number;
};

/**
* AudioInfoコンポーネントに表示されるパラメータ
* TODO: src/domain/talk.ts辺りに切り出す
*/
export const SLIDER_PARAMETERS = {
export const SLIDER_PARAMETERS: Record<PresetSliderKey, SliderParameter> = {
/**
* 話速パラメータの定義
*/
SPEED: {
speedScale: {
max: () => 2,
min: () => 0.5,
step: () => 0.01,
Expand All @@ -57,7 +67,7 @@ export const SLIDER_PARAMETERS = {
/**
* 音高パラメータの定義
*/
PITCH: {
pitchScale: {
max: () => 0.15,
min: () => -0.15,
step: () => 0.01,
Expand All @@ -66,7 +76,7 @@ export const SLIDER_PARAMETERS = {
/**
* 抑揚パラメータの定義
*/
INTONATION: {
intonationScale: {
max: () => 2,
min: () => 0,
step: () => 0.01,
Expand All @@ -76,38 +86,38 @@ export const SLIDER_PARAMETERS = {
/**
* 音量パラメータの定義
*/
VOLUME: {
volumeScale: {
max: () => 2,
min: () => 0,
step: () => 0.01,
scrollStep: () => 0.1,
scrollMinStep: () => 0.01,
},
/**
* 開始無音パラメータの定義
* 文内無音(倍率)パラメータの定義
*/
PRE_PHONEME_LENGTH: {
max: () => 1.5,
pauseLengthScale: {
max: () => 2,
min: () => 0,
step: () => 0.01,
scrollStep: () => 0.1,
scrollMinStep: () => 0.01,
},
/**
* 終了無音パラメータの定義
* 開始無音パラメータの定義
*/
POST_PHONEME_LENGTH: {
prePhonemeLength: {
max: () => 1.5,
min: () => 0,
step: () => 0.01,
scrollStep: () => 0.1,
scrollMinStep: () => 0.01,
},
/**
* 文内無音(倍率)パラメータの定義
* 終了無音パラメータの定義
*/
PAUSE_LENGTH_SCALE: {
max: () => 2,
postPhonemeLength: {
max: () => 1.5,
min: () => 0,
step: () => 0.01,
scrollStep: () => 0.1,
Expand All @@ -116,7 +126,7 @@ export const SLIDER_PARAMETERS = {
/**
* モーフィングレートパラメータの定義
*/
MORPHING_RATE: {
morphingRate: {
max: () => 1,
min: () => 0,
step: () => 0.01,
Expand Down
3 changes: 3 additions & 0 deletions src/type/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ export type Preset = {
postPhonemeLength: number;
morphingInfo?: MorphingInfo;
};
export type PresetSliderKey =
| keyof Omit<Preset, "name" | "morphingInfo">
| "morphingRate";

export type MorphingInfo = {
rate: number;
Expand Down

0 comments on commit 01822f2

Please sign in to comment.