当前位置: 首页>>代码示例>>Python>>正文


Python alsaaudio.Mixer类代码示例

本文整理汇总了Python中alsaaudio.Mixer的典型用法代码示例。如果您正苦于以下问题:Python Mixer类的具体用法?Python Mixer怎么用?Python Mixer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Mixer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __update_volume

 def __update_volume(self, level=0):
     mixer = Mixer()
     volume = mixer.getvolume()[0]
     code = self.get_volume_code(volume) + level
     code = self.fix_code(code)
     if code in self.VOLUMES:
         volume = self.VOLUMES[code]
         mixer.setvolume(volume)
     return code, volume
开发者ID:Acidburn0zzz,项目名称:mycroft-core,代码行数:9,代码来源:__init__.py

示例2: __update_volume

 def __update_volume(self, change=0):
     """
     Tries to change volume level
     :param change: +1 or -1; the step to change by
     :return: new code (0..11), whether volume changed
     """
     mixer = Mixer()
     old_level = self.volume_to_level(mixer.getvolume()[0])
     new_level = self.bound_level(old_level + change)
     self.enclosure.eyes_volume(new_level)
     mixer.setvolume(self.level_to_volume(new_level))
     return new_level, new_level != old_level
开发者ID:forslund,项目名称:mycroft-core,代码行数:12,代码来源:__init__.py

示例3: set_volume

def set_volume(request, username, value):
    global volume_who, volume_direction
    m = Mixer()
    if value > m.getvolume()[0]:
        volume_direction = "up"
        volume_who = username
    elif value < m.getvolume()[0]:
        volume_direction = "down"
    else:
        return volume()  # no change, quit

    volume_who = username
    m.setvolume(value)
    return volume()
开发者ID:Ferada,项目名称:nih,代码行数:14,代码来源:volume.py

示例4: __update_volume

    def __update_volume(self, level=0):
        """
        Tries to change volume level
        :param level: +1 or -1; the step to change by
        :return: new code (0..11), whether volume changed
        """
        mixer = Mixer()
        volume = mixer.getvolume()[0]
        old_code = self.get_volume_code(volume)

        new_code = self.fix_code(old_code + level)
        if new_code in self.VOLUMES:
            volume = self.VOLUMES[new_code]
            mixer.setvolume(volume)
        return new_code, new_code != old_code
开发者ID:branux,项目名称:mycroft-core,代码行数:15,代码来源:__init__.py

示例5: __init__

 def __init__(self, player):
     self.player = player
     self._alsa_mixer = Mixer(control="PCM")
     self.is_pressed = False
     GPIO.setmode(GPIO.BOARD)
     input_buttons = [k for k in self.buttons.keys()]
     GPIO.setup(input_buttons, GPIO.IN, pull_up_down=GPIO.PUD_UP)
开发者ID:SpotiQue,项目名称:Core,代码行数:7,代码来源:raspberry_gpio.py

示例6: __init__

 def __init__(self, mplfifo, ser, mpout, beep=True):
     self.playing = False
     self.mixer = Mixer(control='PCM')
     self.fifo = mplfifo
     self.ser = ser
     self.mpout = mpout
     self.beep = beep
开发者ID:speakerbug,项目名称:Harold,代码行数:7,代码来源:harold.py

示例7: __init__

 def __init__(self, mplfifo, ser, mpout, beep=True, override = [], blacklist = []):
     self.playing = False
     self.mixer = Mixer(control='PCM')
     self.fifo = mplfifo
     self.ser = ser
     self.mpout = mpout
     self.beep = beep
     self.override = override
     self.blacklist = blacklist
     self.current_user = None
开发者ID:JDrit,项目名称:Harold,代码行数:10,代码来源:harold.py

