Skip to content

tools: add waveio.py for wave file IO - #539

Merged
aiChaoSONG merged 1 commit into
thesofproject:masterfrom
aiChaoSONG:waveio
Jan 11, 2021
Merged

aiChaoSONG merged 1 commit into
thesofproject:masterfrom
aiChaoSONG:waveio

Conversation

@aiChaoSONG

Copy link
Copy Markdown

Currently, quality test for S24_LE is not covered,
because we are not able to read wave file of this
special format.

This patch adds an IO library for standard PCM
wave file.

Also, a light-weight format converter is implemented
in waveio.py.

Signed-off-by: Amery Song chao.song@intel.com

@marc-hb

marc-hb commented Dec 2, 2020 •

Copy link
Copy Markdown
Collaborator

Only two pylint warnings in https://travis-ci.org/github/thesofproject/sof-test/jobs/746929756, so close!

Can you add python3-numpy to the .travis.yml file and look at the other warning?

UPDATE: done in #540

@marc-hb
marc-hb requested a review from singalsu December 2, 2020 00:14

@marc-hb marc-hb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I'm worried that there is nothing automated using this script yet, any plans? If nothing else then a dead simple test script that converts a single, very small file and compares the output to a checked-in reference would provide infinitely (!) more test coverage. Maybe pytest could help with that, not sure. Code that never runs "bitrots": it stops working over time, either because dependencies change or because automation does not catch mistakes.

  • As a generic library, I think some pydoc is needed. It should be possible to do this interactively:

python3
>>> import waveio
>>> help(waveio.write_wav)

Prefixing internal functions with underscore would also be good.

  • When you looked for off-the-shelf options, did you see any project where this library could moved to in the future?

@aiChaoSONG

Copy link
Copy Markdown
Author

@marc-hb

  • below code is used to test the IO feature, I tried all supported formats, and compare data before and after in Octave/Matlab, the data before and after are identical!
x, fs = read_wave('wave_s16_le.wav')
write_wave("written_s16_le.wav", x, fs, 'S16_LE')
  • plans to use this: if you look into wavetool.py, you should see it is using scipy's IO to read and write wave file. and there is some limitations with scipy's IO: 1) S24_LE and S24_3LE are not supported; 2) the data read is int16 or int32 type, we need to normalize the data. This IO library behaves like Matlab's IO, but less wave file format supported.
  • currently, don't find any project that may want this library integrated. The key point of this library is to enable IO of S24_LE(S24_4LE), I don't find anyone or any project are interested in this format except SOF.

@marc-hb

marc-hb commented Dec 2, 2020

Copy link
Copy Markdown
Collaborator

I tried all supported formats, and compare data before and after in Octave/Matlab, the data before and after are identical!

If you could add some pytest that does some kind of comparison like this then we could run it in CI and it would be awesome. If you plan to use this in wavetool very soon then that's OK too. As long as something provides some minimal, automated test coverage then I think it's fine.

I'm curious why you needed Octave/matlab, was "diff" not enough?

The key point of this library is to enable IO of S24_LE(S24_4LE), I don't find anyone or any project are interested in this format except SOF.

Did you ask scipy people? It would probably take long so not for the short term but in the longer term you could become a scipy contributor :-)

Comment thread tools/waveio.py Outdated
Comment thread tools/waveio.py Outdated
@marc-hb

marc-hb commented Dec 3, 2020 •

Copy link
Copy Markdown
Collaborator

SOFCI TEST

UPDATE: that was an attempt to restart Travis after .travis.yml change #540 was merged. It didn't work.

@aiChaoSONG

Copy link
Copy Markdown
Author

@xiulipan @marc-hb @singalsu All reviews are addressed, please give more review or help to approve and merge.

singalsu
singalsu previously approved these changes Jan 8, 2021
Comment thread tools/waveio.py
Currently, quality test for S24_LE is not covered,
because we are not able to read wave file of this
special format.

This patch adds an IO library for standard PCM
wave file.

Also, a light-weight format converter is implemented
in waveio.py.

Signed-off-by: Amery Song <chao.song@intel.com>
@aiChaoSONG
aiChaoSONG merged commit 7d4e6f2 into thesofproject:master Jan 11, 2021
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

Successfully merging this pull request may close these issues.

5 participants