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

選択した再生デバイスがソングでも適用されるようにする #2375

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ watchEffect(() => {
setThemeToCss(theme);
});

// 再生デバイスの初期化と変更の監視
watchEffect(() => {
void store.actions.APPLY_DEVICE_ID_TO_AUDIO_CONTEXT({
device: store.state.savingSetting.audioOutputDevice,
});
});

// ソフトウェアを初期化
const { hotkeyManager } = useHotkeyManager();
const isEnginesReady = ref(false);
Expand Down
17 changes: 17 additions & 0 deletions src/store/singing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import { uuid4 } from "@/helpers/random";
import { convertToWavFileData } from "@/sing/convertToWavFileData";
import { generateWriteErrorMessage } from "@/helpers/fileHelper";
import path from "@/helpers/path";
import { showAlertDialog } from "@/components/Dialog/Dialog";

const logger = createLogger("store/singing");

Expand Down Expand Up @@ -1682,6 +1683,22 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
},
},

APPLY_DEVICE_ID_TO_AUDIO_CONTEXT: {
action(_, { device }) {
if (audioContext) {
const sinkId = device === "default" ? "" : device;
audioContext.setSinkId(sinkId).catch((err: unknown) => {
void showAlertDialog({
type: "error",
title: "エラー",
message: "再生デバイスが見つかりません",
});
throw err;
});
}
},
},

/**
* レンダリングを行う。レンダリング中だった場合は停止して再レンダリングする。
*/
Expand Down
4 changes: 4 additions & 0 deletions src/store/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,10 @@ export type SingingStoreTypes = {
SYNC_TRACKS_AND_TRACK_CHANNEL_STRIPS: {
action(): void;
};

APPLY_DEVICE_ID_TO_AUDIO_CONTEXT: {
action(payload: { device: string }): void;
};
};

export type SingingCommandStoreState = {
Expand Down
4 changes: 4 additions & 0 deletions src/type/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ declare global {
setSinkId(deviceID: string): Promise<undefined>; // setSinkIdを認識してくれないため
}

interface AudioContext {
setSinkId: (sinkId: string) => Promise<void>;
}

interface Window {
readonly [SandboxKey]: import("./preload").Sandbox;
}
Expand Down
Loading