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

マルチトラック:再生・書き出しに対応 #2163

Merged
merged 21 commits into from
Jul 22, 2024
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f2f4737
WIP
sevenc-nanashi Jul 7, 2024
9ae329d
Add: とりあえず再生できるように
sevenc-nanashi Jul 7, 2024
f4a565c
Add: 全書き出しをマルチトラックに対応
sevenc-nanashi Jul 7, 2024
0e56e64
Change: previewSynthをglobalChannelStripに直接繋ぐようにする
sevenc-nanashi Jul 8, 2024
7a51bc7
Change: generateDefaultSongFileNameをstoreの外に出す
sevenc-nanashi Jul 10, 2024
6eccab6
Change: watchStoreStatePluginにする
sevenc-nanashi Jul 10, 2024
d3aa785
Merge: main -> multitrack/play
sevenc-nanashi Jul 10, 2024
9ef350b
Change: fileHelperから持ってくるようにする
sevenc-nanashi Jul 10, 2024
7e03f14
Change: convertToWavFileDataを外に出す
sevenc-nanashi Jul 10, 2024
878df69
Change: watchStoreStatePlugins -> watchStoreStatePlugin
sevenc-nanashi Jul 10, 2024
a6d4cb2
Code: コメントを追加
sevenc-nanashi Jul 10, 2024
1670a27
Change: RENDER内を良い感じにする
sevenc-nanashi Jul 11, 2024
bf2e192
Delete: nextTickを削除
sevenc-nanashi Jul 11, 2024
6425a21
Merge: main -> multitrack/play
sevenc-nanashi Jul 18, 2024
b1f3da2
Code: コメントの内容を変える
sevenc-nanashi Jul 19, 2024
7b72645
Fix: 2回設定していたのを削除
sevenc-nanashi Jul 20, 2024
9f477bb
Change: globalChannelStrip -> mainChannelStrip
sevenc-nanashi Jul 21, 2024
f11d894
Change: createAudioPlayerSequenceを戻す
sevenc-nanashi Jul 21, 2024
c35937b
Change: shouldPlayTracks内のフィルタに任せる
sevenc-nanashi Jul 21, 2024
13d344d
Change: getterにする
sevenc-nanashi Jul 21, 2024
d665551
Add: limiterを追加
sevenc-nanashi Jul 21, 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
Prev Previous commit
Next Next commit
Change: globalChannelStrip -> mainChannelStrip
sevenc-nanashi committed Jul 21, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 9f477bb19edb157b60ba8c0a681326b53c82064d
28 changes: 14 additions & 14 deletions src/store/singing.ts
Original file line number Diff line number Diff line change
@@ -178,7 +178,7 @@ const offlineRenderTracks = async (
sampleRate,
);
const offlineTransport = new OfflineTransport();
const globalChannelStrip = new ChannelStrip(offlineAudioContext);
const mainChannelStrip = new ChannelStrip(offlineAudioContext);
const limiter = withLimiter ? new Limiter(offlineAudioContext) : undefined;
const clipper = new Clipper(offlineAudioContext);
const trackChannelStrips = new Map<TrackId, ChannelStrip>();
@@ -189,7 +189,7 @@ const offlineRenderTracks = async (
channelStrip.pan = track.pan;
channelStrip.mute = !getOrThrow(shouldPlays, trackId);

channelStrip.output.connect(globalChannelStrip.input);
channelStrip.output.connect(mainChannelStrip.input);
trackChannelStrips.set(trackId, channelStrip);
}

@@ -218,12 +218,12 @@ const offlineRenderTracks = async (
audioPlayer.output.connect(channelStrip.input);
offlineTransport.addSequence(audioSequence);
}
globalChannelStrip.volume = 1;
mainChannelStrip.volume = 1;
if (limiter) {
globalChannelStrip.output.connect(limiter.input);
mainChannelStrip.output.connect(limiter.input);
limiter.output.connect(clipper.input);
} else {
globalChannelStrip.output.connect(clipper.input);
mainChannelStrip.output.connect(clipper.input);
}
clipper.output.connect(offlineAudioContext.destination);

@@ -238,7 +238,7 @@ const offlineRenderTracks = async (
let audioContext: AudioContext | undefined;
let transport: Transport | undefined;
let previewSynth: PolySynth | undefined;
let globalChannelStrip: ChannelStrip | undefined;
let mainChannelStrip: ChannelStrip | undefined;
const trackChannelStrips = new Map<TrackId, ChannelStrip>();
let limiter: Limiter | undefined;
let clipper: Clipper | undefined;
@@ -248,12 +248,12 @@ if (window.AudioContext) {
audioContext = new AudioContext();
transport = new Transport(audioContext);
previewSynth = new PolySynth(audioContext);
globalChannelStrip = new ChannelStrip(audioContext);
mainChannelStrip = new ChannelStrip(audioContext);
limiter = new Limiter(audioContext);
clipper = new Clipper(audioContext);

previewSynth.output.connect(globalChannelStrip.input);
globalChannelStrip.output.connect(limiter.input);
previewSynth.output.connect(mainChannelStrip.input);
mainChannelStrip.output.connect(limiter.input);
limiter.output.connect(clipper.input);
clipper.output.connect(audioContext.destination);
}
@@ -272,14 +272,14 @@ export const singingStorePlugin: WatchStoreStatePlugin = (store) => {
// tracksの変更とtrackChannelStripsを同期する。
// NOTE: immerの差分検知はChannelStripだと動かないので、tracksの変更を監視して同期する。
watchSyncEffect(async () => {
if (!audioContext || !globalChannelStrip) {
if (!audioContext || !mainChannelStrip) {
return;
}
const shouldPlays = shouldPlayTracks(store.state.tracks);
for (const [trackId, track] of store.state.tracks) {
if (!trackChannelStrips.has(trackId)) {
const channelStrip = new ChannelStrip(audioContext);
channelStrip.output.connect(globalChannelStrip.input);
channelStrip.output.connect(mainChannelStrip.input);

trackChannelStrips.set(trackId, channelStrip);
sevenc-nanashi marked this conversation as resolved.
Show resolved Hide resolved
}
@@ -1022,12 +1022,12 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
state.volume = volume;
},
async action({ commit }, { volume }) {
if (!globalChannelStrip) {
if (!mainChannelStrip) {
throw new Error("channelStrip is undefined.");
}
commit("SET_VOLUME", { volume });

globalChannelStrip.volume = volume;
mainChannelStrip.volume = volume;
},
},

@@ -1552,7 +1552,7 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
if (!transport) {
throw new Error("transport is undefined.");
}
if (!globalChannelStrip) {
if (!mainChannelStrip) {
throw new Error("channelStrip is undefined.");
}
const audioContextRef = audioContext;