Re: Add code for the PianoBooster metronome
Posted by mark-Dutton on Apr 10, 2021; 4:28pm
URL: http://piano-booster.139.s1.nabble.com/Add-code-for-the-PianoBooster-metronome-tp7572964p7572983.html
Hi Louis,
So I have powered through and finally got all functionalities finished. I have submitted a pull request for you to review.
Changes made:
1. Metronome button on/off
2. Metronome Settings menu
3. Metronome Bar and Beat Sounds
4. Metronome Bar and Beat Velocities
5. Metronome Volume
6. Metronome Preview
7. Metronome Tick Box
8. Metronome Cancel button to revert changes back to previous state
9. Metronome ok button to save new changes
I have also made some major changes to the CConductor::calcBoostVolume() function as well as the piano slider and boost slider functions. The volume of each channel can now be adjusted separately using the boost slider, when you switch the active channel the boost slider will snap up to the current volume of that channel and you can make adjustments to it as you wish. This fixes wip's I saw within that function. Brief overview of how it works:
I set each channels volume to the midpoint of 0 and the maximum midi volume possible. So the volume will be set to MIDI_MAX_VOLUME/2 = 127/2 = 63 on initialisation. This means that all instruments will have equal volume but some volumes may be increased/decreased.
The volume can be changed for each channel using the booster slider,
and the slider value will be normalized/scaled between the values 127 and 0.
So if the slider is at -100 the volume for the active channel will be 0,
100 volume will be 127 and at its midpoint volume will be 63.
When the active channel is changed on the side bar, the boost slider will also snap to the saved value of that channel.
I also fixed piano volume slider which was hardcoded at 127. It follows the same normalization as other
sliders. The metronome slider follows this process as well.
It has been very enjoyable working on the code in the afternoons. If you have any questions about the code in the pull request I can go into more detail for the different segments.
Feel free to look at any of this code whenever you feel like it. I might leave off coding in the afternoons for a while as I need to catch up on the uni work but it has been fun working through this project.