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


Python Mixer.getmute方法代码示例

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


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

示例1: run

# 需要导入模块: from alsaaudio import Mixer [as 别名]
# 或者: from alsaaudio.Mixer import getmute [as 别名]
    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,代码行数:14,代码来源:volume.py

示例2: click

# 需要导入模块: from alsaaudio import Mixer [as 别名]
# 或者: from alsaaudio.Mixer import getmute [as 别名]
    def click(self, button):
        if button == 1:
            mixer = Mixer(self.mutedev)
            mixer.setmute(not bool(mixer.getmute()[0]))

        elif button == 4:
            mixer = Mixer(self.voldev)
            try:
                mixer.setvolume(mixer.getvolume()[0] + self.step)
            except ALSAAudioError:
                return

        elif button == 5:
            mixer = Mixer(self.voldev)
            try:
                mixer.setvolume(mixer.getvolume()[0] - self.step)
            except ALSAAudioError:
                return

        self.update()
开发者ID:tom5760,项目名称:wipi,代码行数:22,代码来源:volume.py

示例3: ALSA

# 需要导入模块: from alsaaudio import Mixer [as 别名]
# 或者: from alsaaudio.Mixer import getmute [as 别名]
class ALSA(IntervalModule):
    """
    Shows volume of ALSA mixer. You can also use this for inputs, btw.

    Requires pyalsaaudio

    Available formatters:

    * `{volume}` — the current volume in percent
    * `{muted}` — the value of one of the `muted` or `unmuted` settings
    * `{card}` — the associated soundcard
    * `{mixer}` — the associated ALSA mixer
    """

    interval = 1

    settings = (
        "format",
        ("format_muted", "optional format string to use when muted"),
        ("mixer", "ALSA mixer"),
        ("mixer_id", "ALSA mixer id"),
        ("card", "ALSA sound card"),
        "muted", "unmuted",
        "color_muted", "color",
        "channel"
    )

    muted = "M"
    unmuted = ""
    color_muted = "#AAAAAA"
    color = "#FFFFFF"
    format = "♪: {volume}"
    format_muted = None
    mixer = "Master"
    mixer_id = 0
    card = 0
    channel = 0

    alsamixer = None
    has_mute = True

    def init(self):
        self.create_mixer()
        try:
            self.alsamixer.getmute()
        except ALSAAudioError:
            self.has_mute = False

        self.fdict = {
            "card": self.alsamixer.cardname(),
            "mixer": self.mixer,
        }

    def create_mixer(self):
        self.alsamixer = Mixer(
            control=self.mixer, id=self.mixer_id, cardindex=self.card)

    def run(self):
        self.create_mixer()

        muted = False
        if self.has_mute:
            muted = self.alsamixer.getmute()[self.channel] == 1

        self.fdict["volume"] = self.alsamixer.getvolume()[self.channel]
        self.fdict["muted"] = self.muted if muted else self.unmuted

        if muted and self.format_muted is not None:
            output_format = self.format_muted
        else:
            output_format = self.format

        self.output = {
            "full_text": output_format.format(**self.fdict),
            "color": self.color_muted if muted else self.color,
        }
开发者ID:AlexRacoon,项目名称:i3pystatus,代码行数:78,代码来源:alsa.py

示例4: Mixer

# 需要导入模块: from alsaaudio import Mixer [as 别名]
# 或者: from alsaaudio.Mixer import getmute [as 别名]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# [email protected]

import sys

from alsaaudio import Mixer


m = Mixer()


if __name__ == '__main__':
    output = ["{}   {}".format(u'\uf001', m.getvolume()[0])]
    color = False
    if m.getmute()[0]:
        color = '#666666'
    output += output
    if color:
        output.append(color)
    print('\n'.join(output))
开发者ID:dbsr,项目名称:dotfiles,代码行数:23,代码来源:volume.py

示例5: ALSA

