Skip to main content

Frame

Struct Frame 

Source
pub struct Frame<'a> {
    pub bars: &'a [f32],
    pub peaks: &'a [f32],
    pub pulse: f32,
    pub bands: [f32; 3],
    pub hits: [f32; 3],
    pub onsets: [bool; 3],
    pub centroid: f32,
    pub flux: f32,
    pub chroma: [f32; 12],
}
Expand description

1 フレームぶんの分析結果。描く側はこれを読む。

0.x の間は、項目が増えることがある(Frame { .. } を自分で組み立てる場合は、増えるたびに 直す。読むだけなら影響しない)。

Fields§

§bars: &'a [f32]

各バーの高さ(0〜1)。0 番が低音。

§peaks: &'a [f32]

各バーのピークの印の高さ(0〜1)。bars と同じ長さで、いつも bars 以上。

§pulse: f32

低音の脈動(0〜1)。

§bands: [f32; 3]

低・中・高の帯域の強さ(0〜1)。順に Config::bass_lo_hz〜Config::bass_hi_hz、 〜Config::mid_hi_hz、〜Config::high_hi_hz。持ち上げはかけない。

§hits: [f32; 3]

帯域ごとのビートの印(0〜1)。ビートを拾った瞬間に強さへ跳ね、ゆっくり戻る。

§onsets: [bool; 3]

帯域ごとに、このフレームでビートを拾ったか。ゲームで弾や光を 1 回だけ出す合図に使う。

§centroid: f32

音の明るさ(スペクトルの重心。0〜1)。Config::min_hz〜Config::max_hz を対数で見た位置で、 高い音・シャリシャリした音ほど 1 に近い。無音は 0。バーと同じ速さでなめらかにする。

§flux: f32

音の急な変化(スペクトルフラックス。0〜1)。スペクトル全体が前のフレームより大きくなった分で、 打楽器・和音の入り・音色の変わり目で立ち上がり、ビートと同じ速さで戻る。鳴りっぱなしでは 0。

§chroma: [f32; 12]

音名ごとの強さ(0〜1。0 = C、1 = C#、…、11 = B)。Config::chroma_lo_hz〜Config::chroma_hi_hz のスペクトルの山を、一番近い半音の音名に割り当てる。和音の色や調の表示に使う。 持ち上げはかけない。窓が短いと低い音の音名を取り違える(Config::fft_size)。

Implementations§

Source§

impl Frame<'_>

Source

pub fn to_snapshot(&self) -> FrameSnapshot

値を複製して持つ形にする(遅らせて使うとき)。

Trait Implementations§

Source§

impl<'a> Clone for Frame<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Frame<'a>

Source§

impl<'a> Debug for Frame<'a>

Source§

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

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

impl<'a> PartialEq for Frame<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Frame<'a>

Auto Trait Implementations§

§

impl<'a> Forget for Frame<'a>

§

impl<'a> Freeze for Frame<'a>

§

impl<'a> Move for Frame<'a>

§

impl<'a> RefUnwindSafe for Frame<'a>

§

impl<'a> Send for Frame<'a>

§

impl<'a> Sync for Frame<'a>

§

impl<'a> Unpin for Frame<'a>

§

impl<'a> UnsafeUnpin for Frame<'a>

§

impl<'a> UnwindSafe for Frame<'a>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.