You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have observed that when playing back the waveform in certain audio players, the sound is routed only to the left speaker. This issue seems to occur when the player relies on the speaker channel mapping embedded in the audio file. Despite the audio file being mono, the playback is incorrectly mapped to a single speaker (left) rather than both speakers, resulting in no sound from the right speaker.
/// Generates a bitmask with `channels` ones in the least significant bits.
///
/// According to the [spec](https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ksmedia/ns-ksmedia-waveformatextensible#remarks),
/// if `channels` is greater than the number of bits in the channel mask, 18 non-reserved bits,
/// extra channels are not assigned to any physical speaker location. In this scenario, this
/// function will return a filled channel mask.
fnchannel_mask(channels:u16) -> u32{
// clamp to 0-18 to stay within reserved bits
(0..channels.clamp(0,18)asu32).map(|c| 1 << c).fold(0, |a, c| a | c)
}
#[test]
fnverify_channel_mask(){
assert_eq!(channel_mask(0), 0);
assert_eq!(channel_mask(1), 1);
assert_eq!(channel_mask(2), 3);
assert_eq!(channel_mask(3), 7);
assert_eq!(channel_mask(4), 0xF);
assert_eq!(channel_mask(8), 0xFF);
assert_eq!(channel_mask(16), 0xFFFF);
// expect channels >= 18 to yield the same mask
assert_eq!(channel_mask(18), 0x3FFFF);
assert_eq!(channel_mask(32), 0x3FFFF);
assert_eq!(channel_mask(64), 0x3FFFF);
assert_eq!(channel_mask(129), 0x3FFFF);
}
The text was updated successfully, but these errors were encountered:
rubeniskov
changed the title
mapping SPEAKER_FRONT_LEFT speaker by default when single channel instead of SPEAKER_FRONT_CENTER
mapping SPEAKER_FRONT_LEFT by default when single channel instead of SPEAKER_FRONT_CENTER
Nov 9, 2024
I have observed that when playing back the waveform in certain audio players, the sound is routed only to the left speaker. This issue seems to occur when the player relies on the speaker channel mapping embedded in the audio file. Despite the audio file being mono, the playback is incorrectly mapped to a single speaker (left) rather than both speakers, resulting in no sound from the right speaker.
It seems the problem came from the assumption of mapping by default the number of channels to a certain speaker which for 1 channel only should be 0x4
hound/src/write.rs
Lines 124 to 149 in b5b6fbd
The text was updated successfully, but these errors were encountered: