2023-02-14 23:02:51 +03:00
|
|
|
import { BufferSize, DownSamplingMode, F0Detector, Protocol, SampleRate, VoiceChangerMode } from "@dannadori/voice-changer-client-js"
|
2023-01-07 14:07:39 +03:00
|
|
|
import React, { useMemo, useState } from "react"
|
2023-01-12 17:01:45 +03:00
|
|
|
import { ClientState } from "@dannadori/voice-changer-client-js";
|
2023-01-10 18:59:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
export type UseAdvancedSettingProps = {
|
|
|
|
clientState: ClientState
|
|
|
|
}
|
2023-01-07 14:07:39 +03:00
|
|
|
|
|
|
|
export type AdvancedSettingState = {
|
|
|
|
advancedSetting: JSX.Element;
|
|
|
|
}
|
|
|
|
|
2023-01-10 18:59:09 +03:00
|
|
|
export const useAdvancedSetting = (props: UseAdvancedSettingProps): AdvancedSettingState => {
|
2023-01-12 11:23:57 +03:00
|
|
|
const [showAdvancedSetting, setShowAdvancedSetting] = useState<boolean>(false)
|
|
|
|
const mmvcServerUrlRow = useMemo(() => {
|
|
|
|
const onSetServerClicked = async () => {
|
|
|
|
const input = document.getElementById("mmvc-server-url") as HTMLInputElement
|
|
|
|
props.clientState.clientSetting.setServerUrl(input.value)
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div className="body-row split-3-3-4 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1">MMVC Server</div>
|
|
|
|
<div className="body-input-container">
|
|
|
|
<input type="text" defaultValue={props.clientState.clientSetting.setting.mmvcServerUrl} id="mmvc-server-url" className="body-item-input" />
|
|
|
|
</div>
|
|
|
|
<div className="body-button-container">
|
|
|
|
<div className="body-button" onClick={onSetServerClicked}>set</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}, [props.clientState.clientSetting.setting.mmvcServerUrl, props.clientState.clientSetting.setServerUrl])
|
|
|
|
|
2023-01-12 11:43:36 +03:00
|
|
|
const protocolRow = useMemo(() => {
|
|
|
|
const onProtocolChanged = async (val: Protocol) => {
|
|
|
|
props.clientState.clientSetting.setProtocol(val)
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1">Protocol</div>
|
|
|
|
<div className="body-select-container">
|
|
|
|
<select className="body-select" value={props.clientState.clientSetting.setting.protocol} onChange={(e) => {
|
|
|
|
onProtocolChanged(e.target.value as
|
|
|
|
Protocol)
|
|
|
|
}}>
|
|
|
|
{
|
|
|
|
Object.values(Protocol).map(x => {
|
|
|
|
return <option key={x} value={x}>{x}</option>
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}, [props.clientState.clientSetting.setting.protocol, props.clientState.clientSetting.setProtocol])
|
|
|
|
|
|
|
|
|
2023-01-12 11:23:57 +03:00
|
|
|
const sampleRateRow = useMemo(() => {
|
|
|
|
return (
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1">Sample Rate</div>
|
|
|
|
<div className="body-select-container">
|
|
|
|
<select className="body-select" value={props.clientState.clientSetting.setting.sampleRate} onChange={(e) => {
|
|
|
|
props.clientState.clientSetting.setSampleRate(Number(e.target.value) as SampleRate)
|
|
|
|
}}>
|
|
|
|
{
|
|
|
|
Object.values(SampleRate).map(x => {
|
|
|
|
return <option key={x} value={x}>{x}</option>
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}, [props.clientState.clientSetting.setting.sampleRate, props.clientState.clientSetting.setSampleRate])
|
|
|
|
|
|
|
|
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">
|
|
|
|
<select className="body-select" value={props.clientState.clientSetting.setting.bufferSize} onChange={(e) => {
|
|
|
|
props.clientState.clientSetting.setBufferSize(Number(e.target.value) as BufferSize)
|
|
|
|
}}>
|
|
|
|
{
|
|
|
|
Object.values(BufferSize).map(x => {
|
|
|
|
return <option key={x} value={x}>{x}</option>
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}, [props.clientState.clientSetting.setting.bufferSize, props.clientState.clientSetting.setBufferSize])
|
|
|
|
|
|
|
|
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">
|
|
|
|
<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))
|
|
|
|
}} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}, [props.clientState.serverSetting.setting.convertChunkNum, props.clientState.serverSetting.setConvertChunkNum])
|
|
|
|
|
2023-01-12 15:42:02 +03:00
|
|
|
const minConvertSizeRow = useMemo(() => {
|
|
|
|
return (
|
|
|
|
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1">Min Convert Size(byte)</div>
|
|
|
|
<div className="body-input-container">
|
|
|
|
<input type="number" min={0} max={8196} step={8196} value={props.clientState.serverSetting.setting.minConvertSize} onChange={(e) => {
|
|
|
|
props.clientState.serverSetting.setMinConvertSize(Number(e.target.value))
|
|
|
|
}} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}, [props.clientState.serverSetting.setting.minConvertSize, props.clientState.serverSetting.setMinConvertSize])
|
|
|
|
|
2023-01-12 11:23:57 +03: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">
|
|
|
|
<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))
|
|
|
|
}} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}, [props.clientState.serverSetting.setting.crossFadeOverlapRate, props.clientState.serverSetting.setCrossFadeOverlapRate])
|
|
|
|
|
|
|
|
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">
|
|
|
|
<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))
|
|
|
|
}} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}, [props.clientState.serverSetting.setting.crossFadeOffsetRate, props.clientState.serverSetting.setCrossFadeOffsetRate])
|
|
|
|
|
|
|
|
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">
|
|
|
|
<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))
|
|
|
|
}} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}, [props.clientState.serverSetting.setting.crossFadeEndRate, props.clientState.serverSetting.setCrossFadeEndRate])
|
|
|
|
|
2023-01-07 14:07:39 +03:00
|
|
|
|
|
|
|
const voiceChangeModeRow = useMemo(() => {
|
|
|
|
return (
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1 ">Voice Change Mode</div>
|
|
|
|
<div className="body-select-container">
|
2023-01-12 10:38:45 +03:00
|
|
|
<select className="body-select" value={props.clientState.clientSetting.setting.voiceChangerMode} onChange={(e) => {
|
|
|
|
props.clientState.clientSetting.setVoiceChangerMode(e.target.value as VoiceChangerMode)
|
2023-01-10 18:59:09 +03:00
|
|
|
}}>
|
2023-01-07 14:07:39 +03:00
|
|
|
{
|
|
|
|
Object.values(VoiceChangerMode).map(x => {
|
|
|
|
return <option key={x} value={x}>{x}</option>
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-01-12 10:38:45 +03:00
|
|
|
}, [props.clientState.clientSetting.setting.voiceChangerMode, props.clientState.clientSetting.setVoiceChangerMode])
|
2023-01-07 14:07:39 +03:00
|
|
|
|
2023-01-11 22:52:01 +03:00
|
|
|
|
2023-02-14 16:32:25 +03:00
|
|
|
const downSamplingModeRow = useMemo(() => {
|
|
|
|
return (
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1 ">DownSamplingMode</div>
|
|
|
|
<div className="body-select-container">
|
|
|
|
<select className="body-select" value={props.clientState.clientSetting.setting.downSamplingMode} onChange={(e) => {
|
|
|
|
props.clientState.clientSetting.setDownSamplingMode(e.target.value as DownSamplingMode)
|
|
|
|
}}>
|
|
|
|
{
|
|
|
|
Object.values(DownSamplingMode).map(x => {
|
|
|
|
return <option key={x} value={x}>{x}</option>
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}, [props.clientState.clientSetting.setting.downSamplingMode, props.clientState.clientSetting.setDownSamplingMode])
|
|
|
|
|
|
|
|
|
2023-01-11 22:52:01 +03:00
|
|
|
const workletSettingRow = useMemo(() => {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1">Trancate Num</div>
|
|
|
|
<div className="body-input-container">
|
2023-02-12 12:50:10 +03:00
|
|
|
<input type="number" min={5} max={300} step={1} value={props.clientState.workletSetting.setting.numTrancateTreshold} onChange={(e) => {
|
2023-01-11 22:52:01 +03:00
|
|
|
props.clientState.workletSetting.setSetting({
|
|
|
|
...props.clientState.workletSetting.setting,
|
|
|
|
numTrancateTreshold: Number(e.target.value)
|
|
|
|
})
|
|
|
|
}} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-02-12 11:07:28 +03:00
|
|
|
{/* v.1.5.xより Silent skipは廃止 */}
|
|
|
|
{/* <div className="body-row split-3-7 left-padding-1 guided">
|
2023-01-11 22:52:01 +03:00
|
|
|
<div className="body-item-title left-padding-1">Trancate Vol</div>
|
|
|
|
<div className="body-input-container">
|
|
|
|
<input type="number" min={0.0001} max={0.0009} step={0.0001} value={props.clientState.workletSetting.setting.volTrancateThreshold} onChange={(e) => {
|
|
|
|
props.clientState.workletSetting.setSetting({
|
|
|
|
...props.clientState.workletSetting.setting,
|
|
|
|
volTrancateThreshold: Number(e.target.value)
|
|
|
|
})
|
|
|
|
}} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1">Trancate Vol Length</div>
|
|
|
|
<div className="body-input-container">
|
|
|
|
<input type="number" min={16} max={128} step={1} value={props.clientState.workletSetting.setting.volTrancateLength} onChange={(e) => {
|
|
|
|
props.clientState.workletSetting.setSetting({
|
|
|
|
...props.clientState.workletSetting.setting,
|
|
|
|
volTrancateLength: Number(e.target.value)
|
|
|
|
})
|
|
|
|
}} />
|
|
|
|
</div>
|
2023-02-12 11:07:28 +03:00
|
|
|
</div> */}
|
2023-01-12 11:23:57 +03:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}, [props.clientState.workletSetting.setting, props.clientState.workletSetting.setSetting])
|
2023-01-11 22:52:01 +03:00
|
|
|
|
|
|
|
|
2023-01-12 11:23:57 +03:00
|
|
|
const advanceSettingContent = useMemo(() => {
|
|
|
|
if (!showAdvancedSetting) return <></>
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="body-row divider"></div>
|
|
|
|
{mmvcServerUrlRow}
|
2023-01-12 11:43:36 +03:00
|
|
|
{protocolRow}
|
2023-01-12 11:23:57 +03:00
|
|
|
<div className="body-row divider"></div>
|
|
|
|
{sampleRateRow}
|
|
|
|
{bufferSizeRow}
|
|
|
|
<div className="body-row divider"></div>
|
|
|
|
|
|
|
|
{convertChunkNumRow}
|
2023-01-12 15:42:02 +03:00
|
|
|
{minConvertSizeRow}
|
2023-01-12 11:23:57 +03:00
|
|
|
{crossFadeOverlapRateRow}
|
|
|
|
{crossFadeOffsetRateRow}
|
|
|
|
{crossFadeEndRateRow}
|
|
|
|
<div className="body-row divider"></div>
|
|
|
|
{voiceChangeModeRow}
|
|
|
|
<div className="body-row divider"></div>
|
|
|
|
{workletSettingRow}
|
|
|
|
<div className="body-row divider"></div>
|
2023-02-14 16:32:25 +03:00
|
|
|
{downSamplingModeRow}
|
2023-02-14 23:02:51 +03:00
|
|
|
|
2023-01-11 22:52:01 +03:00
|
|
|
</>
|
|
|
|
)
|
2023-02-14 23:02:51 +03:00
|
|
|
}, [showAdvancedSetting, mmvcServerUrlRow, protocolRow, sampleRateRow, bufferSizeRow, convertChunkNumRow, minConvertSizeRow, crossFadeOverlapRateRow, crossFadeOffsetRateRow, crossFadeEndRateRow, voiceChangeModeRow, workletSettingRow, downSamplingModeRow])
|
2023-01-11 22:52:01 +03:00
|
|
|
|
|
|
|
|
2023-01-07 14:07:39 +03:00
|
|
|
const advancedSetting = useMemo(() => {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="body-row split-3-7 left-padding-1">
|
|
|
|
<div className="body-sub-section-title">Advanced Setting</div>
|
2023-01-12 11:23:57 +03:00
|
|
|
<div>
|
|
|
|
<input type="checkbox" checked={showAdvancedSetting} onChange={(e) => {
|
|
|
|
setShowAdvancedSetting(e.target.checked)
|
|
|
|
}} /> show
|
2023-01-07 14:07:39 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-12 11:23:57 +03:00
|
|
|
{advanceSettingContent}
|
2023-01-07 14:07:39 +03:00
|
|
|
</>
|
|
|
|
)
|
2023-01-12 11:23:57 +03:00
|
|
|
}, [showAdvancedSetting, advanceSettingContent])
|
2023-01-07 14:07:39 +03:00
|
|
|
|
|
|
|
return {
|
|
|
|
advancedSetting,
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|