Skip to main content
← PSoXide SDK guides and examples · SDK 80d1c329e977 · All Cargo features enabled; check feature gates before use.

PanLaw

Enum PanLaw 

Source
pub enum PanLaw {
    Off,
    Sum,
    Dot,
    EqualPower(Center),
    Custom(fn(i32, i32) -> (i32, i32)),
}
Expand description

How a level is split over two ears.

pan is Q12 from -PAN_RIGHT (hard left) to PAN_RIGHT (hard right).

§Example

use psx_sfx::space::{PanLaw, PAN_RIGHT};

// Quake's law: each ear gets (1 -+ pan) of the level.
let (l, r) = PanLaw::Dot.apply(1000, PAN_RIGHT / 2);
assert_eq!((l, r), (500, 1500));

Variants§

§

Off

Both ears get the level: a mono source.

§

Sum

WipEout’s constant-sum law. The ears get v + d and v - d with d = (v * -pan) >> 13, so a pan of PAN_RIGHT is a quarter turn and moves half the level across. With pan = -4a this is bit for bit the retail v * a >> 11 split, including the floor rounding.

§

Dot

Quake’s law: the left ear gets v * (1 - pan), the right v * (1 + pan).

§

EqualPower(Center)

Constant power: left = cos, right = sin of a quarter turn swept by the pan, from the 256-entry sine table in psx-math.

§

Custom(fn(i32, i32) -> (i32, i32))

The caller’s own law, for retail-exact reproduction. Receives the level and the pan and returns the two ear levels.

Implementations§

Source§

impl PanLaw

Source

pub fn apply(&self, level: i32, pan: i32) -> (i32, i32)

Split level over two ears for pan. The result is not clamped to the SPU range; gains does that.

assert_eq!(PanLaw::Off.apply(900, 4096), (900, 900));

Trait Implementations§

Source§

impl Clone for PanLaw

Source§

fn clone(&self) -> PanLaw

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PanLaw

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for PanLaw

Auto Trait Implementations§

§

impl Freeze for PanLaw

§

impl RefUnwindSafe for PanLaw

§

impl Send for PanLaw

§

impl Sync for PanLaw

§

impl Unpin for PanLaw

§

impl UnsafeUnpin for PanLaw

§

impl UnwindSafe for PanLaw

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.