Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: ソングの書き出しダイアログを追加 #2287

Merged
merged 32 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3bc974b
Add: ソングの書き出しダイアログを追加
sevenc-nanashi Oct 6, 2024
746e911
Add: ダイアログを完成させる
sevenc-nanashi Oct 8, 2024
2da6078
Add: パラメータ適用以外は実装
sevenc-nanashi Oct 8, 2024
a6c489a
Merge: main -> add/song-export-dialog
sevenc-nanashi Oct 8, 2024
f257ac7
Add: 書き出せるように
sevenc-nanashi Oct 8, 2024
d2da407
Change: wave -> audio
sevenc-nanashi Oct 8, 2024
38b3449
Add: wav以外の書き出しを追加
sevenc-nanashi Oct 8, 2024
235c8c0
Change: メモ -> NOTE
sevenc-nanashi Oct 8, 2024
e0546f1
Fix: ファイル名のプレビューを修正
sevenc-nanashi Oct 8, 2024
0e9ffbd
Fix: トーク側のファイル名を修正
sevenc-nanashi Oct 8, 2024
ab10033
Change: DialogStatesに定義を置く
sevenc-nanashi Oct 8, 2024
3074f3f
Add: 出力ポップアップを追加
sevenc-nanashi Oct 8, 2024
5865b94
Fix: プレビューを修正
sevenc-nanashi Oct 9, 2024
dea09c3
Delete: フォーマット選択を削除
sevenc-nanashi Oct 10, 2024
e77378e
Change: テキストを変える
sevenc-nanashi Oct 10, 2024
c7e81a9
Update: 色々更新
sevenc-nanashi Oct 10, 2024
fe0338e
Change: モノラル時はpan=0を使う用に
sevenc-nanashi Oct 10, 2024
4cdd363
Change: ステレオでandをかける
sevenc-nanashi Oct 10, 2024
a037a42
Change: wav -> WAV
sevenc-nanashi Oct 10, 2024
96a7298
Code: コメントを変える
sevenc-nanashi Oct 10, 2024
0e250f7
Change: 書き出し -> 書き出す
sevenc-nanashi Oct 10, 2024
e8e75fd
Code: コメントを追加
sevenc-nanashi Oct 10, 2024
8be9c4d
Revert: package-lock.jsonの変更を戻す
sevenc-nanashi Oct 10, 2024
e49714f
Change: TrackParametersをstore/type.tsに移動
sevenc-nanashi Oct 10, 2024
f62c512
Change: isMonoに
sevenc-nanashi Oct 10, 2024
a134148
Code: コメントを追加
sevenc-nanashi Oct 10, 2024
04fb7ff
Fix: デフォルト値を修正
sevenc-nanashi Oct 10, 2024
7685fd8
Fix: 条件を修正
sevenc-nanashi Oct 11, 2024
6a40314
Improvr: テキストをいい感じにする
sevenc-nanashi Oct 11, 2024
ed909fc
Change: isStereo -> isMono
sevenc-nanashi Oct 11, 2024
7a01ce6
Improve: モノラル書き出しをオンにするとパンが無効化されるように
sevenc-nanashi Oct 12, 2024
b693b20
微調整
Hiroshiba Oct 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/backend/common/ConfigManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ const migrations: [string, (store: Record<string, unknown>) => unknown][] = [
delete experimentalSetting.shouldApplyDefaultPresetOnVoiceChanged;
}

