當前位置: 首頁>>代碼示例>>Python>>正文


Python sunau.open方法代碼示例

本文整理匯總了Python中sunau.open方法的典型用法代碼示例。如果您正苦於以下問題:Python sunau.open方法的具體用法?Python sunau.open怎麽用?Python sunau.open使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sunau的用法示例。


在下文中一共展示了sunau.open方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_on_closed

# 需要導入模塊: import sunau [as 別名]
# 或者: from sunau import open [as 別名]
def test_on_closed(self):
        dsp = ossaudiodev.open('w')
        dsp.close()
        self.assertRaises(ValueError, dsp.fileno)
        self.assertRaises(ValueError, dsp.read, 1)
        self.assertRaises(ValueError, dsp.write, b'x')
        self.assertRaises(ValueError, dsp.writeall, b'x')
        self.assertRaises(ValueError, dsp.bufsize)
        self.assertRaises(ValueError, dsp.obufcount)
        self.assertRaises(ValueError, dsp.obufcount)
        self.assertRaises(ValueError, dsp.obuffree)
        self.assertRaises(ValueError, dsp.getptr)

        mixer = ossaudiodev.openmixer()
        mixer.close()
        self.assertRaises(ValueError, mixer.fileno) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:18,代碼來源:test_ossaudiodev.py

示例2: read_sound_file

# 需要導入模塊: import sunau [as 別名]
# 或者: from sunau import open [as 別名]
def read_sound_file(path):
    with open(path, 'rb') as fp:
        au = sunau.open(fp)
        rate = au.getframerate()
        nchannels = au.getnchannels()
        encoding = au._encoding
        fp.seek(0)
        data = fp.read()

    if encoding != sunau.AUDIO_FILE_ENCODING_MULAW_8:
        raise RuntimeError("Expect .au file with 8-bit mu-law samples")

    # Convert the data to 16-bit signed.
    data = audioop.ulaw2lin(data, 2)
    return (data, rate, 16, nchannels) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:17,代碼來源:test_ossaudiodev.py

示例3: play_sound_file

# 需要導入模塊: import sunau [as 別名]
# 或者: from sunau import open [as 別名]
def play_sound_file(self, data, rate, ssize, nchannels):
        try:
            dsp = ossaudiodev.open('w')
        except IOError, msg:
            if msg.args[0] in (errno.EACCES, errno.ENOENT,
                               errno.ENODEV, errno.EBUSY):
                raise unittest.SkipTest(msg)
            raise

        # at least check that these methods can be invoked 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:12,代碼來源:test_ossaudiodev.py

示例4: test_set_parameters

# 需要導入模塊: import sunau [as 別名]
# 或者: from sunau import open [as 別名]
def test_set_parameters(self):
        dsp = ossaudiodev.open("w")
        try:
            self.set_parameters(dsp)

            # Disabled because it fails under Linux 2.6 with ALSA's OSS
            # emulation layer.
            #self.set_bad_parameters(dsp)
        finally:
            dsp.close()
            self.assertTrue(dsp.closed) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:13,代碼來源:test_ossaudiodev.py

示例5: test_main

# 需要導入模塊: import sunau [as 別名]
# 或者: from sunau import open [as 別名]
def test_main():
    try:
        dsp = ossaudiodev.open('w')
    except (ossaudiodev.error, IOError), msg:
        if msg.args[0] in (errno.EACCES, errno.ENOENT,
                           errno.ENODEV, errno.EBUSY):
            raise unittest.SkipTest(msg)
        raise 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:10,代碼來源:test_ossaudiodev.py

示例6: test_with

# 需要導入模塊: import sunau [as 別名]
# 或者: from sunau import open [as 別名]
def test_with(self):
        with ossaudiodev.open('w') as dsp:
            pass
        self.assertTrue(dsp.closed) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:6,代碼來源:test_ossaudiodev.py


注:本文中的sunau.open方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。