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

ピッチ編集機能を追加 #2003

Merged
merged 50 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
16e465c
ピッチ編集機能を追加
sigprogramming Apr 18, 2024
26b6c1d
修正
sigprogramming Apr 19, 2024
c0ea4fe
色を調整、UIを修正
sigprogramming Apr 19, 2024
d61c3c0
ペンの画像を追加、ピッチ編集時のカーソルをペンに変更
sigprogramming Apr 20, 2024
4c6e644
TODOコメントを追加
sigprogramming Apr 20, 2024
36e8b5b
ピッチ編集をundo/redoできるようにした
sigprogramming Apr 20, 2024
a43144e
有声区間のみピッチ編集を適用するように変更
sigprogramming Apr 20, 2024
17ecaf0
ピッチ編集データを平滑化してからセットするようにした
sigprogramming Apr 20, 2024
9cc6e97
Update src/components/Dialog/SettingDialog.vue
sigprogramming Apr 21, 2024
55db36a
Update src/components/Sing/ScoreSequencer.vue
sigprogramming Apr 21, 2024
c2cce14
例外を使用して網羅性チェックを行うようにした
sigprogramming Apr 21, 2024
496b6fe
pitchEdit.dataのところにコメントを追加、データが無いことを表す値を定数で定義
sigprogramming Apr 21, 2024
ec97ae3
prevCursorFrameとprevCursorFrequencyをまとめてprevCursorPosに変更、コメントを追加
sigprogramming Apr 21, 2024
5f4c065
修正
sigprogramming Apr 21, 2024
67fef5d
ピッチ編集機能が無効になったときに行う処理をSingEditorに移動
sigprogramming Apr 21, 2024
5494167
1フレームのピッチ変更を適用しない理由をコメントで説明
sigprogramming Apr 21, 2024
1b557e8
編集モードの判定をcomputed内で行うようにした
sigprogramming Apr 21, 2024
5a32bc9
プレビュー時に実行される関数の処理を説明するコメントを追加
sigprogramming Apr 21, 2024
99d60c2
コメントを追加
sigprogramming Apr 21, 2024
0e42330
EditModeをEditTargetに変更
sigprogramming Apr 21, 2024
a287179
DataSectionのハッシュの型をブランド型にした
sigprogramming Apr 21, 2024
4935a2f
データ区間のマップを更新する関数の処理を説明するコメントを追加、コメントを修正
sigprogramming Apr 21, 2024
b8fc343
フレームレート周りを一旦変更
sigprogramming Apr 22, 2024
adfc414
Colorクラスの値の範囲をコメントで書いた
sigprogramming Apr 22, 2024
5c29acd
FramewiseDataSectionに変更
sigprogramming Apr 22, 2024
4072e8d
watchのimmediateをtrueに設定
sigprogramming Apr 22, 2024
4fffb7f
データ区間のマップを生成する処理を関数に切り出した
sigprogramming Apr 22, 2024
a0c3260
concatからpushに変更、spliceを使用してデータを書き換える形に変更
sigprogramming Apr 22, 2024
b2bccd3
SET_PITCH_EDIT_DATAのところにコメントを追加
sigprogramming Apr 22, 2024
1498820
ピッチ編集を適用する処理のところにコメントを追加
sigprogramming Apr 22, 2024
8cf7941
修正
sigprogramming Apr 22, 2024
fe4fa12
DataSectionMapの更新処理が開始順で完了せずピッチの表示が更新されないことがある不具合を修正
sigprogramming Apr 22, 2024
33cd5fb
修正
sigprogramming Apr 22, 2024
e5b8164
Revert "concatからpushに変更、spliceを使用してデータを書き換える形に変更"
sigprogramming Apr 22, 2024
07d5761
ExhaustiveErrorを移動
sigprogramming Apr 22, 2024
f2a705b
NOTEコメントを追加
sigprogramming Apr 23, 2024
548518c
修正
sigprogramming Apr 23, 2024
98fc1f3
structuredCloneを使用してディープコピーするようにした
sigprogramming Apr 23, 2024
8c8adb5
asyncProcessで例外が発生したときにisRunningとisRunRequestedがfalseにならないのを修正
sigprogramming Apr 23, 2024
09b2117
非同期処理の実行部分を変更
sigprogramming Apr 24, 2024
7dbbb30
AsyncLockを使用する形にした
sigprogramming Apr 24, 2024
01c47ed
DEPRECATEDにしてコメントを追加
sigprogramming Apr 24, 2024
9e21295
CLEAR_PITCH_EDIT_DATAを削除
sigprogramming Apr 24, 2024
1a432a4
縦方向のズームの下限を調整
sigprogramming Apr 24, 2024
4c6f4fd
Update src/type/utility.ts
sigprogramming Apr 24, 2024
08341ac
Update src/sing/utility.ts
sigprogramming Apr 24, 2024
51a42c2
元のピッチの色の彩度を12から15にした
sigprogramming Apr 25, 2024
03a7cfb
concatからpushに変更、spliceを使用してデータを書き換える形に変更
sigprogramming Apr 25, 2024
5e8f44a
macでピッチの消去ができるように修正
sigprogramming Apr 25, 2024
cad48f0
to mouseButton
Hiroshiba Apr 25, 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
42 changes: 26 additions & 16 deletions src/components/Sing/ScoreSequencer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ import {
DoubleClickDetector,
NoteAreaInfo,
GridAreaInfo,
getButton,
} from "@/sing/viewHelper";
import SequencerRuler from "@/components/Sing/SequencerRuler.vue";
import SequencerKeys from "@/components/Sing/SequencerKeys.vue";
Expand Down Expand Up @@ -968,12 +969,13 @@ const onNoteBarMouseDown = (event: MouseEvent, note: Note) => {
if (editTarget.value !== "NOTE" || !isSelfEventTarget(event)) {
return;
}
const downButton = getButton(event);
// ダブルクリック用の処理を行う
if (event.button === 0) {
if (downButton === "LEFT_BUTTON") {
mouseDownAreaInfo = new NoteAreaInfo(note.id);
}

if (event.button === 0) {
if (downButton === "LEFT_BUTTON") {
startPreview(event, "MOVE", note);
} else if (!state.selectedNoteIds.has(note.id)) {
selectOnlyThis(note);
Expand All @@ -984,12 +986,13 @@ const onNoteLeftEdgeMouseDown = (event: MouseEvent, note: Note) => {
if (editTarget.value !== "NOTE" || !isSelfEventTarget(event)) {
return;
}
const downButton = getButton(event);
// ダブルクリック用の処理を行う
if (event.button === 0) {
if (downButton === "LEFT_BUTTON") {
mouseDownAreaInfo = new NoteAreaInfo(note.id);
}

if (event.button === 0) {
if (downButton === "LEFT_BUTTON") {
startPreview(event, "RESIZE_LEFT", note);
} else if (!state.selectedNoteIds.has(note.id)) {
selectOnlyThis(note);
Expand All @@ -1000,12 +1003,13 @@ const onNoteRightEdgeMouseDown = (event: MouseEvent, note: Note) => {
if (editTarget.value !== "NOTE" || !isSelfEventTarget(event)) {
return;
}
const downButton = getButton(event);
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
// ダブルクリック用の処理を行う
if (event.button === 0) {
if (downButton === "LEFT_BUTTON") {
mouseDownAreaInfo = new NoteAreaInfo(note.id);
}

if (event.button === 0) {
if (downButton === "LEFT_BUTTON") {
startPreview(event, "RESIZE_RIGHT", note);
} else if (!state.selectedNoteIds.has(note.id)) {
selectOnlyThis(note);
Expand All @@ -1016,8 +1020,9 @@ const onNoteLyricMouseDown = (event: MouseEvent, note: Note) => {
if (editTarget.value !== "NOTE" || !isSelfEventTarget(event)) {
return;
}
const downButton = getButton(event);
// ダブルクリック用の処理を行う
if (event.button === 0) {
if (downButton === "LEFT_BUTTON") {
mouseDownAreaInfo = new NoteAreaInfo(note.id);
}

Expand All @@ -1030,19 +1035,15 @@ const onMouseDown = (event: MouseEvent) => {
if (editTarget.value === "NOTE" && !isSelfEventTarget(event)) {
return;
}
// macOSの場合、Ctrl+クリックが右クリックのため、その場合はノートを追加しない
// TODO: 他の箇所でもチェックを行うようにする
if (isMac && event.ctrlKey && event.button === 0) {
return;
}
const downButton = getButton(event);
// ダブルクリック用の処理を行う
if (event.button === 0) {
if (downButton === "LEFT_BUTTON") {
mouseDownAreaInfo = new GridAreaInfo();
}

// TODO: メニューが表示されている場合はメニュー非表示のみ行いたい
if (editTarget.value === "NOTE") {
if (event.button === 0) {
if (downButton === "LEFT_BUTTON") {
if (event.shiftKey) {
isRectSelecting.value = true;
rectSelectStartX.value = cursorX.value;
Expand All @@ -1054,7 +1055,15 @@ const onMouseDown = (event: MouseEvent) => {
store.dispatch("DESELECT_ALL_NOTES");
}
} else if (editTarget.value === "PITCH") {
if (event.button === 0) {
if (isMac) {
// Macの場合、左ボタンでDRAW、右ボタンでERASE
if (downButton === "LEFT_BUTTON") {
startPreview(event, "DRAW_PITCH");
} else if (downButton === "RIGHT_BUTTON") {
startPreview(event, "ERASE_PITCH");
}
} else if (downButton === "LEFT_BUTTON") {
// Mac以外の場合、左ボタンでDRAW、左ボタン+CtrlでERASE
if (event.ctrlKey) {
startPreview(event, "ERASE_PITCH");
} else {
Expand Down Expand Up @@ -1089,7 +1098,8 @@ const onMouseMove = (event: MouseEvent) => {
};

const onMouseUp = (event: MouseEvent) => {
if (event.button !== 0) {
const upButton = getButton(event);
if (upButton !== "LEFT_BUTTON") {
return;
}
// ダブルクリック用の処理を行う
Expand Down
14 changes: 7 additions & 7 deletions src/components/Sing/SequencerPitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type PitchLine = {
readonly lineStrip: LineStrip;
};

const originalPitchLineColor = new Color(177, 201, 181, 255);
const originalPitchLineColor = new Color(171, 201, 176, 255);
const originalPitchLineWidth = 1.2;
const pitchEditLineColor = new Color(146, 214, 154, 255);
const pitchEditLineWidth = 2;
Expand Down Expand Up @@ -261,7 +261,7 @@ const updateOriginalPitchDataSectionMap = async () => {
const frameRate = editFrameRate.value; // f0(元のピッチ)は編集フレームレートで表示する
const singingGuidesValue = singingGuides.value;

let tempData: number[] = [];
const tempData: number[] = [];
for (const singingGuide of singingGuidesValue) {
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
// TODO: 補間を行うようにする
if (singingGuide.frameRate !== frameRate) {
Expand All @@ -287,10 +287,10 @@ const updateOriginalPitchDataSectionMap = async () => {
// 無声子音区間以外のf0をtempDataにコピーする
// NOTE: 無声子音区間は音程が無く、f0の値が大きく上下するので表示しない
if (tempData.length < endFrame) {
const arrayToConcat = new Array(endFrame - tempData.length).fill(
const valuesToPush = new Array(endFrame - tempData.length).fill(
VALUE_INDICATING_NO_DATA,
);
tempData = tempData.concat(arrayToConcat);
tempData.push(...valuesToPush);
}
for (let i = 0; i < f0.length; i++) {
const phoneme = framePhonemes[i];
Expand All @@ -312,20 +312,20 @@ const updatePitchEditDataSectionMap = async () => {
// 1次元のデータからデータ区間のマップを生成して、pitchEditDataSectionMapに設定する

const frameRate = editFrameRate.value;
const tempData = [...pitchEditData.value];

// プレビュー中のピッチ編集があれば、適用する
let tempData = [...pitchEditData.value];
if (previewPitchEdit.value != undefined) {
const previewPitchEditType = previewPitchEdit.value.type;
if (previewPitchEditType === "draw") {
const previewData = previewPitchEdit.value.data;
const previewStartFrame = previewPitchEdit.value.startFrame;
const previewEndFrame = previewStartFrame + previewData.length;
if (tempData.length < previewEndFrame) {
const arrayToConcat = new Array(previewEndFrame - tempData.length).fill(
const valuesToPush = new Array(previewEndFrame - tempData.length).fill(
VALUE_INDICATING_NO_DATA,
);
tempData = tempData.concat(arrayToConcat);
tempData.push(...valuesToPush);
}
for (let i = 0; i < previewData.length; i++) {
tempData[previewStartFrame + i] = previewData[i];
Expand Down
18 changes: 17 additions & 1 deletion src/sing/viewHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { StyleInfo } from "@/type/preload";
import { StyleInfo, isMac } from "@/type/preload";
import { calculateHash } from "@/sing/utility";

const BASE_X_PER_QUARTER_NOTE = 120;
Expand Down Expand Up @@ -202,3 +202,19 @@ export async function calculateFramewiseDataSectionHash(
const hash = await calculateHash(dataSection);
return framewiseDataSectionHashSchema.parse(hash);
}

export type MouseButton = "LEFT_BUTTON" | "RIGHT_BUTTON" | "OTHER_BUTTON";

export function getButton(event: MouseEvent): MouseButton {
// macOSの場合、Ctrl+クリックは右クリック
if (isMac && event.button === 0 && event.ctrlKey) {
return "RIGHT_BUTTON";
}
if (event.button === 0) {
return "LEFT_BUTTON";
} else if (event.button === 2) {
return "RIGHT_BUTTON";
} else {
return "OTHER_BUTTON";
}
}
14 changes: 5 additions & 9 deletions src/store/singing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,17 +524,15 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
{ data, startFrame }: { data: number[]; startFrame: number },
) {
const pitchEditData = state.tracks[selectedTrackIndex].pitchEditData;
let tempData = [...pitchEditData];
const tempData = [...pitchEditData];
const endFrame = startFrame + data.length;
if (tempData.length < endFrame) {
const arrayToConcat = new Array(endFrame - tempData.length).fill(
const valuesToPush = new Array(endFrame - tempData.length).fill(
VALUE_INDICATING_NO_DATA,
);
tempData = tempData.concat(arrayToConcat);
}
for (let i = 0; i < data.length; i++) {
tempData[startFrame + i] = data[i];
tempData.push(...valuesToPush);
}
tempData.splice(startFrame, data.length, ...data);
state.tracks[selectedTrackIndex].pitchEditData = tempData;
},
},
Expand All @@ -547,9 +545,7 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
const pitchEditData = state.tracks[selectedTrackIndex].pitchEditData;
const tempData = [...pitchEditData];
const endFrame = Math.min(startFrame + frameLength, tempData.length);
for (let i = startFrame; i < endFrame; i++) {
tempData[i] = VALUE_INDICATING_NO_DATA;
}
tempData.fill(VALUE_INDICATING_NO_DATA, startFrame, endFrame);
state.tracks[selectedTrackIndex].pitchEditData = tempData;
},
},
Expand Down
Loading