2023-01-12 16:38:45 +09:00
|
|
|
import { BufferSize } from "@dannadori/voice-changer-client-js"
|
2023-01-07 20:07:39 +09:00
|
|
|
import React, { useMemo, useState } from "react"
|
2023-01-11 00:59:09 +09:00
|
|
|
import { ClientState } from "./hooks/useClient"
|
2023-01-07 20:07:39 +09:00
|
|
|
|
2023-01-11 00:59:09 +09:00
|
|
|
export type UseConvertSettingProps = {
|
|
|
|
clientState: ClientState
|
2023-01-07 20:07:39 +09:00
|
|
|
}
|
|
|
|
|
2023-01-11 00:59:09 +09:00
|
|
|
export type ConvertSettingState = {
|
|
|
|
convertSetting: JSX.Element;
|
|
|
|
}
|
2023-01-07 20:07:39 +09:00
|
|
|
|
2023-01-11 00:59:09 +09:00
|
|
|
export const useConvertSetting = (props: UseConvertSettingProps): ConvertSettingState => {
|
2023-01-07 20:07:39 +09:00
|
|
|
|
|
|
|
const bufferSizeRow = useMemo(() => {
|
|
|
|
return (
|
|
|
|
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1">Buffer Size</div>
|
|
|
|
<div className="body-select-container">
|
2023-01-12 16:38:45 +09:00
|
|
|
<select className="body-select" value={props.clientState.clientSetting.setting.bufferSize} onChange={(e) => {
|
|
|
|
props.clientState.clientSetting.setBufferSize(Number(e.target.value) as BufferSize)
|
2023-01-11 00:59:09 +09:00
|
|
|
}}>
|
2023-01-07 20:07:39 +09:00
|
|
|
{
|
|
|
|
Object.values(BufferSize).map(x => {
|
|
|
|
return <option key={x} value={x}>{x}</option>
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-01-12 16:38:45 +09:00
|
|
|
}, [props.clientState.clientSetting.setting.bufferSize, props.clientState.clientSetting.setBufferSize])
|
2023-01-07 20:07:39 +09:00
|
|
|
|
|
|
|
const inputChunkNumRow = useMemo(() => {
|
|
|
|
return (
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1">Input Chunk Num(128sample/chunk)</div>
|
|
|
|
<div className="body-input-container">
|
2023-01-12 16:38:45 +09:00
|
|
|
<input type="number" min={1} max={256} step={1} value={props.clientState.clientSetting.setting.inputChunkNum} onChange={(e) => {
|
|
|
|
props.clientState.clientSetting.setInputChunkNum(Number(e.target.value))
|
2023-01-11 00:59:09 +09:00
|
|
|
}} />
|
2023-01-07 20:07:39 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-01-12 16:38:45 +09:00
|
|
|
}, [props.clientState.clientSetting.setting.inputChunkNum, props.clientState.clientSetting.setInputChunkNum])
|
2023-01-07 20:07:39 +09:00
|
|
|
|
|
|
|
const convertChunkNumRow = useMemo(() => {
|
|
|
|
return (
|
|
|
|
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1">Convert Chunk Num(128sample/chunk)</div>
|
|
|
|
<div className="body-input-container">
|
2023-01-12 16:38:45 +09:00
|
|
|
<input type="number" min={1} max={256} step={1} value={props.clientState.serverSetting.setting.convertChunkNum} onChange={(e) => {
|
|
|
|
props.clientState.serverSetting.setConvertChunkNum(Number(e.target.value))
|
2023-01-11 00:59:09 +09:00
|
|
|
}} />
|
2023-01-07 20:07:39 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-01-12 16:38:45 +09:00
|
|
|
}, [props.clientState.serverSetting.setting.convertChunkNum, props.clientState.serverSetting.setConvertChunkNum])
|
2023-01-07 20:07:39 +09:00
|
|
|
|
|
|
|
const gpuRow = useMemo(() => {
|
|
|
|
return (
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1">GPU</div>
|
|
|
|
<div className="body-input-container">
|
2023-01-12 16:38:45 +09:00
|
|
|
<input type="number" min={-2} max={5} step={1} value={props.clientState.serverSetting.setting.gpu} onChange={(e) => {
|
|
|
|
props.clientState.serverSetting.setGpu(Number(e.target.value))
|
2023-01-11 00:59:09 +09:00
|
|
|
}} />
|
2023-01-07 20:07:39 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-01-12 16:38:45 +09:00
|
|
|
}, [props.clientState.serverSetting.setting.gpu, props.clientState.serverSetting.setGpu])
|
2023-01-07 20:07:39 +09:00
|
|
|
|
2023-01-12 01:05:38 +09:00
|
|
|
const crossFadeOverlapRateRow = useMemo(() => {
|
|
|
|
return (
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1">Cross Fade Overlap Rate</div>
|
|
|
|
<div className="body-input-container">
|
2023-01-12 16:38:45 +09:00
|
|
|
<input type="number" min={0.1} max={1} step={0.1} value={props.clientState.serverSetting.setting.crossFadeOverlapRate} onChange={(e) => {
|
|
|
|
props.clientState.serverSetting.setCrossFadeOverlapRate(Number(e.target.value))
|
2023-01-12 01:05:38 +09:00
|
|
|
}} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-01-12 16:38:45 +09:00
|
|
|
}, [props.clientState.serverSetting.setting.crossFadeOverlapRate, props.clientState.serverSetting.setCrossFadeOverlapRate])
|
2023-01-12 01:05:38 +09:00
|
|
|
|
2023-01-07 20:07:39 +09:00
|
|
|
const crossFadeOffsetRateRow = useMemo(() => {
|
|
|
|
return (
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1">Cross Fade Offset Rate</div>
|
|
|
|
<div className="body-input-container">
|
2023-01-12 16:38:45 +09:00
|
|
|
<input type="number" min={0} max={1} step={0.1} value={props.clientState.serverSetting.setting.crossFadeOffsetRate} onChange={(e) => {
|
|
|
|
props.clientState.serverSetting.setCrossFadeOffsetRate(Number(e.target.value))
|
2023-01-11 00:59:09 +09:00
|
|
|
}} />
|
2023-01-07 20:07:39 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-01-12 16:38:45 +09:00
|
|
|
}, [props.clientState.serverSetting.setting.crossFadeOffsetRate, props.clientState.serverSetting.setCrossFadeOffsetRate])
|
2023-01-07 20:07:39 +09:00
|
|
|
|
|
|
|
const crossFadeEndRateRow = useMemo(() => {
|
|
|
|
return (
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1">Cross Fade End Rate</div>
|
|
|
|
<div className="body-input-container">
|
2023-01-12 16:38:45 +09:00
|
|
|
<input type="number" min={0} max={1} step={0.1} value={props.clientState.serverSetting.setting.crossFadeEndRate} onChange={(e) => {
|
|
|
|
props.clientState.serverSetting.setCrossFadeEndRate(Number(e.target.value))
|
2023-01-11 00:59:09 +09:00
|
|
|
}} />
|
2023-01-07 20:07:39 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-01-12 16:38:45 +09:00
|
|
|
}, [props.clientState.serverSetting.setting.crossFadeEndRate, props.clientState.serverSetting.setCrossFadeEndRate])
|
2023-01-07 20:07:39 +09:00
|
|
|
|
|
|
|
const convertSetting = useMemo(() => {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="body-row split-3-7 left-padding-1">
|
|
|
|
<div className="body-sub-section-title">Converter Setting</div>
|
|
|
|
<div className="body-select-container">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{bufferSizeRow}
|
|
|
|
{inputChunkNumRow}
|
|
|
|
{convertChunkNumRow}
|
|
|
|
{gpuRow}
|
2023-01-12 01:05:38 +09:00
|
|
|
{crossFadeOverlapRateRow}
|
2023-01-07 20:07:39 +09:00
|
|
|
{crossFadeOffsetRateRow}
|
|
|
|
{crossFadeEndRateRow}
|
|
|
|
</>
|
|
|
|
)
|
2023-01-12 01:05:38 +09:00
|
|
|
}, [bufferSizeRow, inputChunkNumRow, convertChunkNumRow, gpuRow, crossFadeOverlapRateRow, crossFadeOffsetRateRow, crossFadeEndRateRow])
|
2023-01-07 20:07:39 +09:00
|
|
|
|
|
|
|
return {
|
|
|
|
convertSetting,
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|