pub struct BrstmInformation {
pub info: Head1,
pub tracks: Vec<TrackDescription>,
pub channels: Vec<AdpcmChannelInformation>,
/* private fields */
}Fields§
§info: Head1§tracks: Vec<TrackDescription>§channels: Vec<AdpcmChannelInformation>Implementations§
Source§impl BrstmInformation
impl BrstmInformation
Sourcepub fn from_reader<RS: Read + Seek>(f: &mut RS) -> BinResult<Self>
pub fn from_reader<RS: Read + Seek>(f: &mut RS) -> BinResult<Self>
Examples found in repository?
More examples
examples/brstm-fix.rs (line 10)
5pub fn try_main() -> binrw::BinResult<()> {
6 let mut files = args().skip(1);
7 let in_filename = files.next().expect("no in filename");
8 let out_filename = files.next().expect("no out filename");
9 let mut f = File::open(in_filename)?;
10 let mut src = BrstmInformation::from_reader(&mut f)?.into_with_data(&mut f)?;
11 drop(f);
12 src.info.fix_tracks();
13 let mut outf = File::create(out_filename)?;
14 src.write_brstm(&mut outf)?;
15 Ok(())
16}examples/rw-check.rs (line 14)
8pub fn main() {
9 for src in std::env::args().skip(1) {
10 let orig = fs::read(&src).unwrap();
11 let mut dest = Vec::with_capacity(orig.len());
12 println!("{src}");
13 let mut cursor = Cursor::new(&orig);
14 let parsed = BrstmInformation::from_reader(&mut cursor).unwrap();
15 let data_parsed = parsed.into_with_data(&mut cursor).unwrap();
16 data_parsed
17 .write_brstm(&mut Cursor::new(&mut dest))
18 .unwrap();
19 if orig != dest {
20 println!("missmatch: {src}");
21 }
22 }
23}examples/all-sizes.rs (line 8)
5pub fn main() {
6 let mut name_to_duration = Vec::new();
7 for filename in args().skip(1) {
8 let read = BrstmInformation::from_reader(&mut File::open(&filename).unwrap()).unwrap();
9 let name = filename.split_terminator('/').last().unwrap();
10 // if read.info.loop_flag == 0 {
11 name_to_duration.push((
12 name.to_string(),
13 read.info.loop_flag,
14 read.info.total_samples,
15 ));
16 // }
17 }
18 name_to_duration.sort_unstable_by_key(|(_, _, count)| *count);
19 for (name, loop_flag, count) in name_to_duration.iter() {
20 println!("{name}:{loop_flag}:{count}");
21 }
22}pub fn write_brstm<WS: Write + Seek>( &self, ws: &mut WS, adpcm_bytes: &[u8], data_bytes: &[u8], ) -> BinResult<()>
pub fn channel_count(&self) -> u8
Sourcepub fn channels_per_track(&self) -> Option<u8>
pub fn channels_per_track(&self) -> Option<u8>
returns None if it cannot be determined
pub fn is_stereo(&self) -> bool
pub fn is_mono(&self) -> bool
Sourcepub fn check_tracks_valid(&self) -> bool
pub fn check_tracks_valid(&self) -> bool
determine if track information is broken:
- channels are referenced that don’t exist
- channels exist but aren’t referenced
Sourcepub fn fix_tracks(&mut self) -> bool
pub fn fix_tracks(&mut self) -> bool
fixes songs with tracks that point to invalid channels or if no tracks exist returns if tracks had to be fixed
Examples found in repository?
examples/brstm-fix.rs (line 12)
5pub fn try_main() -> binrw::BinResult<()> {
6 let mut files = args().skip(1);
7 let in_filename = files.next().expect("no in filename");
8 let out_filename = files.next().expect("no out filename");
9 let mut f = File::open(in_filename)?;
10 let mut src = BrstmInformation::from_reader(&mut f)?.into_with_data(&mut f)?;
11 drop(f);
12 src.info.fix_tracks();
13 let mut outf = File::create(out_filename)?;
14 src.write_brstm(&mut outf)?;
15 Ok(())
16}Sourcepub fn into_with_data<RS: Read + Seek>(
self,
f: &mut RS,
) -> Result<BrstmInfoWithData>
pub fn into_with_data<RS: Read + Seek>( self, f: &mut RS, ) -> Result<BrstmInfoWithData>
Examples found in repository?
examples/brstm-fix.rs (line 10)
5pub fn try_main() -> binrw::BinResult<()> {
6 let mut files = args().skip(1);
7 let in_filename = files.next().expect("no in filename");
8 let out_filename = files.next().expect("no out filename");
9 let mut f = File::open(in_filename)?;
10 let mut src = BrstmInformation::from_reader(&mut f)?.into_with_data(&mut f)?;
11 drop(f);
12 src.info.fix_tracks();
13 let mut outf = File::create(out_filename)?;
14 src.write_brstm(&mut outf)?;
15 Ok(())
16}More examples
examples/rw-check.rs (line 15)
8pub fn main() {
9 for src in std::env::args().skip(1) {
10 let orig = fs::read(&src).unwrap();
11 let mut dest = Vec::with_capacity(orig.len());
12 println!("{src}");
13 let mut cursor = Cursor::new(&orig);
14 let parsed = BrstmInformation::from_reader(&mut cursor).unwrap();
15 let data_parsed = parsed.into_with_data(&mut cursor).unwrap();
16 data_parsed
17 .write_brstm(&mut Cursor::new(&mut dest))
18 .unwrap();
19 if orig != dest {
20 println!("missmatch: {src}");
21 }
22 }
23}Trait Implementations§
Source§impl Clone for BrstmInformation
impl Clone for BrstmInformation
Source§fn clone(&self) -> BrstmInformation
fn clone(&self) -> BrstmInformation
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BrstmInformation
impl RefUnwindSafe for BrstmInformation
impl Send for BrstmInformation
impl Sync for BrstmInformation
impl Unpin for BrstmInformation
impl UnwindSafe for BrstmInformation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more