Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion of audio data to numpy array seems to be buggy... #2

Open
ginsi opened this issue Feb 19, 2018 · 2 comments
Open

Conversion of audio data to numpy array seems to be buggy... #2

ginsi opened this issue Feb 19, 2018 · 2 comments
Assignees

Comments

@ginsi
Copy link

ginsi commented Feb 19, 2018

The two steps conversion of audio data to numpy array seems buggy to me.
It should take into account (and afaik it does not) that the most significant bit of every second byte has negative weight (i.e. the numeric representation is in two's complement).
Perhaps a good starting point is to use this one step conversion
data_np = np.frombuffer(data_inp, dtype='<i2')
which lands in the range [-32768..+32767] and add an offset if desired

@markjay4k
Copy link
Owner

yes, the method I used for converting the audio data is probably not the best. I was thinking of switching to

np.fromstring(data_int)

@markjay4k markjay4k self-assigned this Feb 19, 2018
@markjay4k
Copy link
Owner

I just tried your suggestion of using np.frombuffer(data_int, dtype='<i2') and it's working nicely. I will update the files to use that instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants