24 Commits

Author SHA1 Message Date
Jamie Hardt
69fd5f310c Fixed some typos in this 2021-09-28 13:49:04 -07:00
Jamie Hardt
a8bb5e8c8e Update to version 1.1 2021-09-28 13:46:34 -07:00
Jamie Hardt
468ed12304 Merge pull request #10 from atoav/cuepoints
Surface cue frame_offset field in UI and test for sounddevices files.
2021-09-28 13:39:09 -07:00
Jamie Hardt
a015d7cf8a Added sounddevices test WAV
And unit tests for cue metadata.
2021-09-28 13:18:07 -07:00
Jamie Hardt
e89e87045c Merge pull request #11 from EaterLabs/misc-fixes
implement basic f32le support and some other misc fixes
2021-09-28 12:30:45 -07:00
Jamie Hardt
ecc1db703d Update Cargo.lock 2021-09-28 12:27:53 -07:00
Jamie Hardt
4cd28c9efe Create wavebuffer.rs 2021-09-28 11:59:56 -07:00
eater
663b9fad43 derive Debug for ADMAudioID and ChannelDescriptor and implement f32
reading
2021-08-22 23:40:07 +02:00
eater
9fe741d913 implement std::error::Error for Error 2021-08-22 23:35:47 +02:00
David Huss
2ecae51e8d Adding sounddevices testfile for cue points
As described in issue #9 the function cue_points() didn't display the
expected frame values for cue points created on a Sound Devices
MixPre-Series recorder. The file added by this commit
(sounddevices_6_cue_points.wav) is short and mono channel, but has 6 cue
points in it.

The expected frames for the cue points are:
0: 90112
1: 176128
2: 237568
3: 294912
4: 380928
5: 385024
2021-08-17 09:08:07 +02:00
David Huss
56dc4d1048 Try fix for cuepoints 2021-08-16 17:03:57 +02:00
Jamie Hardt
1af4c675c7 Merge commit 'a625b485d993d912556cdf72605bf7b2c48c18c2' 2021-06-23 10:21:41 -07:00
Jamie Hardt
a625b485d9 Merge branch 'candidate-v1' into HEAD 2021-06-23 10:19:48 -07:00
Jamie Hardt
d17c6badfa Removed unused import 2021-06-23 10:18:44 -07:00
Jamie Hardt
bc6be79715 Merge commit '53fcecfc451f9d38e2b541a728ea444162d04125' into candidate-v1 2021-06-23 10:13:05 -07:00
Jamie Hardt
763e9a10a3 Merge commit 'eee3c3f62592f024dd1308edeedc1b98565bbcd3' into candidate-v1 2021-06-23 10:08:48 -07:00
Jamie Hardt
319845ae49 In progress format plumbing 2021-01-05 00:32:09 -08:00
Jamie Hardt
6375567af1 Update README.md 2021-01-03 18:41:37 -08:00
Jamie Hardt
1a169da48f removed inapplicable code 2021-01-03 13:27:35 -08:00
Jamie Hardt
50b7b7b640 Merge commit '72d6be406e75ca0c40c134311f558cbec9c9f356' into candidate-v1 2021-01-03 13:26:50 -08:00
Jamie Hardt
94eb36bbb5 Merge branch 'master' into candidate-v1 2021-01-02 18:14:14 -08:00
Jamie Hardt
80be74c8fb Features 2021-01-02 16:04:44 -08:00
Jamie Hardt
75fc40d638 Bump version and license year 2021-01-02 15:45:24 -08:00
Jamie Hardt
2780bfb31b Structuring Readme 2021-01-02 15:44:05 -08:00
13 changed files with 225 additions and 119 deletions

38
Cargo.lock generated
View File

