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


Python alsaaudio.Mixer方法代码示例

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


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

示例1: VolumeUp

# 需要导入模块: import alsaaudio [as 别名]
# 或者: from alsaaudio import Mixer [as 别名]
def VolumeUp(self):
        m = alsaaudio.Mixer()
        vol = m.getvolume()[0]

 #       print("VolumeUp vol %d " % vol)
        for i,v in enumerate(self.snd_segs):
            if  vol >= v[0] and vol <= v[1]:
                self._Needle = i
                break
          
        self._Needle += 1
        
        if self._Needle > len(self.snd_segs) -1:
            self._Needle = len(self.snd_segs) -1

#        print("Set volume %d" % self.snd_segs[self._Needle][1] )
        m.setvolume( self.snd_segs[self._Needle][0] +  (self.snd_segs[self._Needle][1] - self.snd_segs[self._Needle][0])/2   ) ## prefer bigger one  

        self._Value = self.snd_segs[self._Needle][1]

#        print( self._Value)
        return self._Value 
开发者ID:clockworkpi,项目名称:launcher,代码行数:24,代码来源:above_all_patch.py

示例2: VolumeDown

# 需要导入模块: import alsaaudio [as 别名]
# 或者: from alsaaudio import Mixer [as 别名]
def VolumeDown(self):
        m = alsaaudio.Mixer()
        vol = m.getvolume()[0]

        for i,v in enumerate(self.snd_segs):
            if  vol >= v[0] and vol <= v[1]:
                self._Needle = i
                break

        self._Needle -= 1
        if self._Needle < 0:
            self._Needle = 0
        
        vol =  self.snd_segs[self._Needle][0] ## prefer smaller one
        
        if vol < 0:
            vol = 0
        m.setvolume(vol)

#        print(vol)

        self._Value = vol
        return vol 
开发者ID:clockworkpi,项目名称:launcher,代码行数:25,代码来源:above_all_patch.py

示例3: Init

# 需要导入模块: import alsaaudio [as 别名]
# 或者: from alsaaudio import Mixer [as 别名]
def Init(self):
        self._CanvasHWND = self._Screen._CanvasHWND
        self._Width =  self._Screen._Width
        self._Height = self._Screen._Height
        
        self._MySlider = SoundSlider()

        self._MySlider._Parent = self        
        self._MySlider.SetCanvasHWND(self._CanvasHWND)

        self._MySlider.OnChangeCB = self.WhenSliderDrag

        self._MySlider.Init()
        
        try:
            m = alsaaudio.Mixer()
            self._MySlider.SetValue(m.getvolume()[0])
        except Exception,e:
            print(str(e))
            self._MySlider.SetValue(0) 
开发者ID:clockworkpi,项目名称:launcher,代码行数:22,代码来源:sound_page.py

示例4: set_alsa_control

# 需要导入模块: import alsaaudio [as 别名]
# 或者: from alsaaudio import Mixer [as 别名]
def set_alsa_control(self, alsa_control):
        from alsaaudio import Mixer
        try:
            self.mixer = Mixer(alsa_control)
            logging.debug("using existing ALSA control %s", alsa_control)
        except:
            try:
                logging.debug(
                    "ALSA control %s does not exist, creating it", alsa_control)

                self.mixer = self.create_mixer(alsa_control)
            except Exception as e:
                logging.error(
                    "can't create ALSA mixer control %s (%s)",
                    alsa_control, e)
            return False

        if self.mixer == None:
            logging.error("ALSA mixer %s not found", alsa_control)
            return False

        self.mixername = alsa_control
        return True 
开发者ID:hifiberry,项目名称:hifiberry-dsp,代码行数:25,代码来源:alsasync.py

示例5: read_alsa_data

# 需要导入模块: import alsaaudio [as 别名]
# 或者: from alsaaudio import Mixer [as 别名]
def read_alsa_data(self):
        from alsaaudio import Mixer
        volumes = Mixer(self.mixername).getvolume()
        channels = 0
        vol = 0
        for i in range(len(volumes)):
            channels += 1
            vol += volumes[i]

        if channels > 0:
            vol = round(vol / channels)
            
        if vol != self.alsavol:
            logging.debug(
                "ALSA volume changed from {}% to {}%".format(self.alsavol, vol))
            self.alsavol = vol
            return True
        else:
            return False 
开发者ID:hifiberry,项目名称:hifiberry-dsp,代码行数:21,代码来源:alsasync.py

示例6: __init__

# 需要导入模块: import alsaaudio [as 别名]
# 或者: from alsaaudio import Mixer [as 别名]
def __init__(self):
        self.vlcInstance = vlc.Instance()
        self.player = self.vlcInstance.media_player_new()
        self.alsa = alsaaudio.Mixer(alsaaudio.mixers()[0])
        self.alsa.setvolume(self.volume) 
开发者ID:BramRausch,项目名称:PiPod,代码行数:7,代码来源:playback.py

示例7: __init__

