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

マルチトラック:storeを色々変える #2093

Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
caeb9bc
Change: phrase以外をtrackIdを受け取るようにする
sevenc-nanashi May 20, 2024
e05a37a
wip
sevenc-nanashi May 22, 2024
b677470
Update: singing.tsを色々変える
sevenc-nanashi May 22, 2024
ad9213e
Update: store以外を良い感じに合わせる
sevenc-nanashi May 22, 2024
1821a81
Add: マイグレーションを追加
sevenc-nanashi May 22, 2024
5814360
Fix: SET_TRACKでselectedTrackIdが無を参照するのを修正
sevenc-nanashi May 22, 2024
e7884a0
Fix: 二重にセットするように
sevenc-nanashi May 22, 2024
344c4bd
Fix: trackOrderにする
sevenc-nanashi May 25, 2024
23bebb1
Change: SELECT_TRACKしないようにする
sevenc-nanashi May 25, 2024
347889a
Code: data -> pitchArray
sevenc-nanashi May 25, 2024
39f65e5
Code: SET_SINGING_GUIDE_KEY_TO_PHRASEに型をつける
sevenc-nanashi May 25, 2024
3424633
Code: こっちも型をつける
sevenc-nanashi May 25, 2024
f48e7c7
WIP: むずい
sevenc-nanashi May 25, 2024
acaece1
Change: PhraseにtrackIdを持たせる
sevenc-nanashi May 26, 2024
3f84b3f
Fix: 型エラーを修正
sevenc-nanashi May 27, 2024
ef164fd
Change: SET_NOTESとかの処理をSET_TRACKに写す
sevenc-nanashi May 27, 2024
4eee4e4
Fix: overlappingNoteIds.hasが抜けてたのを修正
sevenc-nanashi May 27, 2024
c70f3e0
Change: initialTrackIdにする
sevenc-nanashi May 27, 2024
98bb972
Code: コメントを修正
sevenc-nanashi May 27, 2024
43e8122
Change: singerAndFrameRatesを最初に作っておく
sevenc-nanashi May 27, 2024
f0092c9
Code: トラック周りのactionを移動
sevenc-nanashi May 27, 2024
4fd821c
Fix: overlappingNoteInfos周りを修正
sevenc-nanashi May 27, 2024
6315e46
Change: Mapのキーを変える
sevenc-nanashi May 31, 2024
57ee262
Change: CREATE_TRACKをADD_TRACKと分割
sevenc-nanashi May 31, 2024
09a5da8
Code: 空行を開ける
sevenc-nanashi May 31, 2024
d51eb36
Change: overlappingNoteIdsをトラック毎に持つようにする
sevenc-nanashi May 31, 2024
f0cd501
Code: コメントを移動
sevenc-nanashi Jun 1, 2024
b18c9ac
Fix: Renderする
sevenc-nanashi Jun 1, 2024
ec0336d
Add: trackOrderに入ってるかバリデーションする
sevenc-nanashi Jun 1, 2024
ec521b4
Add: tracksに入ってるかバリデーションする
sevenc-nanashi Jun 1, 2024
f7721c1
Delete: SET_TRACK_ORDERを一度消す
sevenc-nanashi Jun 1, 2024
9694a6e
Delete: singerAndFrameRatesの片引き数を消す
sevenc-nanashi Jun 1, 2024
7c5b056
Add: trackのバリデーションを追加
sevenc-nanashi Jun 1, 2024
5d27e99
Fix: overlappingNoteIdsを代入してなかったので修正
sevenc-nanashi Jun 1, 2024
27207cf
Change: 判定方法を変更
sevenc-nanashi Jun 2, 2024
dd6b6ea
Change: tracks.hasに一本化する
sevenc-nanashi Jun 2, 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
8 changes: 8 additions & 0 deletions src/sing/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ export const isValidNotes = (notes: Note[]) => {
return notes.every((value) => isValidNote(value));
};

export const isValidTrack = (track: Track) => {
return (
Number.isInteger(track.keyRangeAdjustment) &&
Number.isInteger(track.volumeRangeAdjustment) &&
isValidNotes(track.notes)
sevenc-nanashi marked this conversation as resolved.
Show resolved Hide resolved
);
};

const tickToSecondForConstantBpm = (
ticks: number,
bpm: number,
Expand Down
35 changes: 18 additions & 17 deletions src/store/singing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import {
createDefaultTempo,
createDefaultTimeSignature,
isValidNotes,
isValidTrack,
} from "@/sing/domain";
import {
FrequentlyUpdatedState,
Expand Down Expand Up @@ -924,16 +925,27 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
state.overlappingNoteInfos.set(trackId, new Map());
state.overlappingNoteIds.set(trackId, new Set());
},
action({ commit }, { trackId, track }) {
action({ state, commit, dispatch }, { trackId, track }) {
if (state.trackOrder.includes(trackId)) {
throw new Error(`Track ${trackId} is already registered.`);
}
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
if (!isValidTrack(track)) {
throw new Error("The track is invalid.");
}
commit("REGISTER_TRACK", { trackId, track });
sevenc-nanashi marked this conversation as resolved.
Show resolved Hide resolved

dispatch("RENDER");
},
},

SELECT_TRACK: {
mutation(state, { trackId }) {
state.selectedTrackId = trackId;
},
action({ commit }, { trackId }) {
action({ state, commit }, { trackId }) {
if (!state.tracks.has(trackId)) {
throw new Error(`Track ${trackId} does not exist.`);
}
commit("SELECT_TRACK", { trackId });
sevenc-nanashi marked this conversation as resolved.
Show resolved Hide resolved
},
},
Expand Down Expand Up @@ -977,15 +989,6 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
},
},

SET_TRACK_ORDER: {
mutation(state, { trackOrder }) {
state.trackOrder = trackOrder;
},
action({ commit }, { trackOrder }) {
commit("SET_TRACK_ORDER", { trackOrder });
},
},

/**
* レンダリングを行う。レンダリング中だった場合は停止して再レンダリングする。
*/
Expand Down Expand Up @@ -1328,12 +1331,11 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
const audioContextRef = audioContext;
const transportRef = transport;
const channelStripRef = channelStrip;

// レンダリング中に変更される可能性のあるデータをコピーする
const tracks = structuredClone(toRaw(state.tracks));
sevenc-nanashi marked this conversation as resolved.
Show resolved Hide resolved

const singerAndFrameRates = new Map<
TrackId,
{ singer: Singer; frameRate: number } | undefined
>(
const singerAndFrameRates = new Map(
[...tracks].map(([trackId, track]) => [
trackId,
track.singer
Expand All @@ -1345,11 +1347,10 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
: undefined,
]),
);

// レンダリング中に変更される可能性のあるデータをコピーする
const tpqn = state.tpqn;
const tempos = state.tempos.map((value) => ({ ...value }));
const editFrameRate = state.editFrameRate;

const firstRestMinDurationSeconds = 0.12;
const lastRestDurationSeconds = 0.5;
const fadeOutDurationSeconds = 0.15;
Expand Down
5 changes: 0 additions & 5 deletions src/store/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1168,11 +1168,6 @@ export type SingingStoreTypes = {
mutation: { tracks: Map<TrackId, Track> };
action(payload: { tracks: Map<TrackId, Track> }): Promise<void>;
};

SET_TRACK_ORDER: {
mutation: { trackOrder: TrackId[] };
action(payload: { trackOrder: TrackId[] }): void;
};
};

export type SingingCommandStoreState = {
Expand Down
Loading