-
-
Notifications
You must be signed in to change notification settings - Fork 213
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
Implemented WAV source, sink and backend #659
Conversation
🤖 Upon creation, pull request description does not have a link to an issue. If there is a related issue, please add it to the description using any of the supported formats. |
Thanks for PR! Will review in upcoming days! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch, here are a few comments.
memcpy(header_data + offset, &chunk_id_, sizeof(chunk_id_)); | ||
offset += sizeof(chunk_id_); | ||
memcpy(header_data + offset, &chunk_size_, sizeof(chunk_size_)); | ||
offset += sizeof(chunk_size_); | ||
memcpy(header_data + offset, &format_, sizeof(format_)); | ||
offset += sizeof(format_); | ||
memcpy(header_data + offset, &subchunk1_id_, sizeof(subchunk1_id_)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the code can be simpler and shorter if we would make WavHeader a struct and write it directly to file?
Currently we're defining all fields in .h and then repeating all fields in this function, which doubles the code size. Instead, we could just fwrite() the whole struct.
We'd need to use ROC_ATTR_PACKED_BEGIN/ROC_ATTR_PACKED_END for the struct to ensure that compiler does not insert any padding.
If WavHeader becomes a struct, I guess we can define in directly in wav_sink.cpp (in anon namespace), since it will be small and won't be used anywhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've decided to leave this class but move header data to a POD struct, which memory is this time managed by the WavHeader
instead of the user, so it should be cheaper to use it. In case of inclusion of some other, extra parameters to the header, it should be a bit easier to extend this class.
Technically the number of samples written so far can be stored in WavSink
, so I'm not really set on any of those solutions, because they're similarly good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think current version is nice!
Thanks for detailed review and finding all those issues! I've updated the commit and fixed mentioned problems. |
Thanks, It seems you forgot to commit your changes or pushed a wrong commit? Seems that the new cimmit is identical to the old one. |
Hi, I've pushed commit 03d29eb to develop branch that adds new fields sample_format and pcm_format to SampleSpec. It mostly does not affect this PR, but SampleSpec ctor now has new parameter pcm_format, which you can just set to audio::Sample_RawFormat (which means that source/sink produces/consumes samples in "raw" format - 32-bit PCM floats). So please rebase on fresh develop. |
fb07872
to
e377951
Compare
It's rebased and adjusted to newest changes on develop branch. I must've not force pushed the amended commit and not noticed that. |
Thanks, looks and works great! I've pushed a small follow-up commit: fc0fab2 Changes:
|
We also forgot one small thing, I've created a new issue for it: #684 |
Implemented issue: 576
dr_wav
single header library,dr_wav
,WavHeader
to store and handle headers of written WAV files,