mirror of
https://github.com/iluvcapra/bwavfile.git
synced 2026-01-02 09:50:44 +00:00
Ambisonic format create/write
This commit is contained in:
@@ -16,7 +16,7 @@ This is currently a work-in-progress! However many features presently work:
|
|||||||
| Transparent promotion to RF64/BW64 | ☑️ | |
|
| Transparent promotion to RF64/BW64 | ☑️ | |
|
||||||
| Unified interface for regular and extended Wave format | ☑️ | |
|
| Unified interface for regular and extended Wave format | ☑️ | |
|
||||||
| Channel/speaker map metadata | ☑️ | ☑️ |
|
| Channel/speaker map metadata | ☑️ | ☑️ |
|
||||||
| Ambisonic B-format metadata | ☑️ | |
|
| Ambisonic B-format metadata | ☑️ | ☑️ |
|
||||||
| EBU Broadcast-WAVE metadata | ☑️ | ☑️ |
|
| EBU Broadcast-WAVE metadata | ☑️ | ☑️ |
|
||||||
| Basic iXML/ADM metadata | ☑️ | |
|
| Basic iXML/ADM metadata | ☑️ | |
|
||||||
| Enhanced iXML metadata support | | |
|
| Enhanced iXML metadata support | | |
|
||||||
|
|||||||
19
src/fmt.rs
19
src/fmt.rs
@@ -1,5 +1,5 @@
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use super::common_format::{CommonFormat, UUID_PCM};
|
use super::common_format::{CommonFormat, UUID_PCM,UUID_BFORMAT_PCM};
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
||||||
@@ -195,7 +195,22 @@ impl WaveFmt {
|
|||||||
|
|
||||||
/// Create a new integer PCM format for ambisonic b-format.
|
/// 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 {
|
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.
|
/// Create a new integer PCM format `WaveFmt` with a custom channel bitmap.
|
||||||
|
|||||||
@@ -191,9 +191,9 @@ impl<W> WaveWriter<W> where W: Write + Seek {
|
|||||||
|
|
||||||
/// Write Broadcast-Wave metadata to the file.
|
/// Write Broadcast-Wave metadata to the file.
|
||||||
///
|
///
|
||||||
/// This function will write the metadata chunk immediately; if you have
|
/// This function will write the metadata chunk immediately to the end of
|
||||||
/// already written and closed the audio data the bext chunk will be
|
/// the file; if you have already written and closed the audio data the
|
||||||
/// positioned after it.
|
/// bext chunk will be positioned after it.
|
||||||
fn write_broadcast_metadata(self, bext: &Bext) -> Result<Self,Error> {
|
fn write_broadcast_metadata(self, bext: &Bext) -> Result<Self,Error> {
|
||||||
let mut b = self.chunk(BEXT_SIG)?;
|
let mut b = self.chunk(BEXT_SIG)?;
|
||||||
b.write_bext(bext)?;
|
b.write_bext(bext)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user