// 書き出しテンプレートから拡張子を削除
const savingSetting = config.savingSetting as { fileNamePattern: string };
savingSetting.fileNamePattern = savingSetting.fileNamePattern.replace(
".wav",
"",
);
sevenc-nanashi marked this conversation as resolved.
Show resolved Hide resolved

Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
return config;
},
],
Expand Down
12 changes: 10 additions & 2 deletions src/backend/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,12 @@ registerIpcMainHandle<IpcMainHandle>({
dialog.showSaveDialog(win, {
title,
defaultPath,
filters: [{ name: "Wave File", extensions: ["wav"] }],
filters: [
{
name: "WAVファイル",
extensions: ["wav"],
},
],
properties: ["createDirectory"],
}),
);
Expand Down Expand Up @@ -872,7 +877,10 @@ registerIpcMainHandle<IpcMainHandle>({

WRITE_FILE: (_, { filePath, buffer }) => {
try {
fs.writeFileSync(filePath, new DataView(buffer));
fs.writeFileSync(
filePath,
new DataView(buffer instanceof Uint8Array ? buffer.buffer : buffer),
);
return success(undefined);
} catch (e) {
// throwだと`.code`の情報が消えるのでreturn
Expand Down
11 changes: 11 additions & 0 deletions src/components/Dialog/AllDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<UpdateNotificationDialogContainer
:canOpenDialog="canOpenNotificationDialog"
/>
<ExportSongAudioDialog v-model="isExportSongAudioDialogOpen" />
<ImportSongProjectDialog v-model="isImportSongProjectDialogOpenComputed" />
</template>

Expand All @@ -39,6 +40,7 @@ import DictionaryManageDialog from "@/components/Dialog/DictionaryManageDialog.v
import EngineManageDialog from "@/components/Dialog/EngineManageDialog.vue";
import UpdateNotificationDialogContainer from "@/components/Dialog/UpdateNotificationDialog/Container.vue";
import ImportSongProjectDialog from "@/components/Dialog/ImportSongProjectDialog.vue";
import ExportSongAudioDialog from "@/components/Dialog/ExportSongAudioDialog/Container.vue";
import { useStore } from "@/store";
import { filterCharacterInfosByStyleType } from "@/store/utility";

Expand Down Expand Up @@ -159,6 +161,15 @@ const canOpenNotificationDialog = computed(() => {
);
});

// ソングのオーディオエクスポート時の設定ダイアログ
const isExportSongAudioDialogOpen = computed({
get: () => store.state.isExportSongAudioDialogOpen,
set: (val) =>
store.dispatch("SET_DIALOG_OPEN", {
isExportSongAudioDialogOpen: val,
}),
});

// ソングのプロジェクトファイルのインポート時の設定ダイアログ
const isImportSongProjectDialogOpenComputed = computed({
get: () => store.state.isImportSongProjectDialogOpen,
Expand Down
62 changes: 26 additions & 36 deletions src/components/Dialog/Dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { DotNotationDispatch } from "@/store/vuex";
import { withProgressDotNotation as withProgress } from "@/store/ui";

type MediaType = "audio" | "text";
export type MediaType = "audio" | "text";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exportしたの使ってないかも

Suggested change
export type MediaType = "audio" | "text";
type MediaType = "audio" | "text";

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(個人の感覚ですが)エクスポートした関数の引数の型はエクスポートされてないとなんか気持ち悪いんですよね...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

実際exportしておいた方が便利な気もしますが、ここだけそうなっているのは逆に不便さが勝る気がします。
とはいえ直してくださいというのもあれだと思うので、ちょっとこっち直しちゃいますね!


export type CommonDialogResult = "OK" | "CANCEL";
export type CommonDialogOptions = {
Expand Down Expand Up @@ -160,18 +160,8 @@ export async function generateAndSaveOneAudioWithDialog({
actions,
);

if (result.result === "CANCELED") return;

if (result.result === "SUCCESS") {
if (disableNotifyOnGenerate) return;
// 書き出し成功時に通知をする
showWriteSuccessNotify({
mediaType: "audio",
actions,
});
} else {
showWriteErrorDialog({ mediaType: "audio", result, actions });
}
if (result == undefined) return;
notifyResult(result, "audio", actions, disableNotifyOnGenerate);
}

export async function multiGenerateAndSaveAudioWithDialog({
Expand Down Expand Up @@ -260,17 +250,8 @@ export async function generateAndConnectAndSaveAudioWithDialog({
actions,
);

if (result == undefined || result.result === "CANCELED") return;

if (result.result === "SUCCESS") {
if (disableNotifyOnGenerate) return;
showWriteSuccessNotify({
mediaType: "audio",
actions,
});
} else {
showWriteErrorDialog({ mediaType: "audio", result, actions });
}
if (result == undefined) return;
notifyResult(result, "audio", actions, disableNotifyOnGenerate);
}

export async function connectAndExportTextWithDialog({
Expand All @@ -285,18 +266,8 @@ export async function connectAndExportTextWithDialog({
const result = await actions.CONNECT_AND_EXPORT_TEXT({
filePath,
});

if (result == undefined || result.result === "CANCELED") return;

if (result.result === "SUCCESS") {
if (disableNotifyOnGenerate) return;
showWriteSuccessNotify({
mediaType: "text",
actions,
});
} else {
showWriteErrorDialog({ mediaType: "text", result, actions });
}
if (!result) return;
notifyResult(result, "text", actions, disableNotifyOnGenerate);
}

// 書き出し成功時の通知を表示
Expand Down Expand Up @@ -352,6 +323,25 @@ const showWriteErrorDialog = ({
}
};

/** 保存結果に応じてユーザーに通知する。キャンセルされた場合は何もしない。 */
export const notifyResult = (
sevenc-nanashi marked this conversation as resolved.
Show resolved Hide resolved
result: SaveResultObject,
mediaType: MediaType,
actions: DotNotationDispatch<AllActions>,
disableNotifyOnGenerate: boolean,
) => {
if (result.result === "CANCELED") return;
if (result.result === "SUCCESS") {
if (disableNotifyOnGenerate) return;
showWriteSuccessNotify({
mediaType,
actions,
});
} else {
showWriteErrorDialog({ mediaType, result, actions });
}
};

const NOTIFY_TIMEOUT = 7000;

export const showNotifyAndNotShowAgainButton = (
Expand Down
41 changes: 41 additions & 0 deletions src/components/Dialog/ExportSongAudioDialog/BaseCell.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コピーしたことがわかるように、ちょっとメモ書きだけ書いときますか!

Suggested change
<template>
<!-- SettingDialogのBaseCellを参考にして作成 -->
<template>

こういうメモあった方がいいのかない方がいいのかわかんないですね。。。
ま、まあ、気が向けば・・・!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

気が向かない(というよりあってもそんなに特が無い気がする)のでパスします。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

了解です!
確かにあってもあんま無駄な気がしますが、ここにたどり着いたコミッターの方には便利だと思うので、ちょっとこちらで書いてみますね!

<QCardActions :class="props.class">
<div>{{ title }}</div>
<div :aria-label="description">
<QIcon name="help_outline" size="sm" class="help-hover-icon">
<QTooltip
:delay="500"
anchor="center right"
self="center left"
transitionShow="jump-right"
transitionHide="jump-left"
>
{{ description }}
</QTooltip>
</QIcon>
</div>
<QSpace />
<slot />
</QCardActions>
</template>

<script setup lang="ts">
export type Props = {
title: string;
description: string;
class?: unknown; // 型はquasarの定義を真似ている
};

const props = defineProps<Props>();
</script>

<style scoped lang="scss">
@use "@/styles/visually-hidden" as visually-hidden;
@use "@/styles/colors" as colors;

.help-hover-icon {
margin-left: 6px;
color: colors.$display;
opacity: 0.5;
}
</style>
36 changes: 36 additions & 0 deletions src/components/Dialog/ExportSongAudioDialog/Container.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<Presentation v-model="modelValue" @exportAudio="handleExportAudio" />
</template>

<script setup lang="ts">
import { notifyResult } from "../Dialog";
import Presentation, { ExportTarget } from "./Presentation.vue";
import { useStore } from "@/store";
import { SaveResultObject, SongExportSetting } from "@/store/type";

defineOptions({
name: "ExportSongAudioDialog",
});

const modelValue = defineModel<boolean>();
const store = useStore();

const handleExportAudio = async (
target: ExportTarget,
setting: SongExportSetting,
) => {
let result: SaveResultObject;
if (target === "master") {
result = await store.dispatch("EXPORT_AUDIO_FILE", { setting });
} else {
result = await store.dispatch("EXPORT_STEM_AUDIO_FILE", { setting });
}

notifyResult(
result,
"audio",
store.actions,
store.state.confirmedTips.notifyOnGenerate,
);
};
</script>
Loading
Loading