Skip to content

several WavPack import/export fixes - #3330

Merged
crsib merged 8 commits into
audacity:masterfrom
dbry:wavpack-repairs
Aug 3, 2022
Merged

crsib merged 8 commits into
audacity:masterfrom
dbry:wavpack-repairs

Conversation

@dbry

@dbry dbry commented Aug 2, 2022

Copy link
Copy Markdown
Contributor

Hi Audacity team!

First I would like to thank the Audacity team, and particularly @Subhra264, for integrating WavPack into Audacity. Great work!

Unfortunately at the time I was not aware that this was ongoing because I found out about it the day it was committed to master. I'm sure that if I'd been aware I could have helped it along and perhaps saved some headaches. But in any event, I have been testing it now for the past week or so and have discovered and and fixed some minor issues and put together these eight commits.

Probably the easiest way to review them is to look at the individual commits. Most of them were pretty trivial to find (like files from the official WavPack test suite that simply would not load), and while I'm happy to go into more detail, these should all be pretty self-explanatory. One issue, however, requires a little more explanation.

The hybrid mode of WavPack was configured with a bitrate from 16 - 384 kbps (kbits per second). The problem with this is that this fixed range does not take into account the sample rate and number of channels (which directly affect the bitrates available), and therefore presents sometimes inappropriate values. For example, with 24/96 stereo audio the minimum bitrate that the hybrid mode will work at is around 430 kbps, and 6-channel, 48-kHz audio will only go down to 650 kbps. So for these common audio formats the entire range of presented bitrates is too low, which essentially makes the feature useless.

The solution I came up with is to present the bitrate in bits per sample instead, ranging from 2.2 (the minimum the hybrid mode will operate) to 8.0 (the practical upper limit which is always audibly transparent). I believe that this makes the feature usable while still presenting something easily understood by the user.

Please let me know if I can explain any of these changes more fully, and thanks again for this contribution!

  • I signed CLA
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

@crsib
crsib self-requested a review August 2, 2022 08:36
n.mb_str(wxConvUTF8),
v.mb_str(wxConvUTF8),
static_cast<int>( v.length() ));
static_cast<int>( strlen(v.mb_str(wxConvUTF8)) ));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great catch!

Comment on lines +113 to 114
wxLogDebug("WavpackOpenFileInput() failed on file %s, error = %s", filename, errMessage);
return nullptr;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably wxLogError is a better idea. wxLogDebug does not generate any user visible output really.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't really intend this for the user, especially because this gets triggered any time the WavPack importer is invoked to check whether some random file is importable. However, it might be useful for debugging if libwavpack refuses to open a file that it should be able to.

itemLen = WavpackGetTagItemIndexed(mWavPackContext, i, NULL, 0);
std::string item (itemLen + 1, '\0');
WavpackGetTagItemIndexed(mWavPackContext, i, item.data(), itemLen + 1);
item.resize(itemLen); // remove terminating NULL from std::string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure why do is this needed. This is safe here, though, so nothing critical

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not a regular C++ programmer and just discovered that std::strings can include terminating NULLs. The issue this caused was that when the tag name had a NULL at the end it would no longer match the same string without a NULL. So, for example, this line did not work as intended:

mGrid->SetCellValue(i, 1, mLocal.GetTag(labelmap[i].name));

@crsib
crsib merged commit f27f914 into audacity:master Aug 3, 2022
@dbry

dbry commented Aug 3, 2022

Copy link
Copy Markdown
Contributor Author

@crsib Thanks for the prompt review and merge! I'll continue testing, but I think this is pretty good at this point.

@crsib

crsib commented Aug 4, 2022

Copy link
Copy Markdown
Contributor

@dbry thank you a lot for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants