當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。