- Tkinter GUI Application Development Blueprints(Second Edition)
- Bhaskar Chaudhary
- 196字
- 2021-06-24 18:35:14
Playing the drum machine
Now that we have a mechanism to load drum samples and a mechanism to define beat patterns in place, let's add the ability to play these beat patterns. In many ways, this is the core of our program.
Let's first understand the functionality that we want to achieve here.
Once the user has loaded one or more drum samples and has defined a beat pattern using the toggle buttons, we need to scan each column of the pattern to see if it finds a green button (a True value in our data structure).
If the value is True for a given location in the matrix, our code should play the corresponding drum sample before moving ahead. If two or more drum samples are selected in the same column, all the samples should play almost simultaneously.
Moreover, there should be a fixed time gap between the playing of each successive column, which will define the tempo of the music.
To achieve this functionality, we need to import the pygame module to play the sounds, and the time module to define the temporal gap between them.
- 現代C++編程:從入門到實踐
- AngularJS入門與進階
- Mastering AWS Lambda
- Python 深度學習
- 數據庫系統原理及MySQL應用教程
- Podman實戰
- Blender 3D Incredible Machines
- Python Data Analysis(Second Edition)
- Monitoring Elasticsearch
- Oracle Database 12c Security Cookbook
- Python機器學習編程與實戰
- SAP BusinessObjects Dashboards 4.1 Cookbook
- C語言程序設計學習指導與習題解答
- 深入理解Elasticsearch(原書第3版)
- Mastering Android Game Development