@@ -22,13 +22,13 @@ dependencies = [
[[package]]
name = "bitflags"
version = "1.2.1"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bwavfile"
version = "0.9.3"
version = "1.1.0"
dependencies = [
"byteorder",
"clap",
@@ -39,9 +39,9 @@ dependencies = [
[[package]]
name = "byteorder"
version = "1.3.4"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "clap"
@@ -124,24 +124,24 @@ checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
[[package]]
name = "hermit-abi"
version = "0.1.17"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "itoa"
version = "0.4.7"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
[[package]]
name = "libc"
version = "0.2.81"
version = "0.2.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb"
checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6"
[[package]]
name = "ryu"
@@ -151,15 +151,15 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "serde"
version = "1.0.118"
version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
[[package]]
name = "serde_json"
version = "1.0.61"
version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a"
checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8"
dependencies = [
"itoa",
"ryu",
@@ -183,15 +183,15 @@ dependencies = [
[[package]]
name = "unicode-width"
version = "0.1.8"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]]
name = "uuid"
version = "0.8.1"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
[[package]]
name = "vec_map"

View File

@@ -1,6 +1,6 @@
[package]
name = "bwavfile"
version = "0.9.3"
version = "1.1.0"
authors = ["Jamie Hardt <jamiehardt@me.com>"]
edition = "2018"
license = "MIT"

View File

@@ -4,72 +4,45 @@
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/iluvcapra/bwavfile/Rust)](https://github.com/iluvcapra/bwavfile/actions?query=workflow%3ARust)
# bwavfile
Rust Wave File Reader/Writer with Broadcast-WAV, MBWF and RF64 Support
Wave File Reader/Writer library in Rust, with Broadcast-WAV, MBWF and RF64 Support
### Features
## Features
This is currently a work-in-progress! However many features presently work:
__bwavfile__ provides a reader `WaveReader` and writer type `WaveWriter` for
reading and creating new audio files respectively.
| Feature |Read |Write|
|---------------------------------------|:---:|:-----:|
| Standard .wav files | ☑️ | ☑️ |
| Transparent promotion to RF64/BW64 | ☑️ | ☑️ |
| Unified interface for regular and extended Wave format | ☑️ | ☑️ |
| Channel/speaker map metadata | ☑️ | ☑️ |
| Ambisonic B-format metadata | ☑️ | ☑️ |
| EBU Broadcast-WAVE metadata | ☑️ | ☑️ |
| Basic iXML/ADM metadata | ☑️ | ☑️ |
| Enhanced iXML metadata support | | |
| ADM `chna` channel metadata | | |
| Broadcast-WAVE Level overview `levl` metadata | | |
| Cue list metadata | ☑️ | |
| Sampler and instrument metadata | | |
| Enhanced Wave file form validation | ☑️ | |
`WaveReader` and `WaveWriter` support:
* A unified interface for standard RIFF and RF64/BW64 64-bit Wave files.
* When using `WaveWriter`, wave files are transparently upgraded from RIFF
to RF64 when required.
* Unpacked reading and writing of Integer PCM and IEEE float audio data
formats.
* A unified interface for standard `WaveFormat` and extended `WaveFormatEx`
wave data format specification.
* Multichannel, surround, and ambisonic audio data description including
surround channel maps, ADM `AudioTrackFormat`, `AudioChannelFormatRef` and
`AudioPackRef` data structures.
* Broadcast-Wave metdata extension, including long description, originator
information, SMPTE UMID and coding history.
* Reading and writing of embedded iXML and axml/ADM metadata.
* Reading and writing of timed cues and and timed cue regions.
### Feature Roadmap
Some features that may be included in the future include:
* Broadcast-Wave `levl` waveform overview data reading and writing.
* Sampler and Instrument metadata.
* Performance improvements.
## Use Examples
### Examples Directory
Check out the [examples](examples) directory for some practical use cases:
* [blits](examples/blits.rs) shows how to use `WaveWriter` to create a new
file with BLITS alignment tones.
### Reading Audio Frames From a File
```rust
use bwavfile::WaveReader;
let mut r = WaveReader::open("tests/media/ff_silence.wav").unwrap();
let format = r.format().unwrap();
assert_eq!(format.sample_rate, 44100);
assert_eq!(format.channel_count, 1);
let mut buffer = format.create_frame_buffer();
let mut frame_reader = r.audio_frame_reader().unwrap();
let read = frame_reader.read_integer_frame(&mut buffer).unwrap();
assert_eq!(buffer, [0i32]);
assert_eq!(read, 1);
```
### Accessing Channel Descriptions
```rust
use bwavfile::{WaveReader, ChannelMask};
let mut f = WaveReader::open("tests/media/pt_24bit_51.wav").unwrap();
let chans = f.channels().unwrap();
assert_eq!(chans[0].index, 0);
assert_eq!(chans[0].speaker, ChannelMask::FrontLeft);
assert_eq!(chans[3].index, 3);
assert_eq!(chans[3].speaker, ChannelMask::LowFrequency);
assert_eq!(chans[4].speaker, ChannelMask::BackLeft);
```
* [wave-inter](examples/wave-inter.rs) uses `WaveReader` and `WaveWriter` to
interleave several input Wave files into a single polyphonic Wave file.
* [wave-deinter](examples/wave-deinter.rs) uses `WaveReader` and `WaveWriter`
to de-interleave an input Wave file into several monoarual Wave files.
## Note on Testing

View File

@@ -8,7 +8,7 @@ use std::io;
use std::path::Path;
extern crate bwavfile;
use bwavfile::{Error,WaveReader, WaveWriter, ChannelDescriptor, ChannelMask, WaveFmt, AudioFrameWriter};
use bwavfile::{Error,WaveReader, WaveWriter, ChannelDescriptor, ChannelMask, WaveFmt};
#[macro_use]
extern crate clap;
@@ -70,7 +70,7 @@ fn process_file(infile: &str, delim : &str, numeric_channel_names : bool) -> Res
let output_file = WaveWriter::create(&outfile_name, ouptut_format).expect("Failed to create new file");
let mut output_wave_writer = output_file.audio_frame_writer()?;
let mut buffer = input_format.create_frame_buffer();
let mut buffer = input_format.create_frame_buffer(1);
while input_wave_reader.read_integer_frame(&mut buffer)? > 0 {
output_wave_writer.write_integer_frames(&buffer[n..=n])?;

View File

@@ -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()
)
}
}
}

