Struct SameReceiver

Source
pub struct SameReceiver { /* private fields */ }
Expand description

A complete SAME/EAS receiver chain

The receive chain takes f32 audio samples and performs the following operations:

  1. Automatic gain control
  2. Demodulation and down-sampling to two samples per symbol, governed by a zero-crossing detector timing recovery loop.
  3. Access code correlation and squelch. The code correlator also synchronizes to byte boundaries.
  4. (Optional) Adaptive decision feedback equalization
  5. Framing and message decoding

To create the receiver, first create its Builder:

use sameold::SameReceiverBuilder;

let mut builder = SameReceiverBuilder::default();
let receiver = builder.build();
assert_eq!(receiver.input_rate(), 22050);

Once created, use the iter_messages() method to obtain decoded messages.

See module documentation for details.

Implementations§

Source§

impl SameReceiver

Source

pub fn iter_events<'rx, I>( &'rx mut self, input: I, ) -> impl Iterator<Item = SameReceiverEvent> + 'rx
where I: IntoIterator<Item = f32> + 'rx,

Decode events and messages from a source of audio

Bind an iterator which will consume the input and produce SAME SameReceiverEvent events, which include:

  • notifications about acquired and dropped carrier,
  • attempts to frame messages; and
  • successful framed messages

The input must be f32 PCM mono audio at the input_rate() for this receiver. Sound cards commonly output audio samples in i16 format. You must perform the conversion to floating-point yourself, if needed. It is unnecessary to scale the converted values; our AGC algorithm will take care of that.

The iterator will consume as many samples of input that are required to produce the next event. It will return None if the input is exhausted and there are no new events.

You can use iter_messages() instead if you are only interested in successful decodes.

Source

pub fn iter_messages<'rx, I>( &'rx mut self, input: I, ) -> impl Iterator<Item = Message> + 'rx
where I: IntoIterator<Item = f32> + 'rx,

Receive SAME messages from a source of audio

Bind an iterator which will consume the input and produce SAME Message events. Only successfully-decoded messages are reported. Other events, such as acquisition of signal or decoding failures, are not reported. If you are interested in these events, use iter_events() instead.

The input must be f32 PCM mono audio at the input_rate() for this receiver. Sound cards commonly output audio samples in i16 format. You must perform the conversion to floating-point yourself, if needed. It is unnecessary to scale the converted values; our AGC algorithm will take care of that.

The iterator will consume as many samples of input that are required to produce the next message. It will return None if the input is exhausted and there are no new messages.

Source

pub fn input_rate(&self) -> u32

Input sampling rate

Returns sampling rate expected by the process() method.

Source

pub fn input_sample_counter(&self) -> u64

Lifetime total input sample counter

Reports the lifetime total of input samples which have been processed.

Source

pub fn reset(&mut self)

Clear all DSP states and reset to zero initial conditions

All buffers and states are cleared.

Source

pub fn flush(&mut self) -> Option<Message>

Flush the DSP buffers and emit any leftover messages

The DSP algorithms impose delay on the input. When processing recorded audio that has been “close cut” to the extents of a message, the SameReceiver might not emit the message. This is because not all of the data samples from the file have made their way through the entire system.

This method flushes the input with an adequate number of zeros to ensure all buffered samples have been processed. Returns the last Message generated, if any.

You probably want to reset() after calling this method.

Trait Implementations§

Source§

impl Clone for SameReceiver

Source§

fn clone(&self) -> SameReceiver

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SameReceiver

Source§

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

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

impl From<&SameReceiverBuilder> for SameReceiver

Source§

fn from(cfg: &SameReceiverBuilder) -> Self

Create the SAME Receiver from its Builder

Auto Trait Implementations§

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

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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 = 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.