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


Python ChannelMask.channels方法代码示例

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


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

示例1: __init__

# 需要导入模块: from audiotools import ChannelMask [as 别名]
# 或者: from audiotools.ChannelMask import channels [as 别名]
    def __init__(self, aiff_file,
                 sample_rate, channels, channel_mask, bits_per_sample,
                 chunk_length, process=None):
        """aiff_file should be rewound to the start of the SSND chunk."""

        alignment = AiffAudio.SSND_ALIGN.parse_stream(aiff_file)
        PCMReader.__init__(self,
                           file=__capped_stream_reader__(
                aiff_file,
                chunk_length - AiffAudio.SSND_ALIGN.sizeof()),
                           sample_rate=sample_rate,
                           channels=channels,
                           channel_mask=channel_mask,
                           bits_per_sample=bits_per_sample,
                           process=process,
                           signed=True,
                           big_endian=True)
        self.ssnd_chunk_length = chunk_length - 8
        standard_channel_mask = ChannelMask(self.channel_mask)
        aiff_channel_mask = AIFFChannelMask(standard_channel_mask)
        if (channels in (3, 4, 6)):
            self.channel_order = [aiff_channel_mask.channels().index(channel)
                                  for channel in
                                  standard_channel_mask.channels()]
        else:
            self.channel_order = None
开发者ID:bspeice,项目名称:Melodia,代码行数:28,代码来源:__aiff__.py

示例2: __init__

# 需要导入模块: from audiotools import ChannelMask [as 别名]
# 或者: from audiotools.ChannelMask import channels [as 别名]
    def __init__(self, aiff_file,
                 sample_rate, channels, channel_mask, bits_per_sample,
                 total_frames, process=None):
        """aiff_file should be a file-like object of aiff data

        sample_rate, channels, channel_mask and bits_per_sample are ints."""

        self.file = aiff_file
        self.sample_rate = sample_rate
        self.channels = channels
        self.channel_mask = channel_mask
        self.bits_per_sample = bits_per_sample
        self.remaining_frames = total_frames
        self.bytes_per_frame = self.channels * self.bits_per_sample / 8

        self.process = process

        from .bitstream import BitstreamReader

        #build a capped reader for the ssnd chunk
        aiff_reader = BitstreamReader(aiff_file, 0)
        try:
            (form, aiff) = aiff_reader.parse("4b 32p 4b")
            if (form != 'FORM'):
                raise InvalidAIFF(_(u"Not an AIFF file"))
            elif (aiff != 'AIFF'):
                raise InvalidAIFF(_(u"Invalid AIFF file"))

            while (True):
                (chunk_id, chunk_size) = aiff_reader.parse("4b 32u")
                if (chunk_id == 'SSND'):
                    #adjust for the SSND alignment
                    aiff_reader.skip(64)
                    break
                else:
                    aiff_reader.skip_bytes(chunk_size)
                    if (chunk_size % 2):
                        aiff_reader.skip(8)
        except IOError:
            self.read = self.read_error

        #handle AIFF unusual channel order
        standard_channel_mask = ChannelMask(self.channel_mask)
        aiff_channel_mask = AIFFChannelMask(standard_channel_mask)
        if (channels in (3, 4, 6)):
            self.channel_order = [aiff_channel_mask.channels().index(channel)
                                  for channel in
                                  standard_channel_mask.channels()]
        else:
            self.channel_order = None
开发者ID:bluemutedwisdom,项目名称:python-audio-tools,代码行数:52,代码来源:__aiff__.py

示例3: ChannelMask

# 需要导入模块: from audiotools import ChannelMask [as 别名]
# 或者: from audiotools.ChannelMask import channels [as 别名]
                 0x70f,    # FL, FC, FR, SL, SR, BC, LFE
                 0x63f)):  # FL, FC, FR, SL, SR, BL, BR, LFE

                standard_channel_mask = ChannelMask(pcmreader.channel_mask)
                vorbis_channel_mask = VorbisChannelMask(standard_channel_mask)
            else:
                raise UnsupportedChannelMask(filename,
                                             int(pcmreader.channel_mask))

            try:
                from . import ReorderedPCMReader

                transfer_framelist_data(
                    ReorderedPCMReader(
                        pcmreader,
                        [standard_channel_mask.channels().index(channel)
                         for channel in vorbis_channel_mask.channels()]),
                    sub.stdin.write)
            except (IOError, ValueError), err:
                sub.stdin.close()
                sub.wait()
                cls.__unlink__(filename)
                raise EncodingError(str(err))
            except Exception, err:
                sub.stdin.close()
                sub.wait()
                cls.__unlink__(filename)
                raise err

        else:
            raise UnsupportedChannelMask(filename,
开发者ID:R-a-dio,项目名称:python-audio-tools,代码行数:33,代码来源:vorbis.py

示例4: ChannelMask

# 需要导入模块: from audiotools import ChannelMask [as 别名]
# 或者: from audiotools.ChannelMask import channels [as 别名]
                0x37,  # FR, FC, FL, BL, BR
                0x3F,  # FR, FC, FL, BL, BR, LFE
                0x70F,  # FL, FC, FR, SL, SR, BC, LFE
                0x63F,
            ):  # FL, FC, FR, SL, SR, BL, BR, LFE

                standard_channel_mask = ChannelMask(pcmreader.channel_mask)
                vorbis_channel_mask = VorbisChannelMask(standard_channel_mask)
            else:
                raise UnsupportedChannelMask(filename, int(pcmreader.channel_mask))

            try:
                transfer_framelist_data(
                    ReorderedPCMReader(
                        pcmreader,
                        [standard_channel_mask.channels().index(channel) for channel in vorbis_channel_mask.channels()],
                    ),
                    sub.stdin.write,
                )
            except (IOError, ValueError), err:
                sub.stdin.close()
                sub.wait()
                cls.__unlink__(filename)
                raise EncodingError(str(err))
            except Exception, err:
                sub.stdin.close()
                sub.wait()
                cls.__unlink__(filename)
                raise err

        else:
开发者ID:atempcode1,项目名称:python-audio-tools,代码行数:33,代码来源:__vorbis__.py


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