Skip to content

Commit

Permalink
フレーズレンダラーを追加、リファクタリング
Browse files Browse the repository at this point in the history
  • Loading branch information
sigprogramming committed Aug 24, 2024
1 parent ccba185 commit 6c74724
Show file tree
Hide file tree
Showing 7 changed files with 1,129 additions and 655 deletions.
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,
});
}
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

0 comments on commit 6c74724

Please sign in to comment.