본문 바로가기

개발자 레니는 지금 -/소프트웨어와 함께

[ MODULE ] audioop:: pcm data 모노, 스테레오 정보 바꾸기


Python

Audioop:: Manipulate raw audio data

#Ubuntu 16.04 LTS

#Python 3.5.2


#>> 상세 설명,  실행화면



audioop

The audioop module contains some useful operations on sound fragments. It operates on sound fragments consisting of signed integer samples 8, 16 or 32 bits wide, stored in Python strings. This is the same format as used by the al and sunaudiodev modules. All scalar items are integers, unless specified otherwise.



This module provides support for a-LAW, u-LAW and Intel/DVI ADPCM encodings.



A few of the more complicated operations only take 16-bit samples, otherwise, the sample size (in bytes) is always a parameter of the operation.



사용방법

import audioop


def stereo_to_mono(data, width=2):

lsample = audioop.tomono(data, width, 1, 0)

rsample = audioop.tomono(data, width, 0, 1)

return audioop.add(lsample, rsample, width)


def mono_to_stereo(data, width=1):

lsample = audioop.tostereo(data, width, 1, 0)

rsample = audioop.tostereo(data, width, 0, 1)

return audioop.add(lsample, rsample, width)





#2018년07월17일