# 需要导入模块: from alsaaudio import Mixer [as 别名]
# 或者: from alsaaudio.Mixer import getmute [as 别名]
class ALSA(IntervalModule):
    """
    Shows volume of ALSA mixer. You can also use this for inputs, btw.

    Requires pyalsaaudio

    .. rubric:: Available formatters

    * `{volume}` — the current volume in percent
    * `{muted}` — the value of one of the `muted` or `unmuted` settings
    * `{card}` — the associated soundcard
    * `{mixer}` — the associated ALSA mixer
    """

    interval = 1

    settings = (
        "format",
        ("format_muted", "optional format string to use when muted"),
        ("mixer", "ALSA mixer"),
        ("mixer_id", "ALSA mixer id"),
        ("card", "ALSA sound card"),
        ("increment", "integer percentage of max volume to in/decrement volume on mousewheel"),
        "muted", "unmuted",
        "color_muted", "color",
        "channel",
        ("map_volume", "volume display/setting as in AlsaMixer. increment option is ignored then.")
    )

    muted = "M"
    unmuted = ""
    color_muted = "#AAAAAA"
    color = "#FFFFFF"
    format = "♪: {volume}"
    format_muted = None
    mixer = "Master"
    mixer_id = 0
    card = 0
    channel = 0
    increment = 5

    map_volume = False

    alsamixer = None
    has_mute = True

    on_upscroll = "increase_volume"
    on_downscroll = "decrease_volume"
    on_leftclick = "switch_mute"
    on_rightclick = on_leftclick

    def init(self):
        self.create_mixer()
        try:
            self.alsamixer.getmute()
        except ALSAAudioError:
            self.has_mute = False

        self.fdict = {
            "card": self.alsamixer.cardname(),
            "mixer": self.mixer,
        }

        self.dbRng = self.alsamixer.getrange()

        self.dbMin = self.dbRng[0]
        self.dbMax = self.dbRng[1]

    def create_mixer(self):
        self.alsamixer = Mixer(
            control=self.mixer, id=self.mixer_id, cardindex=self.card)

    def run(self):
        self.create_mixer()

        muted = False
        if self.has_mute:
            muted = self.alsamixer.getmute()[self.channel] == 1

        self.fdict["volume"] = self.get_cur_volume()
        self.fdict["muted"] = self.muted if muted else self.unmuted
        self.fdict["db"] = self.get_db()

        if muted and self.format_muted is not None:
            output_format = self.format_muted
        else:
            output_format = self.format

        self.data = self.fdict
        self.output = {
            "full_text": output_format.format(**self.fdict),
            "color": self.color_muted if muted else self.color,
        }

    def switch_mute(self):
        if self.has_mute:
            muted = self.alsamixer.getmute()[self.channel]
            self.alsamixer.setmute(not muted)

    def get_cur_volume(self):
#.........这里部分代码省略.........
开发者ID:Arvedui,项目名称:i3pystatus,代码行数:103,代码来源:alsa.py

示例6: ALSA

# 需要导入模块: from alsaaudio import Mixer [as 别名]
# 或者: from alsaaudio.Mixer import getmute [as 别名]
class ALSA():

    def init(self):

        self.muted = "M"
        self.unmuted = ""
        self.color_muted = "#AAAAAA"
        self.color = "#FFFFFF"
        self.format = "♪: {volume}"
        self.format_muted = None
        self.mixer = "Master"
        self.mixer_id = 0
        self.card = 0
        self.channel = 0
        self.increment = 5

        self.map_volume = False

        self.alsamixer = None
        self.has_mute = True



        self.create_mixer()
        try:
            self.alsamixer.getmute()
        except ALSAAudioError:
            self.has_mute = False

        self.fdict = {
            "card": self.alsamixer.cardname(),
            "mixer": self.mixer,
        }

        self.dbRng = self.alsamixer.getrange()

        self.dbMin = self.dbRng[0]
        self.dbMax = self.dbRng[1]

    def create_mixer(self):
        self.alsamixer = Mixer(
            control=self.mixer, id=self.mixer_id, cardindex=self.card)

    def run(self):
        self.create_mixer()

        muted = False
        if self.has_mute:
            muted = self.alsamixer.getmute()[self.channel] == 1

        self.fdict["volume"] = self.get_cur_volume()
        self.fdict["muted"] = self.muted if muted else self.unmuted
        self.fdict["db"] = self.get_db()

        if muted and self.format_muted is not None:
            output_format = self.format_muted
        else:
            output_format = self.format

        self.output = {
            "full_text": output_format.format(**self.fdict),
            "color": self.color_muted if muted else self.color,
        }

    def switch_mute(self):
        if self.has_mute:
            muted = self.alsamixer.getmute()[self.channel]
            self.alsamixer.setmute(not muted)

    def get_cur_volume(self):
        if self.map_volume:
            dbCur = self.get_db() * 100.0
            dbMin = self.dbMin * 100.0
            dbMax = self.dbMax * 100.0

            dbCur_norm = self.exp10((dbCur - dbMax) / 6000.0)
            dbMin_norm = self.exp10((dbMin - dbMax) / 6000.0)

            vol = (dbCur_norm - dbMin_norm) / (1 - dbMin_norm)
            vol = int(round(vol * 100, 0))

            return vol
        else:
            return self.alsamixer.getvolume()[self.channel]

    def get_new_volume(self, direction):
        if direction == "inc":
            volume = (self.fdict["volume"] + 1) / 100
        elif direction == "dec":
            volume = (self.fdict["volume"] - 1) / 100

        dbMin = self.dbMin * 100
        dbMax = self.dbMax * 100

        dbMin_norm = self.exp10((dbMin - dbMax) / 6000.0)

        vol = volume * (1 - dbMin_norm) + dbMin_norm

        if direction == "inc":
            dbNew = min(self.dbMax, ceil(((6000.0 * log10(vol)) + dbMax) / 100))