示例8: notify

    def notify(self, timestamp):
        with self.LOCK:
            if self.data.__contains__(timestamp):
                volume = None
                self.alarm_on = True
                delay = self.__calculate_delay(self.max_delay)

                while self.alarm_on and datetime.now() < delay:
                    play_mp3(self.file_path).communicate()
                    self.speak_dialog('alarm.stop')
                    time.sleep(self.repeat_time + 2)
                    if not volume and datetime.now() >= delay:
                        mixer = Mixer()
                        volume = mixer.getvolume()[0]
                        mixer.setvolume(100)
                        delay = self.__calculate_delay(self.extended_delay)
                if volume:
                    Mixer().setvolume(volume)
                self.remove(timestamp)
                self.alarm_on = False
                self.save()
开发者ID:forslund,项目名称:mycroft-core,代码行数:21,代码来源:__init__.py

示例9: process

    def process(self, data):
        self.client.emit(Message(data))

        if "mycroft.stop" in data:
            self.client.emit(Message("mycroft.stop"))

        if "volume.up" in data:
            self.client.emit(
                Message("IncreaseVolumeIntent", metadata={'play_sound': True}))

        if "volume.down" in data:
            self.client.emit(
                Message("DecreaseVolumeIntent", metadata={'play_sound': True}))

        if "system.test.begin" in data:
            self.client.emit(Message('recognizer_loop:sleep'))

        if "system.test.end" in data:
            self.client.emit(Message('recognizer_loop:wake_up'))

        if "mic.test" in data:
            mixer = Mixer()
            prev_vol = mixer.getvolume()[0]
            mixer.setvolume(35)
            self.client.emit(Message("speak", metadata={
                'utterance': "I am testing one two three"}))

            time.sleep(0.5)  # Prevents recording the loud button press
            record("/tmp/test.wav", 3.0)
            mixer.setvolume(prev_vol)
            play_wav("/tmp/test.wav")
            time.sleep(3.5)  # Pause between tests so it's not so fast

            # Test audio muting on arduino
            subprocess.call('speaker-test -P 10 -l 0 -s 1', shell=True)
开发者ID:branux,项目名称:mycroft-core,代码行数:35,代码来源:enclosure.py

示例10: process

    def process(self, data):
        self.client.emit(Message(data))

        if "mycroft.stop" in data:
            self.client.emit(Message("mycroft.stop"))

        if "volume.up" in data:
            self.client.emit(
                Message("IncreaseVolumeIntent", metadata={'play_sound': True}))

        if "volume.down" in data:
            self.client.emit(
                Message("DecreaseVolumeIntent", metadata={'play_sound': True}))

        if "system.test.begin" in data:
            self.client.emit(Message('recognizer_loop:sleep'))

        if "system.test.end" in data:
            self.client.emit(Message('recognizer_loop:wake_up'))

        if "mic.test" in data:
            mixer = Mixer()
            prev_vol = mixer.getvolume()[0]
            mixer.setvolume(35)
            self.client.emit(Message("speak", metadata={
                'utterance': "I am testing one two three"}))
            record("/tmp/test.wav", 3.5)
            play_wav("/tmp/test.wav")

            # Test audio muting on arduino
            self.client.emit(Message("speak", metadata={
                'utterance': "LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG"}))

            mixer.setvolume(prev_vol)
开发者ID:kagesenshi,项目名称:mycroft-core,代码行数:34,代码来源:enclosure.py

