# Struct arduboy_rust::prelude::arduboy_tone::ArduboyTones

source ·

    pub struct ArduboyTones {}

Expand description

This is the struct to interact in a save way with the ArduboyTones C++ library.

## Implementations§

source §

### impl ArduboyTones

source

#### pub const fn new() -> ArduboyTones

Get a new instance of ArduboyTones

###### Example

    const sound: ArduboyTones = ArduboyTones::new();

source

#### pub fn tone(&self, frequency: u16, duration: u32)

Play a single tone.

- freq The frequency of the tone, in hertz.
- dur The duration to play the tone for, in 1024ths of a second (very close to milliseconds). A duration of 0, or if not provided, means play forever, or until `noTone()` is called or a new tone or sequence is started.

source

#### pub fn tone2( &self, frequency1: u16, duration1: u32, frequency2: u16, duration2: u32 )

Play two tones in sequence.

- freq1,freq2 The frequency of the tone in hertz.
- dur1,dur2 The duration to play the tone for, in 1024ths of a second (very close to milliseconds).

source

#### pub fn tone3( &self, frequency1: u16, duration1: u32, frequency2: u16, duration2: u32, frequency3: u16, duration3: u32 )

Play three tones in sequence.

- freq1,freq2,freq3 The frequency of the tone, in hertz.
- dur1,dur2,dur3 The duration to play the tone for, in 1024ths of a second (very close to milliseconds).

source

#### pub fn tones(&self, tones: *const u16)

Play a tone sequence from frequency/duration pairs in a PROGMEM array.

- tones A pointer to an array of frequency/duration pairs.

The array must be placed in code space using `PROGMEM`.

See the `tone()` function for details on the frequency and duration values. A frequency of 0 for any tone means silence (a musical rest).

The last element of the array must be `TONES_END` or `TONES_REPEAT`.

Example:

    progmem!(
        static sound1:[u8;_]=[220,1000, 0,250, 440,500, 880,2000,TONES_END]
    );

    tones(get_tones_addr!(sound1));

source

#### pub fn no_tone(&self)

Stop playing the tone or sequence.

If a tone or sequence is playing, it will stop. If nothing is playing, this function will do nothing.

source

#### pub fn playing(&self) -> bool

Check if a tone or tone sequence is playing.

- return boolean `true` if playing (even if sound is muted).

source

#### pub fn tones_in_ram(&self, tones: *mut u32)

Play a tone sequence from frequency/duration pairs in an array in RAM.

- tones A pointer to an array of frequency/duration pairs.

The array must be located in RAM.

See the `tone()` function for details on the frequency and duration values. A frequency of 0 for any tone means silence (a musical rest).

The last element of the array must be `TONES_END` or `TONES_REPEAT`.

Example:

    let sound2: [u16; 9] = [220, 1000, 0, 250, 440, 500, 880, 2000, TONES_END];

Using `tones()`, with the data in PROGMEM, is normally a better choice. The only reason to use tonesInRAM() would be if dynamically altering the contents of the array is required.

source

#### pub fn volume_mode(&self, mode: u8)

Set the volume to always normal, always high, or tone controlled.

One of the following values should be used:

- `VOLUME_IN_TONE` The volume of each tone will be specified in the tone itself.
- `VOLUME_ALWAYS_NORMAL` All tones will play at the normal volume level.
- `VOLUME_ALWAYS_HIGH` All tones will play at the high volume level.

## Auto Trait Implementations§

§

### impl RefUnwindSafe for ArduboyTones

§

### impl Send for ArduboyTones

§

### impl Sync for ArduboyTones

§

### impl Unpin for ArduboyTones

§

### impl UnwindSafe for ArduboyTones

## Blanket Implementations§

§

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

§

#### fn type_id(&self) -> TypeId

Gets the `TypeId` of `self`. Read more
§

### impl<T> Borrow<T> for Twhere T: ?Sized,

§

#### fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

### impl<T> BorrowMut<T> for Twhere T: ?Sized,

§

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

Mutably borrows from an owned value. Read more
§

### impl<T> From<T> for T

§

#### fn from(t: T) -> T

Returns the argument unchanged.

§

### impl<T, U> Into<U> for Twhere 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 Twhere 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 Twhere 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.