mirror of
https://github.com/iluvcapra/bwavfile.git
synced 2026-01-01 09:20:45 +00:00
Merge branch 'master' of https://github.com/iluvcapra/bwavfile
This commit is contained in:
18
src/cue.rs
18
src/cue.rs
@@ -281,7 +281,16 @@ pub struct Cue {
|
||||
pub label : Option<String>,
|
||||
|
||||
/// 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_start: 0,
|
||||
block_start: 0,
|
||||
frame_offset: cue.frame
|
||||
frame_offset: cue.offset
|
||||
};
|
||||
|
||||
let raw_label = cue.label.as_ref().map(|val| {
|
||||
@@ -380,10 +389,11 @@ impl Cue {
|
||||
//.filter_map(|x| str::from_utf8(&x.text).ok())
|
||||
.map(|s| convert_to_cue_string(&s.text))
|
||||
.next()
|
||||
}
|
||||
},
|
||||
offset: i.frame_offset
|
||||
}
|
||||
}).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 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 {
|
||||
fn from(error: io::Error) -> Error {
|
||||
|
||||
@@ -18,6 +18,7 @@ use byteorder::{WriteBytesExt, ReadBytesExt};
|
||||
/// `AudioProgramme`.
|
||||
///
|
||||
/// See BS.2088-1 § 8, also BS.2094, also blahblahblah...
|
||||
#[derive(Debug)]
|
||||
pub struct ADMAudioID {
|
||||
pub track_uid: [char; 12],
|
||||
pub channel_format_ref: [char; 14],
|
||||
@@ -28,6 +29,7 @@ pub struct ADMAudioID {
|
||||
///
|
||||
/// This information is correlated from the Wave format ChannelMap field and
|
||||
/// the `chna` chunk, if present.
|
||||
#[derive(Debug)]
|
||||
pub struct ChannelDescriptor {
|
||||
/// Index, the offset of this channel's samples in one frame.
|
||||
pub index: u16,
|
||||
|
||||
@@ -31,16 +31,11 @@ Apps we test against:
|
||||
- iZotope RX Audio Editor
|
||||
- FFMpeg
|
||||
- Audacity
|
||||
- Sound Devices field recorders: 702T, MixPre-10 II
|
||||
|
||||
[github]: https://github.com/iluvcapra/bwavfile
|
||||
*/
|
||||
|
||||
// #![feature(external_doc)]
|
||||
|
||||
// #[doc(include="../README.md")]
|
||||
// #[cfg(doctest)]
|
||||
// pub struct ReadmeDoctests;
|
||||
|
||||
extern crate encoding;
|
||||
extern crate byteorder;
|
||||
extern crate uuid;
|
||||
|
||||
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 {}",
|
||||
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);
|
||||
|
||||
inner.seek(Start(start))?;
|
||||
@@ -120,6 +120,29 @@ impl<R: Read + Seek> AudioFrameReader<R> {
|
||||
Ok( 0 )
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_float_frame(&mut self, buffer: &mut [f32]) -> Result<u64, Error> {
|
||||
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 )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Wave, Broadcast-WAV and RF64/BW64 parser/reader.
|
||||
|
||||
Reference in New Issue
Block a user