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

Improve handling of AIFF-C compression type #62

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

AkiyukiOkayasu
Copy link
Owner

@AkiyukiOkayasu AkiyukiOkayasu commented Aug 23, 2024

In pacmog v0.4.2, the following AIFF-C compression types were supported:

pacmog/src/aiff.rs

Lines 72 to 77 in 80de8c2

b"NONE" => Ok(CompressionTypeId::None),
b"sowt" => Ok(CompressionTypeId::Sowt),
b"fl32" => Ok(CompressionTypeId::FL32),
b"FL32" => Ok(CompressionTypeId::FL32),
b"fl64" => Ok(CompressionTypeId::FL64),
b"FL64" => Ok(CompressionTypeId::FL64),

These types are compatible with most commonly used AIFF files. However, they are insufficient for certain edge cases:

  • twos (16bit big endian)
  • in24 (24bit big endian)
  • in32 (32bit big endian)
  • 42ni (24bit little endian)
  • 23ni (32bit little endian)

Related issues:

Additionally, there are rare cases where the bit-depth specified in the COMMON chunk does not match the bit-depth assumed by the compression type:

This PR improves the handling of AIFF-C compression types. If the compression type is present and not 'NONE', the bit-depth specified in the COMMON chunk is overwritten with the value corresponding to the compression type.

@AkiyukiOkayasu AkiyukiOkayasu added the bug Something isn't working label Aug 23, 2024
@AkiyukiOkayasu AkiyukiOkayasu merged commit 6f05316 into main Aug 23, 2024
2 of 3 checks passed
@AkiyukiOkayasu AkiyukiOkayasu deleted the aiff-c-compression-type branch August 23, 2024 05:56
@AkiyukiOkayasu
Copy link
Owner Author

List of supported compression types.

pacmog/src/aiff.rs

Lines 154 to 170 in 6f05316

fn aifc_compression_type(compression_type_id: &[u8]) -> Result<(AudioFormat, Option<u16>), ()> {
let t = match compression_type_id {
b"NONE" => (AudioFormat::LinearPcmBe, None),
b"twos" => (AudioFormat::LinearPcmBe, Some(16)),
b"sowt" => (AudioFormat::LinearPcmLe, Some(16)),
b"fl32" => (AudioFormat::IeeeFloatBe, Some(32)),
b"FL32" => (AudioFormat::IeeeFloatBe, Some(32)),
b"fl64" => (AudioFormat::IeeeFloatBe, Some(64)),
b"FL64" => (AudioFormat::IeeeFloatBe, Some(64)),
b"in24" => (AudioFormat::LinearPcmBe, Some(24)),
b"in32" => (AudioFormat::LinearPcmBe, Some(32)),
b"42ni" => (AudioFormat::LinearPcmLe, Some(24)),
b"23ni" => (AudioFormat::LinearPcmLe, Some(32)),
_ => return Err(()), //Unknown compression type
};
Ok(t)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant