Skip to content

Commit

Permalink
EditorFrameAudioQueryを使うようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
sigprogramming committed Sep 3, 2024
1 parent c09eb5f commit e035919
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
16 changes: 7 additions & 9 deletions src/sing/phraseRendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ import {
EditorFrameAudioQueryKey,
EditorFrameAudioQuery,
} from "@/store/type";
import {
FrameAudioQuery,
FramePhoneme,
Note as NoteForRequestToEngine,
} from "@/openapi";
import { FramePhoneme, Note as NoteForRequestToEngine } from "@/openapi";
import { applyPitchEdit, decibelToLinear, tickToSecond } from "@/sing/domain";
import { calculateHash, linearInterpolation } from "@/sing/utility";
import { EngineId, StyleId, TrackId } from "@/type/preload";
Expand Down Expand Up @@ -235,17 +231,18 @@ type ExternalDependencies = Readonly<{

fetchQuery: (
engineId: EngineId,
engineFrameRate: number,
notes: NoteForRequestToEngine[],
) => Promise<FrameAudioQuery>;
) => Promise<EditorFrameAudioQuery>;
fetchSingFrameVolume: (
notes: NoteForRequestToEngine[],
query: FrameAudioQuery,
query: EditorFrameAudioQuery,
engineId: EngineId,
styleId: StyleId,
) => Promise<SingingVolume>;
synthesizeSingingVoice: (
singer: Singer,
query: FrameAudioQuery,
query: EditorFrameAudioQuery,
) => Promise<SingingVoice>;
}>;

Expand Down Expand Up @@ -351,11 +348,12 @@ const generateQuery = async (

const query = await externalDependencies.fetchQuery(
querySource.engineId,
querySource.engineFrameRate,
notesForRequestToEngine,
);

shiftPitch(query.f0, querySource.keyRangeAdjustment);
return { ...query, frameRate: querySource.engineFrameRate };
return query;
};

const queryGenerationStage: BaseStage = {
Expand Down
20 changes: 13 additions & 7 deletions src/store/singing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
StyleId,
TrackId,
} from "@/type/preload";
import { FrameAudioQuery, Note as NoteForRequestToEngine } from "@/openapi";
import { Note as NoteForRequestToEngine } from "@/openapi";
import { ResultError, getValueOrThrow } from "@/type/result";
import {
AudioEvent,
Expand Down Expand Up @@ -1443,6 +1443,7 @@ export const singingStore = createPartialStore<SingingStoreTypes>({

const fetchQuery = async (
engineId: EngineId,
engineFrameRate: number,
notesForRequestToEngine: NoteForRequestToEngine[],
) => {
try {
Expand All @@ -1452,12 +1453,17 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
const instance = await actions.INSTANTIATE_ENGINE_CONNECTOR({
engineId,
});
return await instance.invoke(
const query = await instance.invoke(
"singFrameAudioQuerySingFrameAudioQueryPost",
)({
score: { notes: notesForRequestToEngine },
speaker: singingTeacherStyleId,
});
const editorQuery: EditorFrameAudioQuery = {
...query,
frameRate: engineFrameRate,
};
return editorQuery;
} catch (error) {
const lyrics = notesForRequestToEngine
.map((value) => value.lyric)
Expand All @@ -1472,7 +1478,7 @@ export const singingStore = createPartialStore<SingingStoreTypes>({

const synthesizeSingingVoice = async (
singer: Singer,
query: FrameAudioQuery,
query: EditorFrameAudioQuery,
) => {
if (!getters.IS_ENGINE_READY(singer.engineId)) {
throw new Error("Engine not ready.");
Expand Down Expand Up @@ -1617,7 +1623,7 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
fetchSingFrameVolume: (notes, query, engineId, styleId) =>
actions.FETCH_SING_FRAME_VOLUME({
notes,
frameAudioQuery: query,
query,
engineId,
styleId,
}),
Expand Down Expand Up @@ -1868,12 +1874,12 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
{ actions },
{
notes,
frameAudioQuery,
query,
engineId,
styleId,
}: {
notes: NoteForRequestToEngine[];
frameAudioQuery: FrameAudioQuery;
query: EditorFrameAudioQuery;
engineId: EngineId;
styleId: StyleId;
},
Expand All @@ -1886,7 +1892,7 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
score: {
notes,
},
frameAudioQuery,
frameAudioQuery: query,
},
speaker: styleId,
});
Expand Down
2 changes: 1 addition & 1 deletion src/store/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ export type SingingStoreTypes = {
FETCH_SING_FRAME_VOLUME: {
action(palyoad: {
notes: NoteForRequestToEngine[];
frameAudioQuery: FrameAudioQuery;
query: EditorFrameAudioQuery;
engineId: EngineId;
styleId: StyleId;
}): Promise<number[]>;
Expand Down

0 comments on commit e035919

Please sign in to comment.