Our drum program is now functional. You can load drum samples and define a beat pattern and our drum machine will play it.
Let's now extend our drum machine to create more than one pattern in the same program. This will provide us with the ability to play different patterns simply by changing the pattern number. This gives the user the ability to make different beats for the intro, verse, chorus, bridge, and other parts of a song. The pattern-changing user interface is highlighted in red in the following screenshot:
At the very outset, we have an Entry widget adjacent to the Pattern Number Spinbox widget. We want to display the current pattern number in that Entry widget. We accordingly create a method, display_pattern_name(), which does this task (see code 3.08.py):
def display_pattern_name(self):
self.current_pattern_name_widget.config...