improve details of MIDI Input

This commit is contained in:
josc146 2023-11-30 11:57:52 +08:00
parent 68c70a362b
commit cbe299583b
2 changed files with 11 additions and 2 deletions

View File

@ -487,7 +487,7 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer((
}
}
}
const result = globalMessages.map(m => midiMessageToToken(m)).join('');
const result = ('<pad> ' + globalMessages.map(m => midiMessageToToken(m)).join('')).trim();
commonStore.setCompositionSubmittedPrompt(result);
setPrompt(result);
}}>

View File

@ -98,6 +98,13 @@ const CompositionPanel: FC = observer(() => {
}
}, []);
useEffect(() => {
if (!(commonStore.activeMidiDeviceIndex in commonStore.midiPorts)) {
commonStore.setActiveMidiDeviceIndex(-1);
CloseMidiPort();
}
}, [commonStore.midiPorts]);
const generateNs = (autoPlay: boolean) => {
fetch(getServerRoot(port) + '/text-to-midi', {
method: 'POST',
@ -270,7 +277,9 @@ const CompositionPanel: FC = observer(() => {
content={
<div className="flex flex-col gap-1">
<Dropdown style={{ minWidth: 0 }}
value={commonStore.activeMidiDeviceIndex === -1 ? t('None')! : commonStore.midiPorts[commonStore.activeMidiDeviceIndex].name}
value={(commonStore.activeMidiDeviceIndex === -1 || !(commonStore.activeMidiDeviceIndex in commonStore.midiPorts))
? t('None')!
: commonStore.midiPorts[commonStore.activeMidiDeviceIndex].name}
selectedOptions={[commonStore.activeMidiDeviceIndex.toString()]}
onOptionSelect={(_, data) => {
if (data.optionValue) {