#.........这里部分代码省略.........
开发者ID:Arcaena,项目名称:dotfiles,代码行数:103,代码来源:alsa_volume_toggle.py

示例7: ALSA

# 需要导入模块: from alsaaudio import Mixer [as 别名]
# 或者: from alsaaudio.Mixer import getmute [as 别名]
class ALSA(IntervalModule):
    """
    Shows volume of ALSA mixer. You can also use this for inputs, btw.

    Requires pyalsaaudio

    .. rubric:: Available formatters

    * `{volume}` — the current volume in percent
    * `{muted}` — the value of one of the `muted` or `unmuted` settings
    * `{card}` — the associated soundcard
    * `{mixer}` — the associated ALSA mixer
    """

    interval = 1

    settings = (
        "format",
        ("format_muted", "optional format string to use when muted"),
        ("mixer", "ALSA mixer"),
        ("mixer_id", "ALSA mixer id"),
        ("card", "ALSA sound card"),
        ("increment", "integer percentage of max volume to in/decrement volume on mousewheel"),
        "muted", "unmuted",
        "color_muted", "color",
        "channel"
    )

    muted = "M"
    unmuted = ""
    color_muted = "#AAAAAA"
    color = "#FFFFFF"
    format = "♪: {volume}"
    format_muted = None
    mixer = "Master"
    mixer_id = 0
    card = 0
    channel = 0
    increment = 5

    alsamixer = None
    has_mute = True

    on_upscroll = "increase_volume"
    on_downscroll = "decrease_volume"
    on_leftclick = "switch_mute"
    on_rightclick = on_leftclick

    def init(self):
        self.create_mixer()
        try:
            self.alsamixer.getmute()
        except ALSAAudioError:
            self.has_mute = False

        self.fdict = {
            "card": self.alsamixer.cardname(),
            "mixer": self.mixer,
        }

    def create_mixer(self):
        self.alsamixer = Mixer(
            control=self.mixer, id=self.mixer_id, cardindex=self.card)

    def run(self):
        self.create_mixer()

        muted = False
        if self.has_mute:
            muted = self.alsamixer.getmute()[self.channel] == 1

        self.fdict["volume"] = self.alsamixer.getvolume()[self.channel]
        self.fdict["muted"] = self.muted if muted else self.unmuted

        if muted and self.format_muted is not None:
            output_format = self.format_muted
        else:
            output_format = self.format

        self.output = {
            "full_text": output_format.format(**self.fdict),
            "color": self.color_muted if muted else self.color,
        }

    def switch_mute(self):
        if self.has_mute:
            muted = self.alsamixer.getmute()[self.channel]
            self.alsamixer.setmute(not muted)

    def increase_volume(self, delta=None):
        vol = self.alsamixer.getvolume()[self.channel]
        self.alsamixer.setvolume(min(100, vol + (delta if delta else self.increment)))

    def decrease_volume(self, delta=None):
        vol = self.alsamixer.getvolume()[self.channel]
        self.alsamixer.setvolume(max(0, vol - (delta if delta else self.increment)))
开发者ID:Gordin,项目名称:i3pystatus,代码行数:98,代码来源:alsa.py


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