Touchscreen audio controller for presentation sound

The command Function

The command function (lines 77-86) is called by the main loop when a button gets pressed on the touchscreen. The cmd lets me know which button was touched.

Line 78 checks whether the command is BGVOLUP. If so, it increases the volume by 2 percent (line 79). Then, line 80 checks whether self.volume has gone over 100. If so, it resets it to 100. Finally, if the track is currently playing, then self.track.set_volume is called to do the actual volume adjustment.

Lines 82-85 are the opposite of 78-81 for BGVOLDN, but the logic is identical. Finally, line 86 calls self.drawPlayButton so the volume graph is redrawn.

The announcement Class

The announcement class (lines 89-96) is the simplest of all of the sound-handling classes. It only has one function other than __init__. In __init__, lines 90-92 copy arguments to class variables. Then, the play function loads the sound (line 95) and plays it immediately(line 96).

Buy this article as PDF

Express-Checkout as PDF

Pages: 2

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content