2023-02-19 20:28:56 +03:00
|
|
|
import { CrossFadeOverlapSize, DownSamplingMode, InputSampleRate, Protocol, SampleRate } from "@dannadori/voice-changer-client-js"
|
2023-02-18 14:53:15 +03:00
|
|
|
import React, { useMemo } from "react"
|
2023-02-16 18:09:56 +03:00
|
|
|
import { useAppState } from "./001_provider/001_AppStateProvider";
|
|
|
|
import { AnimationTypes, HeaderButton, HeaderButtonProps } from "./components/101_HeaderButton";
|
2023-01-07 14:07:39 +03:00
|
|
|
|
|
|
|
export type AdvancedSettingState = {
|
|
|
|
advancedSetting: JSX.Element;
|
|
|
|
}
|
|
|
|
|
2023-02-16 18:09:56 +03:00
|
|
|
export const useAdvancedSetting = (): AdvancedSettingState => {
|
|
|
|
const appState = useAppState()
|
|
|
|
const accodionButton = useMemo(() => {
|
|
|
|
const accodionButtonProps: HeaderButtonProps = {
|
|
|
|
stateControlCheckbox: appState.frontendManagerState.stateControls.openAdvancedSettingCheckbox,
|
|
|
|
tooltip: "Open/Close",
|
|
|
|
onIcon: ["fas", "caret-up"],
|
|
|
|
offIcon: ["fas", "caret-up"],
|
|
|
|
animation: AnimationTypes.spinner,
|
|
|
|
tooltipClass: "tooltip-right",
|
|
|
|
};
|
|
|
|
return <HeaderButton {...accodionButtonProps}></HeaderButton>;
|
|
|
|
}, []);
|
|
|
|
|
2023-01-12 11:23:57 +03:00
|
|
|
const mmvcServerUrlRow = useMemo(() => {
|
|
|
|
const onSetServerClicked = async () => {
|
|
|
|
const input = document.getElementById("mmvc-server-url") as HTMLInputElement
|
2023-02-16 18:09:56 +03:00
|
|
|
appState.clientSetting.setServerUrl(input.value)
|
2023-01-12 11:23:57 +03:00
|
|
|
}
|
|
|
|
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">
|
2023-02-19 20:21:51 +03:00
|
|
|
<input type="text" defaultValue={appState.workletNodeSetting.workletNodeSetting.serverUrl} id="mmvc-server-url" className="body-item-input" />
|
2023-01-12 11:23:57 +03:00
|
|
|
</div>
|
|
|
|
<div className="body-button-container">
|
|
|
|
<div className="body-button" onClick={onSetServerClicked}>set</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-02-19 20:21:51 +03:00
|
|
|
}, [appState.workletNodeSetting.workletNodeSetting.serverUrl, appState.clientSetting.setServerUrl])
|
2023-01-12 11:23:57 +03:00
|
|
|
|
2023-01-12 11:43:36 +03:00
|
|
|
const protocolRow = useMemo(() => {
|
|
|
|
const onProtocolChanged = async (val: Protocol) => {
|
2023-02-19 20:21:51 +03:00
|
|
|
appState.workletNodeSetting.updateWorkletNodeSetting({ ...appState.workletNodeSetting.workletNodeSetting, protocol: val })
|
2023-01-12 11:43:36 +03:00
|
|
|
}
|
|
|
|
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">
|
2023-02-19 20:21:51 +03:00
|
|
|
<select className="body-select" value={appState.workletNodeSetting.workletNodeSetting.protocol} onChange={(e) => {
|
2023-01-12 11:43:36 +03:00
|
|
|
onProtocolChanged(e.target.value as
|
|
|
|
Protocol)
|
|
|
|
}}>
|
|
|
|
{
|
|
|
|
Object.values(Protocol).map(x => {
|
|
|
|
return <option key={x} value={x}>{x}</option>
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-02-19 20:21:51 +03:00
|
|
|
}, [appState.workletNodeSetting.workletNodeSetting.protocol, appState.workletNodeSetting.updateWorkletNodeSetting])
|
2023-01-12 11:43:36 +03:00
|
|
|
|
|
|
|
|
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">
|
2023-02-19 08:20:37 +03:00
|
|
|
<select className="body-select" value={appState.clientSetting.clientSetting.sampleRate} onChange={(e) => {
|
|
|
|
appState.clientSetting.updateClientSetting({ ...appState.clientSetting.clientSetting, sampleRate: Number(e.target.value) as SampleRate })
|
2023-01-12 11:23:57 +03:00
|
|
|
}}>
|
|
|
|
{
|
|
|
|
Object.values(SampleRate).map(x => {
|
|
|
|
return <option key={x} value={x}>{x}</option>
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-02-19 08:20:37 +03:00
|
|
|
}, [appState.clientSetting.clientSetting.sampleRate, appState.clientSetting.updateClientSetting])
|
2023-01-12 11:23:57 +03:00
|
|
|
|
2023-02-18 14:53:15 +03:00
|
|
|
const sendingSampleRateRow = useMemo(() => {
|
|
|
|
return (
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1">Sending Sample Rate</div>
|
|
|
|
<div className="body-select-container">
|
2023-02-19 20:21:51 +03:00
|
|
|
<select className="body-select" value={appState.workletNodeSetting.workletNodeSetting.sendingSampleRate} onChange={(e) => {
|
|
|
|
appState.workletNodeSetting.updateWorkletNodeSetting({ ...appState.workletNodeSetting.workletNodeSetting, sendingSampleRate: Number(e.target.value) as InputSampleRate })
|
2023-02-19 04:12:25 +03:00
|
|
|
appState.serverSetting.updateServerSettings({ ...appState.serverSetting.serverSetting, inputSampleRate: Number(e.target.value) as InputSampleRate })
|
2023-02-18 14:53:15 +03:00
|
|
|
}}>
|
|
|
|
{
|
|
|
|
Object.values(InputSampleRate).map(x => {
|
|
|
|
return <option key={x} value={x}>{x}</option>
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-02-19 20:21:51 +03:00
|
|
|
}, [appState.workletNodeSetting.workletNodeSetting.sendingSampleRate, appState.workletNodeSetting.updateWorkletNodeSetting, appState.serverSetting.updateServerSettings])
|
2023-02-18 14:53:15 +03:00
|
|
|
|
2023-02-19 00:25:22 +03:00
|
|
|
const crossFadeOverlapSizeRow = useMemo(() => {
|
|
|
|
return (
|
|
|
|
<div className="body-row split-3-7 left-padding-1 guided">
|
|
|
|
<div className="body-item-title left-padding-1">Cross Fade Overlap Size</div>
|
|
|
|
<div className="body-select-container">
|
2023-02-19 04:12:25 +03:00
|
|
|
<select className="body-select" value={appState.serverSetting.serverSetting.crossFadeOverlapSize} onChange={(e) => {
|
|
|
|
appState.serverSetting.updateServerSettings({ ...appState.serverSetting.serverSetting, crossFadeOverlapSize: Number(e.target.value) as CrossFadeOverlapSize })
|
2023-02-19 00:25:22 +03:00
|
|
|
}}>
|
|
|
|
{
|
|
|
|
Object.values(CrossFadeOverlapSize).map(x => {
|
|
|
|
return <option key={x} value={x}>{x}</option>
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-02-19 04:12:25 +03:00
|
|
|
}, [appState.serverSetting.serverSetting.crossFadeOverlapSize, appState.serverSetting.updateServerSettings])
|
2023-02-19 00:25:22 +03:00
|
|
|
|
2023-01-12 11:23:57 +03: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-02-19 04:12:25 +03:00
|
|
|
<input type="number" min={0} max={1} step={0.1} value={appState.serverSetting.serverSetting.crossFadeOffsetRate} onChange={(e) => {
|
|
|
|
appState.serverSetting.updateServerSettings({ ...appState.serverSetting.serverSetting, crossFadeOffsetRate: Number(e.target.value) })
|
2023-01-12 11:23:57 +03:00
|
|
|
}} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-02-19 04:12:25 +03:00
|
|
|
}, [appState.serverSetting.serverSetting.crossFadeOffsetRate, appState.serverSetting.updateServerSettings])
|
2023-01-12 11:23:57 +03: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-02-19 04:12:25 +03:00
|
|
|
<input type="number" min={0} max={1} step={0.1} value={appState.serverSetting.serverSetting.crossFadeEndRate} onChange={(e) => {
|
|
|
|
appState.serverSetting.updateServerSettings({ ...appState.serverSetting.serverSetting, crossFadeEndRate: Number(e.target.value) })
|
2023-01-12 11:23:57 +03:00
|
|
|
}} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-02-19 04:12:25 +03:00
|
|
|
}, [appState.serverSetting.serverSetting.crossFadeEndRate, appState.serverSetting.updateServerSettings])
|
2023-01-12 11:23:57 +03:00
|
|
|
|
2023-01-07 14:07:39 +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">
|
2023-02-19 20:21:51 +03:00
|
|
|
<select className="body-select" value={appState.workletNodeSetting.workletNodeSetting.downSamplingMode} onChange={(e) => {
|
|
|
|
appState.workletNodeSetting.updateWorkletNodeSetting({ ...appState.workletNodeSetting.workletNodeSetting, downSamplingMode: e.target.value as DownSamplingMode })
|
2023-02-14 16:32:25 +03:00
|
|
|
}}>
|
|
|
|
{
|
|
|
|
Object.values(DownSamplingMode).map(x => {
|
|
|
|
return <option key={x} value={x}>{x}</option>
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2023-02-19 20:21:51 +03:00
|
|
|
}, [appState.workletNodeSetting.workletNodeSetting.downSamplingMode, appState.workletNodeSetting.updateWorkletNodeSetting])
|
2023-02-14 16:32:25 +03:00
|
|
|
|
|
|
|
|
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-16 18:09:56 +03:00
|
|
|
<input type="number" min={5} max={300} step={1} value={appState.workletSetting.setting.numTrancateTreshold} onChange={(e) => {
|
|
|
|
appState.workletSetting.setSetting({
|
|
|
|
...appState.workletSetting.setting,
|
2023-01-11 22:52:01 +03:00
|
|
|
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">
|
2023-02-16 18:09:56 +03:00
|
|
|
<input type="number" min={0.0001} max={0.0009} step={0.0001} value={appState.workletSetting.setting.volTrancateThreshold} onChange={(e) => {
|
|
|
|
appState.workletSetting.setSetting({
|
|
|
|
...appState.workletSetting.setting,
|
2023-01-11 22:52:01 +03:00
|
|
|
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">
|
2023-02-16 18:09:56 +03:00
|
|
|
<input type="number" min={16} max={128} step={1} value={appState.workletSetting.setting.volTrancateLength} onChange={(e) => {
|
|
|
|
appState.workletSetting.setSetting({
|
|
|
|
...appState.workletSetting.setting,
|
2023-01-11 22:52:01 +03:00
|
|
|
volTrancateLength: Number(e.target.value)
|
|
|
|
})
|
|
|
|
}} />
|
|
|
|
</div>
|
2023-02-12 11:07:28 +03:00
|
|
|
</div> */}
|
2023-01-12 11:23:57 +03:00
|
|
|
</>
|
|
|
|
)
|
2023-02-16 18:09:56 +03:00
|
|
|
}, [appState.workletSetting.setting, appState.workletSetting.setSetting])
|
2023-01-11 22:52:01 +03:00
|
|
|
|
|
|
|
|
2023-01-12 11:23:57 +03:00
|
|
|
const advanceSettingContent = useMemo(() => {
|
|
|
|
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}
|
2023-02-18 14:53:15 +03:00
|
|
|
{sendingSampleRateRow}
|
2023-01-12 11:23:57 +03:00
|
|
|
<div className="body-row divider"></div>
|
2023-02-19 00:25:22 +03:00
|
|
|
{crossFadeOverlapSizeRow}
|
2023-01-12 11:23:57 +03:00
|
|
|
{crossFadeOffsetRateRow}
|
|
|
|
{crossFadeEndRateRow}
|
|
|
|
<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-19 20:28:56 +03:00
|
|
|
}, [mmvcServerUrlRow, protocolRow, sampleRateRow, sendingSampleRateRow, crossFadeOverlapSizeRow, crossFadeOffsetRateRow, crossFadeEndRateRow, workletSettingRow, downSamplingModeRow])
|
2023-01-11 22:52:01 +03:00
|
|
|
|
|
|
|
|
2023-01-07 14:07:39 +03:00
|
|
|
const advancedSetting = useMemo(() => {
|
|
|
|
return (
|
|
|
|
<>
|
2023-02-16 18:09:56 +03:00
|
|
|
{appState.frontendManagerState.stateControls.openAdvancedSettingCheckbox.trigger}
|
|
|
|
<div className="partition">
|
|
|
|
<div className="partition-header">
|
|
|
|
<span className="caret">
|
|
|
|
{accodionButton}
|
|
|
|
</span>
|
|
|
|
<span className="title" onClick={() => { appState.frontendManagerState.stateControls.openAdvancedSettingCheckbox.updateState(!appState.frontendManagerState.stateControls.openAdvancedSettingCheckbox.checked()) }}>
|
|
|
|
Advanced Setting
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="partition-content">
|
|
|
|
{advanceSettingContent}
|
2023-01-07 14:07:39 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)
|
2023-02-16 18:09:56 +03:00
|
|
|
}, [advanceSettingContent])
|
2023-01-07 14:07:39 +03:00
|
|
|
|
|
|
|
return {
|
|
|
|
advancedSetting,
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|