示例11: process

    def process(self, data):
        self.client.emit(Message(data))

        if "mycroft.stop" in data:
            self.client.emit(Message("mycroft.stop"))

        if "volume.up" in data:
            self.client.emit(
                Message("IncreaseVolumeIntent", metadata={'play_sound': True}))

        if "volume.down" in data:
            self.client.emit(
                Message("DecreaseVolumeIntent", metadata={'play_sound': True}))

        if "system.test.begin" in data:
            self.client.emit(Message('recognizer_loop:sleep'))

        if "system.test.end" in data:
            self.client.emit(Message('recognizer_loop:wake_up'))

        if "mic.test" in data:
            mixer = Mixer()
            prev_vol = mixer.getvolume()[0]
            mixer.setvolume(35)
            self.client.emit(Message("speak", metadata={
                'utterance': "I am testing one two three"}))

            time.sleep(0.5)  # Prevents recording the loud button press
            record("/tmp/test.wav", 3.0)
            mixer.setvolume(prev_vol)
            play_wav("/tmp/test.wav")
            time.sleep(3.5)  # Pause between tests so it's not so fast

            # Test audio muting on arduino
            subprocess.call('speaker-test -P 10 -l 0 -s 1', shell=True)

        if "unit.shutdown" in data:
            self.client.emit(
                Message("enclosure.eyes.timedspin",
                        metadata={'length': 12000}))
            self.client.emit(Message("enclosure.mouth.reset"))
            subprocess.call('systemctl poweroff -i', shell=True)

        if "unit.reboot" in data:
            self.client.emit(
                Message("enclosure.eyes.spin"))
            self.client.emit(Message("enclosure.mouth.reset"))
            subprocess.call('systemctl reboot -i', shell=True)

        if "unit.setwifi" in data:
            self.client.emit(Message("wifisetup.start"))

        if "unit.factory-reset" in data:
            subprocess.call(
                'rm ~/.mycroft/identity/identity.json',
                shell=True)
            self.client.emit(
                Message("enclosure.eyes.spin"))
            self.client.emit(Message("enclosure.mouth.reset"))
            subprocess.call('systemctl reboot -i', shell=True)
开发者ID:bisaysavath,项目名称:mycroft-core,代码行数:60,代码来源:enclosure.py

示例12: notify

    def notify(self, timestamp):
        with self.LOCK:
            if self.data.__contains__(timestamp):
                volume = None
                self.reminder_on = True
                delay = self.__calculate_delay(self.max_delay)

                while self.reminder_on and datetime.now() < delay:
                    self.speak_dialog(
                        'reminder.notify',
                        data=self.build_feedback_payload(timestamp))
                    time.sleep(1)
                    self.speak_dialog('reminder.stop')
                    time.sleep(self.repeat_time)
                    if not volume and datetime.now() >= delay:
                        mixer = Mixer()
                        volume = mixer.getvolume()[0]
                        mixer.setvolume(100)
                        delay = self.__calculate_delay(self.extended_delay)
                if volume:
                    Mixer().setvolume(volume)
                self.remove(timestamp)
                self.reminder_on = False
                self.save()
开发者ID:Alphacodeclub,项目名称:mycroft-core,代码行数:24,代码来源:__init__.py

示例13: run

    def run(self, commandlist):
        mixer = Mixer()

        if len(commandlist) == 1:
            if mixer.getmute():
                mixer.setmute(0)
            else:
                mixer.setmute(1)
        else:
            command = {'mode':'set'}
            for i in xrange(0, len(commandlist)-1):
                pass
开发者ID:n8many,项目名称:Pixel-Interpreter-Framework,代码行数:12,代码来源:volume.py

示例14: __init__

    def __init__(self):   
        self.logged_in = threading.Event()
        self.end_of_track = threading.Event()

        self.queue_playlist = []
        self.prev_playlist = []
        
        self.min_volume = 70
        
        config = spotify.Config()
        config.load_application_key_file(filename='/home/pi/django_projects/mysite/spotify_app/spotify_appkey.key')
        self.session = spotify.Session(config=config)
        
        self.loop = spotify.EventLoop(self.session)
        self.loop.start()
        
        self.current_track = None

        # Connect an audio sink
        self.audio = spotify.AlsaSink(self.session)
        self.mixer = Mixer('PCM', 0)
        
        self.session.on(spotify.SessionEvent.CONNECTION_STATE_UPDATED, self.on_connection_state_updated)
        self.session.on(spotify.SessionEvent.END_OF_TRACK, self.on_end_of_track)
开发者ID:cgunning,项目名称:django-spotify-test,代码行数:24,代码来源:player.py

示例15: set_volume

def set_volume(val):
	id = alsaaudio.mixers(SOUND_CARD).index(SOUND_MIXER)
	mixer = Mixer(SOUND_MIXER, id, SOUND_CARD)
	mixer.setvolume(val)
开发者ID:Mustard,项目名称:PCRemoteServer,代码行数:4,代码来源:server.py


注:本文中的alsaaudio.Mixer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。