Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Why would wave read be normalized ? #268

@Nitnelav

Description

@Nitnelav

Hi there !

I've spend a some time figuring it out but wav file read is normalized...
To me (as an acoustic engineer) it makes absolutely no sense :)
Especially since there are some calibrate_to and calibrate_with functions.
Am I missing something ? Why would you normalize on import ?

I ended up with the following code to read from the wave file :

import acoustics
import wave
from scipy.io import wavfile
file_path = "whatever.wav"
with wave.open(file_path, 'rb') as wav:
    sampwidth = wav.getsampwidth()
fs, data = wavfile.read(file_path) 
data = data / 2**(8*sampwidth-1)
signal= acoustics.Signal(data, fs=fs)

This works with S16_LE, S32_LE, S24_3LE formats (using the ALSA labelling) but would fail with S24_LE or FLOAT_LE .
It would be nice to have any wav red as a float array in the end.

I would be happy to contribute, I just want to make sure I didn't misunderstand an intentional design choice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions