add Patches Component

This commit is contained in:
[poww10s]
2020-11-20 04:51:50 -05:00
parent 70ccfe7ee1
commit 0e89ade1c6
6 changed files with 159 additions and 6 deletions
+3 -3
View File
@@ -7,9 +7,9 @@ function App() {
return ( return (
<div className="App"> <div className="App">
<header className="App-header"> <header className="App-header">
{/*<Timbre id="timbre1" /> <Timbre id="timbre1" />
<Timbre id="timbre2" />*/} {/*<Timbre id="timbre2" />
<Vocoder id="vocoder" /> <Vocoder id="vocoder" />*/}
</header> </header>
</div> </div>
); );
+2
View File
@@ -7,6 +7,7 @@ import Filter from './parameters/Filter';
import EG from './parameters/EG'; import EG from './parameters/EG';
import Amp from './parameters/Amp'; import Amp from './parameters/Amp';
import LFO from './parameters/LFO'; import LFO from './parameters/LFO';
import Patches from './parameters/Patches';
import { selectById } from './timbreSlice.js'; import { selectById } from './timbreSlice.js';
const timbreStyle = { const timbreStyle = {
@@ -144,6 +145,7 @@ export default function Timbre(props) {
{ value: 'Sample & Hold' }, { value: 'Sample & Hold' },
]} ]}
/> />
<Patches id={ids.patches} />
</div> </div>
); );
} }
@@ -14,7 +14,7 @@
margin: 2.5pt 0; margin: 2.5pt 0;
} }
.pitchContainer { .horizontalContainer {
font-size: small; font-size: small;
display: inline-flex; display: inline-flex;
flex-direction: row; flex-direction: row;
@@ -26,7 +26,7 @@
width: 420px; width: 420px;
height: 214px; height: 214px;
} }
.pitchContainer > .container { .horizontalContainer > .container {
padding: 0 16pt; padding: 0 16pt;
width: 100%; width: 100%;
margin: 10pt 0; margin: 10pt 0;
+128
View File
@@ -0,0 +1,128 @@
import React from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { selectById, parameterUpdated } from './parameterSlice.js';
import { Slider, SelectList } from '../../helpers/Helpers';
import styles from './Parameters.module.css';
const Patch = (props) => {
return (
<div>
Source
<SelectList
value={props.patch.source}
list={[
{ value: 'Filter EG' },
{ value: 'Amp Eg' },
{ value: 'LFO 1' },
{ value: 'LFO 2' },
{ value: 'Velocity' },
{ value: 'Keyboard Track' },
{ value: 'Pitch Bend' },
{ value: 'Mod Wheel' },
]}
onChange={(value) =>
props.onChange({
source: value,
destination: props.patch.destination,
modIntensity: props.patch.modIntensity,
})
}
/>
Destination
<SelectList
value={props.patch.destination}
list={[
{ value: 'Pitch' },
{ value: 'OSC 2 Tune' },
{ value: 'OSC 1 Control 1' },
{ value: 'Noise Level' },
{ value: 'Cutoff' },
{ value: 'Amp' },
{ value: 'Pan' },
{ value: 'LFO 2 Frequency' },
]}
onChange={(value) =>
props.onChange({
source: props.patch.source,
destination: value,
modIntensity: props.patch.modIntensity,
})
}
/>
Mod Intensity
<Slider
min={0}
max={127}
parameter={props.patch.modIntensity}
onChange={(value) =>
props.onChange({
source: props.patch.source,
destination: props.patch.destination,
modIntensity: value,
})
}
/>
</div>
);
};
export default function Patches(props) {
const parameters = useSelector((state) => selectById(state, props.id));
const dispatch = useDispatch();
return (
<div className={styles.horizontalContainer}>
<Patch
patch={parameters.patch1}
onChange={(value) =>
dispatch(
parameterUpdated({
id: props.id,
changes: {
patch1: value,
},
})
)
}
/>
<div className={styles.divider} />
<Patch
patch={parameters.patch2}
onChange={(value, parameter) =>
dispatch(
parameterUpdated({
id: props.id,
changes: {
patch2: value,
},
})
)
}
/>
<div className={styles.divider} />
<Patch
patch={parameters.patch3}
onChange={(value, parameter) =>
dispatch(
parameterUpdated({
id: props.id,
changes: { patch3: value },
})
)
}
/>
<div className={styles.divider} />
<Patch
patch={parameters.patch4}
onChange={(value, parameter) =>
dispatch(
parameterUpdated({
id: props.id,
changes: { patch4: value },
})
)
}
/>
</div>
);
}
+1 -1
View File
@@ -9,7 +9,7 @@ export default function Pitch(props) {
const dispatch = useDispatch(); const dispatch = useDispatch();
return ( return (
<div className={styles.pitchContainer}> <div className={styles.horizontalContainer}>
<div className={styles.container}> <div className={styles.container}>
Voice Assign Voice Assign
<SelectList <SelectList
@@ -265,6 +265,29 @@ const parametersSlice = createSlice({
tempoSync: false, tempoSync: false,
frequency: 0, frequency: 0,
}, },
'patches1': {
id: 'patches1',
patch1: {
source: 'Filter EG',
destination: 'Pitch',
modIntensity: 0,
},
patch2: {
source: 'Amp EG',
destination: 'Pitch',
modIntensity: 0,
},
patch3: {
source: 'LFO 1',
destination: 'Pitch',
modIntensity: 0,
},
patch4: {
source: 'LFO 2',
destination: 'Pitch',
modIntensity: 0,
},
},
}, },
}), }),
reducers: { reducers: {