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

Full RIFF/WAVE support with ID3 tags #408

Merged
merged 15 commits into from
May 4, 2020

Conversation

phw
Copy link
Collaborator

@phw phw commented Oct 22, 2019

This adds support for reading / parsing WAVE files and tagging them using ID3 tags.

This is #321 with history a little bit cleaned up and refactoring applied to address the issues discussed in #392. I opened a new PR as this is now easier to handle for me in my own fork.

The code was refactored so the RIFF code can now completely read the hierarchical RIFF chunk structure. There is explicit support for LIST chunks which can contain subchunks. Since the hierarchy is properly handled the code can now safely support multiple chunk insert / resize / delete operations while keeping the in-memory representation of all offsets and sizes intact. Also reading and writing the padding bytes is now all handled (previously this considered only a few special cases). You can now do things like this safely and it will all do the correct things:

f = RiffFile(open('somepath'), 'rb+')
f['id3'].resize(200)
f.insert_chunk('TEST', b'some data')
f['id3'].delete()

The relevant changes for this are in d326665 (padding bytes fixed) and bc8e150 (handling of the hierarchy and updating sizes / offsets after chunk changes).

Also handling of a LIST INFO chunk could now be easily implemented. The basic RIFF classes would support something like this to read the info:

f = RiffFile(open('somepath'), 'rb+')
info = riff[u'LIST']
info_tags = {}
for chunk in info.subchunks():
    info_tags[chunk.id] = chunk.read().decode().strip('\0')

Or creating an info chunk:

info = f.insert_chunk('LIST', b'INFO')
info.insert_chunk('IART', b'The Artist\x00')

The low level code is all there, so a higher level API for this could be added. But I intentionally left this out of this PR, I am not sure about a proper API for this yet. One option would be to handle this somewhat like ID3v1 is handled by having an option that automatically saves the INFO tag based on ID3 data.

@lazka @Borewit @maybeRainH I consider this now ready for review and testing, your help here is very welcomed.

Next up on my todo list is applying the refactoring here also to the AIFF code, which is plagued by the same issues of not fully handling padding bytes and damaging the files if multiple chunk changing operations are applied in one go.

@Borewit
Copy link
Contributor

Borewit commented Oct 22, 2019

Very nice job @phw! I need to find some time to look at it in detail.

@phw phw force-pushed the feature/riff-wave-id3 branch 2 times, most recently from cc9981e to 3fbca92 Compare October 23, 2019 06:52
@phw
Copy link
Collaborator Author

phw commented Oct 23, 2019

See #409 for the corresponding AIFF changes.

@phw phw force-pushed the feature/riff-wave-id3 branch 3 times, most recently from 4a302a1 to b6a94d2 Compare October 23, 2019 19:45
@phw
Copy link
Collaborator Author

phw commented Oct 24, 2019

I hacked some experimental INFO chunk reading / writing into my Picard branch for WAVE support and used this to test the tagging. I added / removed / updated the ID3 chunk, the INFO chunk and individual INFO chunk elements. Did this in combination with foobar2000 and also checked the results in other tools (Windows Explorer, Totem, VLC, WMP). The data could always be read, the files kept a valid structure. I think the current state of this branch is stable.

@phw phw force-pushed the feature/riff-wave-id3 branch from 3ac4721 to 2e6ad62 Compare November 15, 2019 09:39
@phw
Copy link
Collaborator Author

phw commented Nov 15, 2019

Rebased against current master and fixed merged conflict

@phw phw force-pushed the feature/riff-wave-id3 branch from 2e6ad62 to 234ac31 Compare November 18, 2019 07:43
@phw
Copy link
Collaborator Author

phw commented Nov 18, 2019

Fixed merge conflict

@Borewit
Copy link
Contributor

Borewit commented Nov 18, 2019

Come on, hit that green button @lazka.

@Christilut
Copy link

Can this get merged? Would be great! :)

@phw phw force-pushed the feature/riff-wave-id3 branch from 234ac31 to 6504040 Compare January 3, 2020 14:35
@phw phw force-pushed the feature/riff-wave-id3 branch from 6504040 to 3dd764f Compare February 10, 2020 10:52
@phw
Copy link
Collaborator Author

phw commented Feb 10, 2020

@lazka Now that a new release with fixes is out, could we finally get this merged? :)

The failing tests seem to be unrelated to this PR and kind of random.

@Borewit
Copy link
Contributor

Borewit commented Feb 10, 2020

This merge takes way to long (originates from Aug 17, 2017, #321), I am sorry @lazka, this is just disrespectful to the contributors. Significant effort has been put in this work. If you don't merge for whatever reason, then at least have the courtesy to provide clarity what is causing the delay.

@phw phw requested a review from lazka February 10, 2020 13:56
@phw phw force-pushed the feature/riff-wave-id3 branch from 3dd764f to b3f8459 Compare March 13, 2020 13:00
@phw phw force-pushed the feature/riff-wave-id3 branch from b3f8459 to 4b1544c Compare May 3, 2020 12:28
@phw
Copy link
Collaborator Author

phw commented May 3, 2020

I updated the branch for the latest code changes.

@lazka lazka merged commit 9642ddf into quodlibet:master May 4, 2020
@phw phw deleted the feature/riff-wave-id3 branch May 4, 2020 18:28
@Borewit
Copy link
Contributor

Borewit commented May 5, 2020

Very nice work @phw, thank you so much for completing this.

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.

4 participants