pub struct Ay3_891xAudio { /* private fields */ }
Expand description

Implements AY-3-8910/8912/8913 programmable sound generator.

For the implementation of I/O ports see crate::ay.

Implementations§

Use the Default trait to create instances of this struct.

Resets the internal state to the one initialized with.

Converts a tone frequency given in Hz to a closest 16-bit tone period register value.

clock_hz AY-3-891x clock frequency in Hz. In ZX Spectrum it equals to CPU_HZ / 2. Amstrad CPC has PSG clocked at 1 MHz. Atari ST at 2 MHz.

Returns None if the result can’t be properly represented by 16-bit unsigned integer or if the result is 0.

Converts a 16-bit tone period register value to a tone frequency in Hz.

clock_hz AY-3-891x clock frequency in Hz. In ZX Spectrum it equals to CPU_HZ / 2. Amstrad CPC has PSG clocked at 1 MHz. Atari ST at 2 MHz.

Creates an iterator of tone periods for the AY-3-891x chip.

min_octave A minimal octave number, 0-based (0 is the minimum). max_octave A maximal octave number, 0-based (7 is the maximum). note_freqs An array of tone frequencies (in Hz) in the 5th octave (0-based: 4). To generate frequencies you may want to use audio::music::equal_tempered_scale_note_freqs. clock_hz The AY-3-891x clock frequency in Hz. Usually, it’s CPU_HZ / 2.

Panics

Panics if any period can’t be expressed by 16-bit unsigned integer.

Renders square-wave audio pulses via the Blep interface while mutating the internal state.

The internal state is being altered every INTERNAL_CLOCK_DIVISOR * HOST_CLOCK_RATIO Cpu clock cycles until end_ts is reached. The internal cycle counter is then decremented by the value of frame_tstates before returning from this method.

Provide AmpLevels that can handle level values from 0 to 15 (4-bits).

  • changes should be ordered by time and recorded only with time < end_ts otherwise, some register changes may be lost - the iterator will be drained anyway.
  • end_ts should be a value of an end of frame T-state counter value.
  • frame_tstates should be a duration of a single frame in T-states.
  • channels - indicate Blep audio channels for [A, B, C] AY channels.

Updates the value of one of the sound generator registers for the indicated reg register, with the value given in val.

This method can be used to instantly set the state of the sound generator without the need to generate audio pulses.

Returns the current tone periods of each channel.

The period is in the range: [1, 4095].

Returns the current amplitude level of each channel.

If the channel volume register’s envelope bit is set, it returns the current envelope level for that channel.

The levels are in the range: [0, 15].

Returns the current noise pitch.

The pitch is in the range: [0, 31].

Returns the current value of the mixer register.

t - tone bit: 0 tone enabled, 1 disabled
n - noise bit: 0 noise enabled, 1 disabled

b7 b6 b5 b4 b3 b2 b1 b0 bit
-  -  n  n  n  t  t  t  value
-  -  C  B  A  C  B  A  channel

Returns the current level of the envelope generator.

Returns the envelope shape.

Returns the envelope period.

The period is in the range: [1, 65535].

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Converts self into T using Into<T>. Read more
Causes self to use its Binary implementation when Debug-formatted.
Causes self to use its Display implementation when Debug-formatted. Read more
Causes self to use its LowerExp implementation when Debug-formatted. Read more
Causes self to use its LowerHex implementation when Debug-formatted. Read more
Causes self to use its Octal implementation when Debug-formatted.
Causes self to use its Pointer implementation when Debug-formatted. Read more
Causes self to use its UpperExp implementation when Debug-formatted. Read more
Causes self to use its UpperHex implementation when Debug-formatted. Read more
Formats each item in a sequence. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Convert to S a sample type from self.
Pipes by value. This is generally the method you want to use. Read more
Borrows self and passes that borrow into the pipe function. Read more
Mutably borrows self and passes that borrow into the pipe function. Read more
Borrows self, then passes self.borrow() into the pipe function. Read more
Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Borrows self, then passes self.as_ref() into the pipe function.
Mutably borrows self, then passes self.as_mut() into the pipe function. Read more
Borrows self, then passes self.deref() into the pipe function.
Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more
Immutable access to a value. Read more
Mutable access to a value. Read more
Immutable access to the Borrow<B> of a value. Read more
Mutable access to the BorrowMut<B> of a value. Read more
Immutable access to the AsRef<R> view of a value. Read more
Mutable access to the AsMut<R> view of a value. Read more
Immutable access to the Deref::Target of a value. Read more
Mutable access to the Deref::Target of a value. Read more
Calls .tap() only in debug builds, and is erased in release builds.
Calls .tap_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Attempts to convert self into T using TryInto<T>. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.