//! `SoundAmbi` type.

use crate::err::*;

/// Reads an `ambi` chunk.
pub fn read(b: &[u8]) -> ResultS<(SoundAmbi, usize)>
{
	read_data! {
		endian: BIG, buf: b, size: 16, start: 0, data {
			let index  = u16[2];
			let volume = u16[4];
		}
	}

	Ok((SoundAmbi{index, volume}, 16))
}

/// An ambient sound definition.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct SoundAmbi {
	pub index:  u16,
	pub volume: u16,
}

// EOF
