|
| 1 | +# CoderBot, a didactical programmable robot. |
| 2 | +# Copyright (C) 2014, 2015 Roberto Previtera <info@coderbot.org> |
| 3 | +# |
| 4 | +# This program is free software; you can redistribute it and/or modify |
| 5 | +# it under the terms of the GNU General Public License as published by |
| 6 | +# the Free Software Foundation; either version 2 of the License, or |
| 7 | +# (at your option) any later version. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU General Public License for more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU General Public License along |
| 15 | +# with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 17 | +############################################################################ |
| 18 | +# CoderBot, a didactical programmable robot. |
| 19 | +# Copyright (C) 2014, 2015 Roberto Previtera <info@coderbot.org> |
| 20 | +# |
| 21 | +# MUSICAL EXTENTION for CoderBot |
| 22 | +# This extention is develop by: |
| 23 | +# Michele Carbonera - miki_992@hotmail.it - m.carbonera@campus.unimib.it - michele.carbonera@unimib.it |
| 24 | +# Antonino Tramontana - a.tramontana1@campus.unimib.it |
| 25 | +# Copyright (C) 2020 |
| 26 | +############################################################################ |
| 27 | + |
| 28 | +import os |
| 29 | +import alsaaudio |
| 30 | + |
| 31 | +class AudioCtrl: |
| 32 | + mixer = None |
| 33 | + _instance = None |
| 34 | + |
| 35 | + @classmethod |
| 36 | + def get_instance(cls): |
| 37 | + if cls._instance is None: |
| 38 | + cls._instance = AudioCtrl() |
| 39 | + return cls._instance |
| 40 | + |
| 41 | + def __init__(self): |
| 42 | + self.mixer = alsaaudio.Mixer('PCM', cardindex=1) |
| 43 | + #self.mixer = alsaaudio.PCM(device='numid=1', cardindex=1) |
| 44 | + |
| 45 | + def getVolume(self): |
| 46 | + print(self.mixer.getvolume()) |
| 47 | + |
| 48 | + def setVolume(self,valueVolume): |
| 49 | + self.mixer.setvolume(valueVolume) |
| 50 | +''' |
| 51 | +if __name__ == "__main__": |
| 52 | + a = AudioCtrl() |
| 53 | + a.setVolume(20) |
| 54 | + #a.setVolume(100)''' |
0 commit comments