(즉, C의 limits.h에있는 SHRT_MAX) 의 부호있는 최대 정수는 어떻게 얻을 수 있습니까?Python에서 부호있는 최대 정수 찾기
*.wav
파일의 단일 채널에서 샘플을 정규화하려는 경우 16 비트 부호있는 정수 대신 여러 개의 부동 소수점을 1에서 -1 사이로 입력해야합니다. 모듈 SYS에
def samples(clip, chan_no = 0):
# *.wav files generally come in 8-bit unsigned ints or 16-bit signed ints
# python's wave module gives sample width in bytes, so STRUCT_FMT
# basically converts the wave.samplewidth into a struct fmt string
STRUCT_FMT = { 1 : 'B',
2 : 'h' }
for i in range(clip.getnframes()):
yield struct.unpack(STRUCT_FMT[clip.getsampwidth()] * clip.getnchannels(),
clip.readframes(1))[chan_no]
def normalized_samples(clip, chan_no = 0):
for sample in samples(clip, chan_no):
yield float(sample)/float(32767) ### THIS IS WHERE I NEED HELP
16 비트 샘플이면 가장 큰 일반 정수의 크기에 관계없이 32768로 나눕니다. 파이썬은 버전 3까지는 두 종류의 정수만 있고, "보통"제한된 크기의 int와 무제한 binint가 있습니다. 짧은 int 형식이 없습니다. –