From 3e18a726d529cd15ccc22db052ca4eb3262239cb Mon Sep 17 00:00:00 2001 From: Yuki Igarashi <44018880+P0ngCh4ng@users.noreply.github.com> Date: Wed, 21 Feb 2024 03:54:01 +0900 Subject: [PATCH] =?UTF-8?q?fix=20=E6=AD=8Cwave=E5=87=BA=E5=8A=9B=E6=99=82?= =?UTF-8?q?=E3=81=AE=E3=83=87=E3=83=95=E3=82=A9=E3=83=AB=E3=83=88=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E5=90=8D=E3=82=92=E5=A4=89=E6=9B=B4?= =?UTF-8?q?=20(#1859)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix 歌wave出力時のデフォルトファイル名を変更 * refactor: 歌waveのデフォルトファイル名を変更する処理を関数に切り出し * 細かい変更 --------- Co-authored-by: Hiroshiba --- src/store/singing.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/store/singing.ts b/src/store/singing.ts index 6aae891d5c..6ffc743661 100644 --- a/src/store/singing.ts +++ b/src/store/singing.ts @@ -18,6 +18,7 @@ import { PhraseState, transformCommandStore, } from "./type"; +import { sanitizeFileName } from "./utility"; import { EngineId } from "@/type/preload"; import { FrameAudioQuery, Note as NoteForRequestToEngine } from "@/openapi"; import { ResultError, getValueOrThrow } from "@/type/result"; @@ -1785,8 +1786,34 @@ export const singingStore = createPartialStore({ return Math.max(1, lastNoteEndTime + 1); }; + const generateDefaultSongFileName = () => { + const projectName = getters.PROJECT_NAME; + if (projectName) { + return projectName.split(".")[0] + ".wav"; + } + + const singer = getters.SELECTED_TRACK.singer; + if (singer) { + const singerName = getters.CHARACTER_INFO( + singer.engineId, + singer.styleId + )?.metas.speakerName; + if (singerName) { + const notes = getters.SELECTED_TRACK.notes.slice(0, 5); + const beginningPartLyrics = notes + .map((note) => note.lyric) + .join(""); + return sanitizeFileName( + `${singerName}_${beginningPartLyrics}.wav` + ); + } + } + + return "Untitled.wav"; + }; + const exportWaveFile = async (): Promise => { - const fileName = "test_export.wav"; // TODO: 設定できるようにする + const fileName = generateDefaultSongFileName(); const numberOfChannels = 2; const sampleRate = 48000; // TODO: 設定できるようにする const withLimiter = false; // TODO: 設定できるようにする