# 需要导入模块: import alsaaudio [as 别名]
# 或者: from alsaaudio import Mixer [as 别名]
def __init__(self):
        self._osd = OSDPercentage(font=FONT, colour="#6a5acd", timeout=3) # slate blue
        kn = self._knob = PowerVolume()
        kn.open()
        kn.register_motion(self.change_volume)
        kn.register_button(self.handle_button)
        am = self._mixer = alsaaudio.Mixer(alsaaudio.mixers()[0]) # XXX
        self._volume = am.getvolume()[0] 
开发者ID:kdart,项目名称:pycopia,代码行数:10,代码来源:mastervolume.py

示例8: SyncSoundVolume

# 需要导入模块: import alsaaudio [as 别名]
# 或者: from alsaaudio import Mixer [as 别名]
def SyncSoundVolume(self):
        try:
	        m = alsaaudio.Mixer()
	        vol = m.getvolume()[0]	
        except Exception,e:
            print(str(e))
            vol = 0 
开发者ID:clockworkpi,项目名称:launcher,代码行数:9,代码来源:title_bar.py

示例9: OnLoadCb

# 需要导入模块: import alsaaudio [as 别名]
# 或者: from alsaaudio import Mixer [as 别名]
def OnLoadCb(self):
        try:
            m = alsaaudio.Mixer()
            self._MySlider.SetValue(m.getvolume()[0])
        except Exception,e:
            print(str(e)) 
开发者ID:clockworkpi,项目名称:launcher,代码行数:8,代码来源:sound_page.py

示例10: _get_mixer

# 需要导入模块: import alsaaudio [as 别名]
# 或者: from alsaaudio import Mixer [as 别名]
def _get_mixer():
        try:
            mixer = alsaaudio.Mixer()
        except alsaaudio.ALSAAudioError:
            # no master, we are on a Rpi
            mixer = alsaaudio.Mixer("PCM")
        return mixer 
开发者ID:Sispheor,项目名称:piclodio3,代码行数:9,代码来源:sound_manager.py

示例11: create_mixer

# 需要导入模块: import alsaaudio [as 别名]
# 或者: from alsaaudio import Mixer [as 别名]
def create_mixer(name):

        with tempfile.NamedTemporaryFile(mode='w', dir="/tmp", delete=False) as asoundstate:
            content = ALSA_STATE_FILE.replace("%VOLUME%", name)
            logging.debug("asoundstate file %s", content)
            asoundstate.write(content)
            asoundstate.close()

        command = "/usr/sbin/alsactl -f {} restore".format(
            asoundstate.name)
        logging.debug("runnning %s", command)
        os.system(command)
        from alsaaudio import Mixer
        return Mixer(name) 
开发者ID:hifiberry,项目名称:hifiberry-dsp,代码行数:16,代码来源:alsasync.py

示例12: _mixer

# 需要导入模块: import alsaaudio [as 别名]
# 或者: from alsaaudio import Mixer [as 别名]
def _mixer(self):
        # The mixer must be recreated every time it is used to be able to
        # observe volume/mute changes done by other applications.
        return alsaaudio.Mixer(cardindex=self.cardindex, control=self.control) 
开发者ID:mopidy,项目名称:mopidy-alsamixer,代码行数:6,代码来源:mixer.py

示例13: __init__

# 需要导入模块: import alsaaudio [as 别名]
# 或者: from alsaaudio import Mixer [as 别名]
def __init__(self, cardindex, control, callback=None):
        super().__init__()
        self.running = True

        # Keep the mixer instance alive for the descriptors to work
        self.mixer = alsaaudio.Mixer(cardindex=cardindex, control=control)
        descriptors = self.mixer.polldescriptors()
        assert len(descriptors) == 1
        self.fd = descriptors[0][0]
        self.event_mask = descriptors[0][1]

        self.callback = callback 
开发者ID:mopidy,项目名称:mopidy-alsamixer,代码行数:14,代码来源:mixer.py

示例14: __init__

# 需要导入模块: import alsaaudio [as 别名]
# 或者: from alsaaudio import Mixer [as 别名]
def __init__(self, hw_model):

        (
            card_index,
            self.sound_card,
            playback_device,
        ) = SoundAlsa.sound_configuration()
        self.playback_device = playback_device

        if self.sound_card == SoundAlsa.MODEL_2018_CARD_NAME:
            self.playback_mixer = None
            self.record_device = "null"
            self.record_mixer = None
        else:
            # do we have anyone else? either way it is not supported
            assert self.sound_card == SoundAlsa.MODEL_2019_CARD_NAME

            self.playback_mixer = alsaaudio.Mixer(
                control="Playback", cardindex=card_index
            )
            self.record_device = self.playback_device
            self.record_mixer = alsaaudio.Mixer(
                control="Capture", cardindex=card_index
            )

            if not SoundAlsa.__test_device(self.record_device, True):
                raise RuntimeError(
                    "Unable to configure sound card for recording"
                )

        self.executor = ThreadPoolExecutor(max_workers=1)

        self.future = None
        self.currently_playing = False
        self.currently_recording = False 
开发者ID:nabaztag2018,项目名称:pynab,代码行数:37,代码来源:sound_alsa.py


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