Skip to content

Commit

Permalink
#986 指摘点修正他
Browse files Browse the repository at this point in the history
  • Loading branch information
Romot committed Jan 16, 2023
1 parent af5b7d2 commit 6b8f301
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 41 deletions.
7 changes: 5 additions & 2 deletions src/components/Sing/ScoreSequencer.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="score-sequencer" id="score-sequencer">
<div class="score-sequencer">
<div class="sequencer-keys">
<div
v-for="y in gridY"
Expand All @@ -16,7 +16,7 @@
{{ y.pitch === "C" ? y.name : "" }}
</div>
</div>
<div class="sequencer-grids" ref="sequencer-grids">
<div class="sequencer-grids">
<div
v-for="x in gridX"
:key="x"
Expand All @@ -39,6 +39,7 @@
}"
/>
</div>
<!-- NOTE: ノートと歌詞入力あわせコンポーネント分割予定 -->
<div
v-for="(note, index) in notes"
:key="index"
Expand All @@ -60,6 +61,7 @@
<div class="sequencer-note-bar" />
</div>
</div>
<!-- NOTE: スクロールバー+ズームレンジ仮 -->
<input
type="range"
min="0.1"
Expand Down Expand Up @@ -153,6 +155,7 @@ export default defineComponent({
store.dispatch("REMOVE_NOTE", { index });
};
// NOTE: ノートのバーと歌詞入力でコンポーネント分割予定
const setLyric = (index: number, event: Event) => {
if (!(event.target instanceof HTMLInputElement)) {
return;
Expand Down
6 changes: 1 addition & 5 deletions src/helpers/singHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function getDoremiFromMidi(midi: number): string {
"ソ",
"ラ",
"ラ",
"",
"",
];
const pitchPos = midi % 12;
return mapPitches[pitchPos];
Expand Down Expand Up @@ -61,7 +61,3 @@ export const midiKeys = [...Array(128)]
};
})
.reverse();

export function getDisplayKey(midi: number): object {
return midiKeys[midi];
}
23 changes: 4 additions & 19 deletions src/store/singing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Note,
SingingStoreState,
SingingStoreTypes,
commandMutationsCreator,
} from "./type";
import { createPartialStore } from "./vuex";
import { createUILockAction } from "./ui";
Expand All @@ -14,23 +15,7 @@ import { getDoremiFromMidi } from "@/helpers/singHelper";
export const singingStoreState: SingingStoreState = {
engineId: undefined,
styleId: undefined,
score: {
resolution: 480,
tempos: [
{
position: 0,
tempo: 120,
},
],
timeSignatures: [
{
position: 0,
beats: 4,
beatType: 4,
},
],
notes: [],
},
score: undefined,
renderPhrases: [],
// NOTE: UIの状態は試行のためsinging.tsに局所化する+Hydrateが必要
isShowSinger: true,
Expand Down Expand Up @@ -276,8 +261,8 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
ADD_NOTE: {
mutation(state, { note }: { note: Note }) {
if (state.score) {
const notes = [...state.score.notes].concat(note).sort((a, b) => {
return a.position < b.position ? -1 : 1;
const notes = state.score.notes.concat(note).sort((a, b) => {
return a.position - b.position;
});
state.score.notes = notes;
}
Expand Down
19 changes: 5 additions & 14 deletions src/views/SingerHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,13 @@ export default defineComponent({
// 歌声合成エディターの初期化
onMounted(async () => {
if (store.state.score === undefined) {
const emptyScore = await store.dispatch("GET_EMPTY_SCORE");
await store.dispatch("SET_SCORE", { score: emptyScore });
}
await store.dispatch("SET_SINGER", {});
const score = await store.dispatch("GET_EMPTY_SCORE");
// 実装時の確認用です TODO: 必要なくなったら削除
score.notes = [
{ position: 0, duration: 480, midi: 60, lyric: "" },
{ position: 480, duration: 480, midi: 62, lyric: "" },
{ position: 960, duration: 480, midi: 64, lyric: "" },
{ position: 1440, duration: 480, midi: 65, lyric: "" },
{ position: 1920, duration: 1920, midi: 67, lyric: "" },
];
await store.dispatch("SET_SCORE", { score });
return {};
});
return null;
},
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/store/Vuex.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe("store/vuex.js test", () => {
sequencerZoomX: 1,
sequencerZoomY: 1,
sequencerScrollX: 0,
sequencerScrollY: 60,
sequencerScrollY: 60,
},
getters: {
...uiStore.getters,
Expand Down

0 comments on commit 6b8f301

Please sign in to comment.