Adding extended precision ByteVector conversion for AIFF sample rate #245
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description: During my port of taglib# to node, I noticed a long string of logic for determining the sample rate for AIFF files. Since it's not uncommon for sample rates to be stored in a table, I didn't think much of it. However, while working on writing unit tests for the
Aiff.StremHeader
class, I wanted to double check the AIFF spec to see if there were any more sample rates, since it seemed odd that AIFF could only support a max sample rate of 64kHz when 96kHz and 192kHz files are all the rage these days. Turns out the AIFF spec uses an 80-bit IEEE 754 extended precision floating point number for storing the sample rate (http://muratnkonar.com/aiff/index.html), not a lookup table of sample rates. What's more, I've seen Apple users mention that 96kHz AIFF files exist (https://discussions.apple.com/thread/7273841). Therefore, the existing logic is going to give faulty duration and sample rate values for AIFF files with sample rates > 64kHz.The proposed solution in this PR is to add logic for converting a
ByteVector
into a IEEE 754 extended precision floating point value, expressed as a double. TheAiff.StreamHeader
class has been updated to use this to get the full sample rate. The basis for this logic was from http://www33146ue.sakura.ne.jp/staff/iz/formats/ieee.cSince this is the only usage of this new method, I'm open to storing it somewhere other than the
ByteVector
class.Testing:
ByteVector
method, but I'm not entirely sure how to fit it into the existing set of tests for the class. Any suggestions would be welcome.