Skip to main content

Audio

Struct Audio 

Source
pub struct Audio;

Implementations§

Source§

impl Audio

Source

pub fn init()

PWMおよびGPIO40/45の初期化処理、I2S(HDMI)の初期化、DMAの設定を行います

Source

fn ensure_playback_thread()

常駐再生スレッドを必要なら起動する(プロセス全体で一度だけ spawn される)。 以前は効果音ごとにスレッドを spawn→終了していたため、ESC 連打などで 頻繁なスレッド生成・破棄が起き、スタック確保/解放でヒープ破損を招いていた。 Audio::init() は scheduler::init() より前に呼ばれるため、ここで遅延起動する。

Source

pub fn set_tone(freq: u32)

指定された周波数 (Hz) で自律発振を開始します (0 の場合は Mute)

Source

pub fn mute()

音声を消音します

Source

pub fn play_mml(mml_str: &str)

MML 文字列をバックグラウンド(ノンブロッキング)で演奏開始します

Source

pub fn is_playing() -> bool

現在MMLを演奏中かどうかを判定します

Source

pub fn stop_mml()

MML演奏を強制停止します

Source

pub fn play_tone_async(freq: u32, duration_ms: u32)

単音をバックグラウンド(ノンブロッキング)で指定ミリ秒間演奏します

Source

fn playback_thread_entry()

再生スレッドの実行エントリポイント

Source

pub fn play_pcm_stream(pcm_data: &[i16])

デコードされた 16-bit PCM ステレオ音声データを、HDMI (I2S) と PWM (イヤホンジャック) に供給してDMA再生します

Auto Trait Implementations§

§

impl Freeze for Audio

§

impl RefUnwindSafe for Audio

§

impl Send for Audio

§

impl Sync for Audio

§

impl Unpin for Audio

§

impl UnsafeUnpin for Audio

§

impl UnwindSafe for Audio

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

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

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.