View File

@@ -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 {

View File

@@ -3,7 +3,7 @@ use super::common_format::{CommonFormat, UUID_PCM,UUID_BFORMAT_PCM};
use std::io::Cursor;
use byteorder::LittleEndian;
use byteorder::WriteBytesExt;
use byteorder::{WriteBytesExt, ReadBytesExt};
// Need more test cases for ADMAudioID
#[allow(dead_code)]
@@ -18,6 +18,7 @@ use byteorder::WriteBytesExt;
/// `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,
@@ -290,22 +292,23 @@ impl WaveFmt {
CommonFormat::make( self.tag, self.extended_format.map(|ext| ext.type_guid))
}
/// Create a frame buffer sized to hold frames for a reader or writer
/// Create a frame buffer sized to hold `length` frames for a reader or
/// writer
///
/// This is a conveneince method that creates a `Vec<i32>` with
/// as many elements as there are channels in the underlying stream.
pub fn create_frame_buffer(&self) -> Vec<i32> {
vec![0i32; self.channel_count as usize]
pub fn create_frame_buffer(&self, length : usize) -> Vec<i32> {
vec![0i32; self.channel_count as usize * length]
}
/// Calculate the size of a byte buffer needed to hold audio data of this
/// format for a given number of frames
pub fn buffer_length(&self, frame_count: u64) -> usize {
(self.block_alignment as u64 * frame_count) as usize
/// Create a raw byte buffer to hold `length` blocks from a reader or
/// writer
pub fn create_raw_buffer(&self, length : usize) -> Vec<u8> {
vec![0u8; self.block_alignment as usize * length]
}
// Write frames into a byte vector
pub fn pack_frames(&self, from_frames: &[i32], into_bytes: &mut Vec<u8>) -> () {
/// Write frames into a byte vector
pub fn pack_frames(&self, from_frames: &[i32], into_bytes: &mut [u8]) -> () {
let mut write_cursor = Cursor::new(into_bytes);
assert!(from_frames.len() % self.channel_count as usize == 0,
@@ -325,18 +328,19 @@ impl WaveFmt {
}
/// Read bytes into frames
// pub fn unpack_frames(&self, from_bytes: &[u8], into_frames: &mut Vec<i32>) -> () {
// for n in 0..(from_bytes.len()) {
// buffer[n] = match (self.format.bits_per_sample, framed_bits_per_sample) {
// (0..=8,8) => self.inner.read_u8()? as i32 - 0x80_i32, // EBU 3285 §A2.2
// (9..=16,16) => self.inner.read_i16::<LittleEndian>()? as i32,
// (10..=24,24) => self.inner.read_i24::<LittleEndian>()?,
// (25..=32,32) => self.inner.read_i32::<LittleEndian>()?,
// (b,_)=> panic!("Unrecognized integer format, bits per sample {}, channels {}, block_alignment {}",
// b, self.format.channel_count, self.format.block_alignment)
// }
// }
// }
pub fn unpack_frames(&self, from_bytes: &[u8], into_frames: &mut [i32]) -> () {
let mut rdr = Cursor::new(from_bytes);
for n in 0..(into_frames.len()) {
into_frames[n] = match (self.valid_bits_per_sample(), self.bits_per_sample) {
(0..=8,8) => rdr.read_u8().unwrap() as i32 - 0x80_i32, // EBU 3285 §A2.2
(9..=16,16) => rdr.read_i16::<LittleEndian>().unwrap() as i32,
(10..=24,24) => rdr.read_i24::<LittleEndian>().unwrap(),
(25..=32,32) => rdr.read_i32::<LittleEndian>().unwrap(),
(b,_)=> panic!("Unrecognized integer format, bits per sample {}, channels {}, block_alignment {}",
b, self.channel_count, self.block_alignment)
}
}
}
/// Channel descriptors for each channel.
@@ -379,3 +383,47 @@ impl WaveFmt {
}
}
trait ReadWavAudioData {
fn read_i32_frames(&mut self, format: WaveFmt, into: &mut [i32]) -> Result<usize,std::io::Error>;
fn read_f32_frames(&mut self, format: WaveFmt, into: &mut [f32]) -> Result<usize,std::io::Error>;
}
impl<T> ReadWavAudioData for T where T: std::io::Read {
fn read_i32_frames(&mut self, format: WaveFmt, into: &mut [i32]) -> Result<usize, std::io::Error> {
assert!(into.len() % format.channel_count as usize == 0);
for n in 0..(into.len()) {
into[n] = match (format.valid_bits_per_sample(), format.bits_per_sample) {
(0..=8,8) => self.read_u8().unwrap() as i32 - 0x80_i32, // EBU 3285 §A2.2
(9..=16,16) => self.read_i16::<LittleEndian>().unwrap() as i32,
(10..=24,24) => self.read_i24::<LittleEndian>().unwrap(),
(25..=32,32) => self.read_i32::<LittleEndian>().unwrap(),
(b,_)=> panic!("Unrecognized integer format, bits per sample {}, channels {}, block_alignment {}",
b, format.channel_count, format.block_alignment)
}
}
todo!()
}
fn read_f32_frames(&mut self, format: WaveFmt, into: &mut [f32]) -> Result<usize, std::io::Error> {
assert!(into.len() % format.channel_count as usize == 0);
todo!()
}
}
trait WriteWavAudioData {
fn write_i32_frames(&mut self, format: WaveFmt, from: &[i32]) -> Result<usize, std::io::Error>;
fn write_f32_frames(&mut self, format: WaveFmt, from: &[f32]) -> Result<usize, std::io::Error>;
}
impl<T> WriteWavAudioData for T where T: std::io::Write {
fn write_i32_frames(&mut self, format: WaveFmt, _: &[i32]) -> Result<usize, std::io::Error> {
todo!()
}
fn write_f32_frames(&mut self, format: WaveFmt, _: &[f32]) -> Result<usize, std::io::Error> {
todo!()
}
}

View File

@@ -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
View File

@@ -0,0 +1,3 @@
pub struct WaveBuffer {
pub format : WaveFmt
}

View File

@@ -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.
@@ -133,7 +156,7 @@ impl<R: Read + Seek> AudioFrameReader<R> {
/// assert_eq!(format.channel_count, 1);
///
/// let mut frame_reader = r.audio_frame_reader().unwrap();
/// let mut buffer = format.create_frame_buffer();
/// let mut buffer = format.create_frame_buffer(1);
///
/// let read = frame_reader.read_integer_frame(&mut buffer).unwrap();
///

View File

@@ -26,7 +26,7 @@ impl<W> AudioFrameWriter<W> where W: Write + Seek {
AudioFrameWriter { inner }
}
fn write_integer_frames_to_buffer(&self, from_frames :&[i32], to_buffer : &mut Vec<u8>) -> () {
fn write_integer_frames_to_buffer(&self, from_frames :&[i32], to_buffer : &mut [u8]) -> () {
assert!(from_frames.len() % self.inner.inner.format.channel_count as usize == 0,
"frames buffer does not contain a number of samples % channel_count == 0");
self.inner.inner.format.pack_frames(&from_frames, to_buffer);
@@ -40,7 +40,8 @@ impl<W> AudioFrameWriter<W> where W: Write + Seek {
/// This function will panic if `buffer.len()` modulo the Wave file's channel count
/// is not zero.
pub fn write_integer_frames(&mut self, buffer: &[i32]) -> Result<u64,Error> {
let mut write_buffer = vec![0u8; 0];
let mut write_buffer = self.inner.inner.format
.create_raw_buffer(buffer.len() / self.inner.inner.format.channel_count as usize);
self.write_integer_frames_to_buffer(&buffer, &mut write_buffer);

View File

@@ -82,7 +82,7 @@ fn test_read() {
let path = "tests/media/audacity_16bit.wav";
let mut w = WaveReader::open(path).expect("Failure opening test file");
let mut buffer = w.format().unwrap().create_frame_buffer();
let mut buffer = w.format().unwrap().create_frame_buffer(1);
let mut reader = w.audio_frame_reader().unwrap();
@@ -101,7 +101,7 @@ fn test_locate_multichannel_read() {
let path = "tests/media/ff_pink.wav";
let mut w = WaveReader::open(path).expect("Failure opening test file");
let mut buffer = w.format().unwrap().create_frame_buffer();
let mut buffer = w.format().unwrap().create_frame_buffer(1);
let mut reader = w.audio_frame_reader().unwrap();
@@ -158,7 +158,7 @@ fn test_channels_stereo_no_fmt_extended() {
assert_eq!(channels[1].speaker,ChannelMask::FrontRight);
}
//See issue 6 and 7
///See issue 6 and 7
#[test]
fn test_frame_reader_consumes_reader() {
// Issue #6
@@ -175,4 +175,48 @@ fn test_frame_reader_consumes_reader() {
}
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.