/* eslint-disable @typescript-eslint/no-unused-vars */ // Copyright (c) 2024 Robin E. R. Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of // the Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import { useState } from 'react'; import Button from '@mui/material/Button'; import DialogTitle from '@mui/material/DialogTitle'; import DialogActions from '@mui/material/DialogActions'; import { PiPedalModel, PiPedalModelFactory } from './PiPedalModel'; import FormControlLabel from '@mui/material/FormControlLabel'; import ChannelBindingHelpDialog from './ChannelBindingsHelpDialog'; import IconButtonEx from './IconButtonEx'; import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; import Checkbox from '@mui/material/Checkbox'; import { AlsaMidiDeviceInfo } from './AlsaMidiDeviceInfo'; import DialogEx from './DialogEx'; import MidiChannelBinding, { MidiDeviceSelection } from './MidiChannelBinding'; import DialogContent from '@mui/material/DialogContent'; import Typography from '@mui/material/Typography'; import Select, { SelectChangeEvent } from '@mui/material/Select'; import MenuItem from '@mui/material/MenuItem'; export interface MidiChannelBindingDialogProps { open: boolean; midiChannelBinding: MidiChannelBinding; onClose: () => void; onChanged: (midiChannelBinding: MidiChannelBinding) => void; midiDevices: AlsaMidiDeviceInfo[]; } function MidiChannelBindingDialog(props: MidiChannelBindingDialogProps) { const { onClose, midiChannelBinding, open } = props; const [currentChannel, setCurrentChannel] = useState(midiChannelBinding.channel); const [allowProgramChanges, setAllowProgramChanges] = useState(midiChannelBinding.acceptCommonMessages); const [helpDialog, setHelpDialog] = useState(false); const model: PiPedalModel = PiPedalModelFactory.getInstance(); const handleClose = (): void => { onClose(); }; const handleOk = (): void => { onClose(); }; const generateDeviceSelect = () => { let result: React.ReactElement[] = [ (Any), (None) ]; let i = 2; for (let midiDevice of model.jackConfiguration.get().inputMidiDevices) { result.push(({midiDevice.description})); ++i; } return result; }; const getDefaultDeviceSelect = (): number => { if (midiChannelBinding.deviceSelection === MidiDeviceSelection.DeviceAny as number) { return 0; } if (midiChannelBinding.deviceSelection === MidiDeviceSelection.DeviceNone as number) { return 1; } if (midiChannelBinding.midiDevices.length === 0) { return 0; } let selectedDevice = midiChannelBinding.midiDevices[0]; let ix = 2; for (let midiDevice of model.jackConfiguration.get().inputMidiDevices) { if (midiDevice.name === selectedDevice) { return ix; } ++ix; } return 0; // any. } const [currentDeviceSelect, setCurrentDeviceSelect] = useState(getDefaultDeviceSelect()) const handleDeviceSelecChange = (event: SelectChangeEvent) => { setCurrentDeviceSelect(parseInt(event.target.value)); }; const handleChannelChange = (event: SelectChangeEvent) => { setCurrentChannel(parseInt(event.target.value)); }; return ( {}} fullWidth maxWidth="xs" > MIDI Channel Filters
MIDI Devices
Channels
{ setAllowProgramChanges(event.target.checked); }} /> } label="Allow Program Changes" /> {false&&( // wait until the implementation stabilizes before exposing the help dialog. { setHelpDialog(true); }} size="large"> )}
setHelpDialog(false)} />
); } export default MidiChannelBindingDialog;