mirror of
https://github.com/iluvcapra/bwavfile.git
synced 2026-01-01 09:20:45 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69fd5f310c | ||
|
|
a8bb5e8c8e | ||
|
|
468ed12304 | ||
|
|
a015d7cf8a | ||
|
|
e89e87045c | ||
|
|
ecc1db703d | ||
|
|
4cd28c9efe | ||
|
|
663b9fad43 | ||
|
|
9fe741d913 | ||
|
|
2ecae51e8d | ||
|
|
56dc4d1048 | ||
|
|
1af4c675c7 |
30
Cargo.lock
generated
30
Cargo.lock
generated
@@ -22,13 +22,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.2.1"
|
version = "1.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bwavfile"
|
name = "bwavfile"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -124,24 +124,24 @@ checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.1.18"
|
version = "0.1.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c"
|
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "0.4.7"
|
version = "0.4.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.97"
|
version = "0.2.103"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"
|
checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
@@ -151,15 +151,15 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.126"
|
version = "1.0.130"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03"
|
checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.64"
|
version = "1.0.68"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
|
checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"ryu",
|
"ryu",
|
||||||
@@ -183,9 +183,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-width"
|
name = "unicode-width"
|
||||||
version = "0.1.8"
|
version = "0.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
|
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "bwavfile"
|
name = "bwavfile"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
authors = ["Jamie Hardt <jamiehardt@me.com>"]
|
authors = ["Jamie Hardt <jamiehardt@me.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|||||||
@@ -25,13 +25,14 @@ reading and creating new audio files respectively.
|
|||||||
* Broadcast-Wave metdata extension, including long description, originator
|
* Broadcast-Wave metdata extension, including long description, originator
|
||||||
information, SMPTE UMID and coding history.
|
information, SMPTE UMID and coding history.
|
||||||
* Reading and writing of embedded iXML and axml/ADM metadata.
|
* Reading and writing of embedded iXML and axml/ADM metadata.
|
||||||
* Reading and writing of timed cues and and timed cue region.
|
* Reading and writing of timed cues and and timed cue regions.
|
||||||
|
|
||||||
### Feature Roadmap
|
### Feature Roadmap
|
||||||
|
|
||||||
Some features that may be included in the future include:
|
Some features that may be included in the future include:
|
||||||
* Broadcast-Wave `levl` waveform overview data reading and writing.
|
* Broadcast-Wave `levl` waveform overview data reading and writing.
|
||||||
* Sampler and Instrument mentadata.
|
* Sampler and Instrument metadata.
|
||||||
|
* Performance improvements.
|
||||||
|
|
||||||
|
|
||||||
## Use Examples
|
## Use Examples
|
||||||
|
|||||||
16
src/cue.rs
16
src/cue.rs
@@ -281,7 +281,16 @@ pub struct Cue {
|
|||||||
pub label : Option<String>,
|
pub label : Option<String>,
|
||||||
|
|
||||||
/// The text "note"/comment of this marker if provided
|
/// The text "note"/comment of this marker if provided
|
||||||
pub note : Option<String>
|
pub note : Option<String>,
|
||||||
|
|
||||||
|
/// The offser of this marker
|
||||||
|
///
|
||||||
|
/// **Note:** Applications use the `frame` and `offset` fields
|
||||||
|
/// in different ways. iZotope RX Audio Editor writes the
|
||||||
|
/// marker position to *both* fields, while a Sound Devices
|
||||||
|
/// recorder writes the marker position to *only* the `offset`
|
||||||
|
/// field.
|
||||||
|
pub offset : u32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -306,7 +315,7 @@ impl Cue {
|
|||||||
chunk_id: DATA_SIG,
|
chunk_id: DATA_SIG,
|
||||||
chunk_start: 0,
|
chunk_start: 0,
|
||||||
block_start: 0,
|
block_start: 0,
|
||||||
frame_offset: cue.frame
|
frame_offset: cue.offset
|
||||||
};
|
};
|
||||||
|
|
||||||
let raw_label = cue.label.as_ref().map(|val| {
|
let raw_label = cue.label.as_ref().map(|val| {
|
||||||
@@ -380,7 +389,8 @@ impl Cue {
|
|||||||
//.filter_map(|x| str::from_utf8(&x.text).ok())
|
//.filter_map(|x| str::from_utf8(&x.text).ok())
|
||||||
.map(|s| convert_to_cue_string(&s.text))
|
.map(|s| convert_to_cue_string(&s.text))
|
||||||
.next()
|
.next()
|
||||||
}
|
},
|
||||||
|
offset: i.frame_offset
|
||||||
}
|
}
|
||||||
}).collect()
|
}).collect()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use std::io;
|
use std::{fmt::{Debug,Display}, io};
|
||||||
|
use std::error::Error as StdError;
|
||||||
use super::fourcc::FourCC;
|
use super::fourcc::FourCC;
|
||||||
|
|
||||||
use uuid;
|
use uuid;
|
||||||
@@ -43,6 +44,14 @@ pub enum Error {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl StdError for Error {}
|
||||||
|
|
||||||
|
impl Display for Error {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
Debug::fmt(self, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
impl From<io::Error> for Error {
|
impl From<io::Error> for Error {
|
||||||
fn from(error: io::Error) -> Error {
|
fn from(error: io::Error) -> Error {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use byteorder::{WriteBytesExt, ReadBytesExt};
|
|||||||
/// `AudioProgramme`.
|
/// `AudioProgramme`.
|
||||||
///
|
///
|
||||||
/// See BS.2088-1 § 8, also BS.2094, also blahblahblah...
|
/// See BS.2088-1 § 8, also BS.2094, also blahblahblah...
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct ADMAudioID {
|
pub struct ADMAudioID {
|
||||||
pub track_uid: [char; 12],
|
pub track_uid: [char; 12],
|
||||||
pub channel_format_ref: [char; 14],
|
pub channel_format_ref: [char; 14],
|
||||||
@@ -28,6 +29,7 @@ pub struct ADMAudioID {
|
|||||||
///
|
///
|
||||||
/// This information is correlated from the Wave format ChannelMap field and
|
/// This information is correlated from the Wave format ChannelMap field and
|
||||||
/// the `chna` chunk, if present.
|
/// the `chna` chunk, if present.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct ChannelDescriptor {
|
pub struct ChannelDescriptor {
|
||||||
/// Index, the offset of this channel's samples in one frame.
|
/// Index, the offset of this channel's samples in one frame.
|
||||||
pub index: u16,
|
pub index: u16,
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ Apps we test against:
|
|||||||
- iZotope RX Audio Editor
|
- iZotope RX Audio Editor
|
||||||
- FFMpeg
|
- FFMpeg
|
||||||
- Audacity
|
- Audacity
|
||||||
|
- Sound Devices field recorders: 702T, MixPre-10 II
|
||||||
|
|
||||||
[github]: https://github.com/iluvcapra/bwavfile
|
[github]: https://github.com/iluvcapra/bwavfile
|
||||||
*/
|
*/
|
||||||
|
|||||||
3
src/wavebuffer.rs
Normal file
3
src/wavebuffer.rs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
pub struct WaveBuffer {
|
||||||
|
pub format : WaveFmt
|
||||||
|
}
|
||||||
@@ -50,7 +50,7 @@ impl<R: Read + Seek> AudioFrameReader<R> {
|
|||||||
"Unable to read audio frames from packed formats: block alignment is {}, should be {}",
|
"Unable to read audio frames from packed formats: block alignment is {}, should be {}",
|
||||||
format.block_alignment, (format.bits_per_sample / 8 ) * format.channel_count);
|
format.block_alignment, (format.bits_per_sample / 8 ) * format.channel_count);
|
||||||
|
|
||||||
assert!(format.common_format() == CommonFormat::IntegerPCM ,
|
assert!(format.common_format() == CommonFormat::IntegerPCM || format.common_format() == CommonFormat::IeeeFloatPCM,
|
||||||
"Unsupported format tag {:?}", format.tag);
|
"Unsupported format tag {:?}", format.tag);
|
||||||
|
|
||||||
inner.seek(Start(start))?;
|
inner.seek(Start(start))?;
|
||||||
@@ -121,8 +121,27 @@ impl<R: Read + Seek> AudioFrameReader<R> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_float_frame(&mut self, buffer:&mut [f32]) -> Result<u64, Error> {
|
pub fn read_float_frame(&mut self, buffer: &mut [f32]) -> Result<u64, Error> {
|
||||||
todo!()
|
assert!(buffer.len() as u16 == self.format.channel_count,
|
||||||
|
"read_float_frame was called with a mis-sized buffer, expected {}, was {}",
|
||||||
|
self.format.channel_count, buffer.len());
|
||||||
|
|
||||||
|
let framed_bits_per_sample = self.format.block_alignment * 8 / self.format.channel_count;
|
||||||
|
|
||||||
|
let tell = self.inner.seek(Current(0))?;
|
||||||
|
|
||||||
|
if (tell - self.start) < self.length {
|
||||||
|
for n in 0..(self.format.channel_count as usize) {
|
||||||
|
buffer[n] = match (self.format.bits_per_sample, framed_bits_per_sample) {
|
||||||
|
(25..=32,32) => self.inner.read_f32::<LittleEndian>()?,
|
||||||
|
(b,_)=> panic!("Unrecognized integer format, bits per sample {}, channels {}, block_alignment {}",
|
||||||
|
b, self.format.channel_count, self.format.block_alignment)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok( 1 )
|
||||||
|
} else {
|
||||||
|
Ok( 0 )
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ fn test_channels_stereo_no_fmt_extended() {
|
|||||||
assert_eq!(channels[1].speaker,ChannelMask::FrontRight);
|
assert_eq!(channels[1].speaker,ChannelMask::FrontRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//See issue 6 and 7
|
///See issue 6 and 7
|
||||||
#[test]
|
#[test]
|
||||||
fn test_frame_reader_consumes_reader() {
|
fn test_frame_reader_consumes_reader() {
|
||||||
// Issue #6
|
// Issue #6
|
||||||
@@ -176,3 +176,47 @@ fn test_frame_reader_consumes_reader() {
|
|||||||
|
|
||||||
let _result = from_wav_filename("tests/media/pt_24bit_stereo.wav").unwrap();
|
let _result = from_wav_filename("tests/media/pt_24bit_stereo.wav").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///See to PR#10
|
||||||
|
#[test]
|
||||||
|
fn test_cue_read_sounddevices() {
|
||||||
|
let mut f = WaveReader::open("tests/media/sounddevices_6_cue_points.wav").unwrap();
|
||||||
|
let cue_points = f.cue_points().unwrap();
|
||||||
|
assert_eq!(cue_points.len(), 6);
|
||||||
|
|
||||||
|
assert_eq!(cue_points[0].frame, 0);
|
||||||
|
assert_eq!(cue_points[0].length, None);
|
||||||
|
assert_eq!(cue_points[0].label, None);
|
||||||
|
assert_eq!(cue_points[0].note, None);
|
||||||
|
assert_eq!(cue_points[0].offset, 90112);
|
||||||
|
|
||||||
|
assert_eq!(cue_points[1].frame, 0);
|
||||||
|
assert_eq!(cue_points[1].length, None);
|
||||||
|
assert_eq!(cue_points[1].label, None);
|
||||||
|
assert_eq!(cue_points[1].note, None);
|
||||||
|
assert_eq!(cue_points[1].offset, 176128);
|
||||||
|
|
||||||
|
assert_eq!(cue_points[2].frame, 0);
|
||||||
|
assert_eq!(cue_points[2].length, None);
|
||||||
|
assert_eq!(cue_points[2].label, None);
|
||||||
|
assert_eq!(cue_points[2].note, None);
|
||||||
|
assert_eq!(cue_points[2].offset, 237568);
|
||||||
|
|
||||||
|
assert_eq!(cue_points[3].frame, 0);
|
||||||
|
assert_eq!(cue_points[3].length, None);
|
||||||
|
assert_eq!(cue_points[3].label, None);
|
||||||
|
assert_eq!(cue_points[3].note, None);
|
||||||
|
assert_eq!(cue_points[3].offset, 294912);
|
||||||
|
|
||||||
|
assert_eq!(cue_points[4].frame, 0);
|
||||||
|
assert_eq!(cue_points[4].length, None);
|
||||||
|
assert_eq!(cue_points[4].label, None);
|
||||||
|
assert_eq!(cue_points[4].note, None);
|
||||||
|
assert_eq!(cue_points[4].offset, 380928);
|
||||||
|
|
||||||
|
assert_eq!(cue_points[5].frame, 0);
|
||||||
|
assert_eq!(cue_points[5].length, None);
|
||||||
|
assert_eq!(cue_points[5].label, None);
|
||||||
|
assert_eq!(cue_points[5].note, None);
|
||||||
|
assert_eq!(cue_points[5].offset, 385024);
|
||||||
|
}
|
||||||
Binary file not shown.
Reference in New Issue
Block a user