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:
- Automatic gain control
- Demodulation and down-sampling to two samples per symbol, governed by a zero-crossing detector timing recovery loop.
- Access code correlation and squelch. The code correlator also synchronizes to byte boundaries.
- (Optional) Adaptive decision feedback equalization
- 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
impl SameReceiver
Sourcepub fn iter_events<'rx, I>(
&'rx mut self,
input: I,
) -> impl Iterator<Item = SameReceiverEvent> + 'rxwhere
I: IntoIterator<Item = f32> + 'rx,
pub fn iter_events<'rx, I>(
&'rx mut self,
input: I,
) -> impl Iterator<Item = SameReceiverEvent> + 'rxwhere
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.
Sourcepub fn iter_messages<'rx, I>(
&'rx mut self,
input: I,
) -> impl Iterator<Item = Message> + 'rxwhere
I: IntoIterator<Item = f32> + 'rx,
pub fn iter_messages<'rx, I>(
&'rx mut self,
input: I,
) -> impl Iterator<Item = Message> + 'rxwhere
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.
Sourcepub fn input_rate(&self) -> u32
pub fn input_rate(&self) -> u32
Input sampling rate
Returns sampling rate expected by the
process()
method.
Sourcepub fn input_sample_counter(&self) -> u64
pub fn input_sample_counter(&self) -> u64
Lifetime total input sample counter
Reports the lifetime total of input samples which have been processed.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Clear all DSP states and reset to zero initial conditions
All buffers and states are cleared.
Sourcepub fn flush(&mut self) -> Option<Message>
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
impl Clone for SameReceiver
Source§fn clone(&self) -> SameReceiver
fn clone(&self) -> SameReceiver
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SameReceiver
impl Debug for SameReceiver
Source§impl From<&SameReceiverBuilder> for SameReceiver
impl From<&SameReceiverBuilder> for SameReceiver
Source§fn from(cfg: &SameReceiverBuilder) -> Self
fn from(cfg: &SameReceiverBuilder) -> Self
Create the SAME Receiver from its Builder
Auto Trait Implementations§
impl Freeze for SameReceiver
impl RefUnwindSafe for SameReceiver
impl Send for SameReceiver
impl Sync for SameReceiver
impl Unpin for SameReceiver
impl UnwindSafe for SameReceiver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.