Ambisonic format create/write

This commit is contained in:
Jamie Hardt
2020-12-26 13:52:52 -08:00
parent 3ab3a28d0e
commit 70bf402776
3 changed files with 21 additions and 6 deletions

View File

@@ -16,7 +16,7 @@ This is currently a work-in-progress! However many features presently work:
| Transparent promotion to RF64/BW64 | ☑️ | |
| Unified interface for regular and extended Wave format | ☑️ | |
| Channel/speaker map metadata | ☑️ | ☑️ |
| Ambisonic B-format metadata | ☑️ | |
| Ambisonic B-format metadata | ☑️ | ☑️ |
| EBU Broadcast-WAVE metadata | ☑️ | ☑️ |
| Basic iXML/ADM metadata | ☑️ | |
| Enhanced iXML metadata support | | |

View File

@@ -1,5 +1,5 @@
use uuid::Uuid;
use super::common_format::{CommonFormat, UUID_PCM};
use super::common_format::{CommonFormat, UUID_PCM,UUID_BFORMAT_PCM};
#[allow(dead_code)]
@@ -195,7 +195,22 @@ impl WaveFmt {
/// Create a new integer PCM format for ambisonic b-format.
pub fn new_pcm_ambisonic(sample_rate: u32, bits_per_sample: u16, channel_count: u16) -> Self {
todo!()
let container_bits_per_sample = bits_per_sample + (bits_per_sample % 8);
let container_bytes_per_sample= container_bits_per_sample / 8;
WaveFmt {
tag : 0xFFFE,
channel_count,
sample_rate,
bytes_per_second: container_bytes_per_sample as u32 * sample_rate * channel_count as u32,
block_alignment: container_bytes_per_sample * channel_count,
bits_per_sample: container_bits_per_sample,
extended_format: Some(WaveFmtExtended {
valid_bits_per_sample: bits_per_sample,
channel_mask: ChannelMask::DirectOut as u32,
type_guid: UUID_BFORMAT_PCM
})
}
}
/// Create a new integer PCM format `WaveFmt` with a custom channel bitmap.

View File

@@ -191,9 +191,9 @@ impl<W> WaveWriter<W> where W: Write + Seek {
/// Write Broadcast-Wave metadata to the file.
///
/// This function will write the metadata chunk immediately; if you have
/// already written and closed the audio data the bext chunk will be
/// positioned after it.
/// This function will write the metadata chunk immediately to the end of
/// the file; if you have already written and closed the audio data the
/// bext chunk will be positioned after it.
fn write_broadcast_metadata(self, bext: &Bext) -> Result<Self,Error> {
let mut b = self.chunk(BEXT_SIG)?;
b.write_bext(bext)?;