I took a little time to work up a design of the state machine for patch changes and parameter changes. This design covers what happens when you press the buttons, and how the LED ring updates to reflect the result.
I played around with trying to write this with a state machine tool so that there would be a lovely picture, but found that the boxes were cumbersome to fit ideas into, and it was annoying to work with the arrows. Spatially, it didn't really work out. So, outline form it is. The format is:
- STATE_NAME: Description : Longer Explanation
- Thing that happens when running this state ~or~
- Keyboard Event
- Things that happen when this Keyboard Event occurs (state change only if explicitly stated)
Hopefully this makes some sort of sense to people who aren't me.
I've got the whole lovely thing in a Google Doc, but I'll reproduce it here:
Stylish! Trucker Belt Buckle Synthesizer: State Machine Design
- PLAY: Keyboard Play Mode
- On Key Press
- Last selected note is saved
- Note On Trigger
- On Key Release
- Note Off Trigger
- On Button Press:
- PATCH_SELECT_WAIT
- PATCH_WRITE_WAIT
- PARAMETER_SELECT_WAIT
- MODE_CHANGE_WAIT
- On Key Press
- PATCH_SELECT_WAIT :Patch Change: Waiting for Patch Selection.
- Flash Ring Green
- Block till stylus up
- On Key Press
- Select tentative patch from key number
- Play new patch using last key selected or middle C if none
- On Patch Change Button
- Tentative patch becomes current patch
- Return to PLAY mode.
- Other Button Press
- Go to that button’s WAIT mode
- PATCH_WRITE_WAIT: Patch Write: Waiting for Patch Selection
- Flash Ring Red
- Block til stylus up
- On Key Press
- Select overwrite patch from key number
- Play new patch using last key selected or middle C if none
- On Write Button
- Copy current patch data over selected overwrite patch
- Current patch number = overwrite patch number
- Return to PLAY mode with original patch data
- Other Button Press
- This is an abort of writing
- Patch returns to modified data from before WRITE hit
- Go to that button’s WAIT mode
- PARAMETER_SELECT_WAIT: Parameter Change: Waiting For Parameter Selection
- Flash Ring Blue
- Block til stylus up
- On Key Press
- Select value from key number
- VALUE_CHANGE_WAIT
- On Value Button
- Return to Play Mode
- Other Button Press
- Go to that button’s WAIT mode
- VALUE_CHANGE_WAIT: Value Change: Waiting for value
- Ring Flashes Blue, with the current parameter number’s LED with Green Chanel On (not Flashing) and current value of that parameter with RED channel On (not flashing)
- Block til stylus up
- On Key Press
- Parameter value is changed to value from key
- Play current sound using last key selected or middle C if none
- On Value Button press
- Return to Play Mode
- On Other Button press
- Go to that button’s WAIT mode
- MODE_CHANGE_WAIT: Mode Change: Waiting for Mode Selection
- Flash Ring Dim Yellow
- To Be Continued… Might work like value change for some values, but other values toggle instantaneously, so maybe it’s quick to change animation mode, but you have a two step to handle animation speed, tempo change, etc. Sequencer mode or drum loop drops you into a whole new state machine.
This much should get us to functional synthesizer
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.