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

ソング:フレーズのレンダリング処理をリファクタリング #2248

Merged
merged 15 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
9 changes: 7 additions & 2 deletions src/components/Sing/SequencerPhraseIndicator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
import { computed } from "vue";
import { useStore } from "@/store";
import { getOrThrow } from "@/helpers/mapHelper";
import { PhraseSourceHash, PhraseState } from "@/store/type";
import { PhraseKey, PhraseState } from "@/store/type";

const props = defineProps<{
phraseKey: PhraseSourceHash;
phraseKey: PhraseKey;
isInSelectedTrack: boolean;
}>();

const store = useStore();
const classNames: Record<PhraseState, string> = {
SINGER_IS_NOT_SET: "singer-is-not-set",
WAITING_TO_BE_RENDERED: "waiting-to-be-rendered",
NOW_RENDERING: "now-rendering",
COULD_NOT_RENDER: "could-not-render",
Expand Down Expand Up @@ -43,6 +44,10 @@ const className = computed(() => {
}
}

.singer-is-not-set {
visibility: hidden;
}

.waiting-to-be-rendered {
@include tint-if-in-other-track(
"background-color",
Expand Down
25 changes: 18 additions & 7 deletions src/components/Sing/SequencerPitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { ExhaustiveError } from "@/type/utility";
import { createLogger } from "@/domain/frontend/log";
import { getLast } from "@/sing/utility";
import { getOrThrow } from "@/helpers/mapHelper";
import { FrameAudioQuery } from "@/openapi";

type PitchLine = {
readonly color: Color;
Expand Down Expand Up @@ -57,19 +58,29 @@ const previewPitchEdit = computed(() => props.previewPitchEdit);
const selectedTrackId = computed(() => store.getters.SELECTED_TRACK_ID);
const editFrameRate = computed(() => store.state.editFrameRate);
const singingGuidesInSelectedTrack = computed(() => {
const singingGuides = [];
const singingGuides: {
query: FrameAudioQuery;
frameRate: number;
startTime: number;
}[] = [];
for (const phrase of store.state.phrases.values()) {
if (phrase.trackId !== selectedTrackId.value) {
continue;
}
if (phrase.singingGuideKey == undefined) {
if (phrase.queryKey == undefined) {
continue;
}
const singingGuide = getOrThrow(
store.state.singingGuides,
phrase.singingGuideKey,
);
singingGuides.push(singingGuide);
const track = store.state.tracks.get(phrase.trackId);
if (track == undefined || track.singer == undefined) {
continue;
}
const phraseQuery = getOrThrow(store.state.phraseQueries, phrase.queryKey);
const engineManifest = store.state.engineManifests[track.singer.engineId];
singingGuides.push({
startTime: phrase.startTime,
query: phraseQuery,
frameRate: engineManifest.frameRate,
});
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
}
return singingGuides;
});
Expand Down
33 changes: 9 additions & 24 deletions src/sing/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ import {
Note,
Phrase,
PhraseSource,
SingingGuide,
SingingGuideSource,
SingingVoiceSource,
Tempo,
TimeSignature,
phraseSourceHashSchema,
PhraseKey,
Track,
singingGuideSourceHashSchema,
singingVoiceSourceHashSchema,
} from "@/store/type";
import { FramePhoneme } from "@/openapi";
import { FrameAudioQuery, FramePhoneme } from "@/openapi";
import { TrackId } from "@/type/preload";

const BEAT_TYPES = [2, 4, 8, 16];
Expand Down Expand Up @@ -379,23 +374,9 @@ export function isValidPitchEditData(pitchEditData: number[]) {
);
}

export const calculatePhraseSourceHash = async (phraseSource: PhraseSource) => {
export const calculatePhraseKey = async (phraseSource: PhraseSource) => {
const hash = await calculateHash(phraseSource);
return phraseSourceHashSchema.parse(hash);
};

export const calculateSingingGuideSourceHash = async (
singingGuideSource: SingingGuideSource,
) => {
const hash = await calculateHash(singingGuideSource);
return singingGuideSourceHashSchema.parse(hash);
};

export const calculateSingingVoiceSourceHash = async (
singingVoiceSource: SingingVoiceSource,
) => {
const hash = await calculateHash(singingVoiceSource);
return singingVoiceSourceHashSchema.parse(hash);
return PhraseKey(hash);
};

export function getStartTicksOfPhrase(phrase: Phrase) {
Expand Down Expand Up @@ -469,7 +450,11 @@ export function convertToFramePhonemes(phonemes: FramePhoneme[]) {
}

export function applyPitchEdit(
singingGuide: SingingGuide,
singingGuide: {
query: FrameAudioQuery;
frameRate: number;
startTime: number;
},
pitchEditData: number[],
editFrameRate: number,
) {
Expand Down
Loading
Loading