libsstvenc
Asynchronous Analogue SSTV encoder
|
Data Structures | |
struct | sstvenc_mod |
Functions | |
void | sstvenc_modulator_init (struct sstvenc_mod *const mod, const struct sstvenc_mode *mode, const char *fsk_id, const uint8_t *framebuffer, double rise_time, double fall_time, uint32_t sample_rate, uint8_t time_unit) |
void | sstvenc_modulator_compute (struct sstvenc_mod *const mod) |
size_t | sstvenc_modulator_fill_buffer (struct sstvenc_mod *const mod, double *buffer, size_t buffer_sz) |
static void | sstvenc_modulator_next_rise_sample (struct sstvenc_mod *const mod) |
static void | sstvenc_modulator_next_tone (struct sstvenc_mod *const mod) |
static void | sstvenc_modulator_next_hold_sample (struct sstvenc_mod *const mod) |
static void | sstvenc_modulator_next_fall_sample (struct sstvenc_mod *const mod) |
This uses the SSTV encoder defined in SSTV encoder and combines it with an oscillator from Oscillator implementation and a pulse shaper from Pulse Shaper.
Additional logic is supplied to handle time-quantisation jitter that arises due to the discrete sampling intervals.
Like the SSTV encoder component this is built on, the state machine state is determined by observing sstvenc_mod::ps, in particular, the phase
member and comparing that to Pulse Shaper States. When the value matches SSTVENC_PS_PHASE_DONE, no more meaningful samples will be emitted.
The output is returned by the oscillator instance: sstvenc_mod::osc via its output
member.
struct sstvenc_mod |
Data Fields | ||
---|---|---|
struct sstvenc_encoder | enc |
SSTV encoder state machine |
struct sstvenc_oscillator | osc |
Frequency modulation oscillator |
struct sstvenc_pulseshape | ps |
Pulse shaper |
uint32_t | remaining |
Remaining number of samples needed to correct timing |
uint64_t | total_ns |
Total time period in nanoseconds emitted |
uint64_t | total_samples |
Total audio samples emitted |
void sstvenc_modulator_compute | ( | struct sstvenc_mod *const | mod | ) |
Compute the next audio sample to be emitted from the modulator.
Definition at line 125 of file sstvmod.c.
References sstvenc_mod::osc, sstvenc_oscillator::output, sstvenc_pulseshape::phase, sstvenc_mod::ps, sstvenc_modulator_next_fall_sample(), sstvenc_modulator_next_hold_sample(), sstvenc_modulator_next_rise_sample(), SSTVENC_PS_PHASE_FALL, SSTVENC_PS_PHASE_HOLD, SSTVENC_PS_PHASE_INIT, and SSTVENC_PS_PHASE_RISE.
Referenced by main(), sstvenc_modulator_fill_buffer(), and sstvenc_sequencer_compute().
size_t sstvenc_modulator_fill_buffer | ( | struct sstvenc_mod *const | mod, |
double * | buffer, | ||
size_t | buffer_sz ) |
Fill the given buffer with audio samples from the SSTV modulator. Stop if we run out of buffer space or if the SSTV state machine finishes. Return the number of samples generated.
[in,out] | mod | SSTV modulator state machine to pull samples from. |
[out] | buffer | Audio buffer to write samples to. |
[in] | buffer_sz | Size of the audio buffer in samples. |
Definition at line 147 of file sstvmod.c.
References sstvenc_mod::osc, sstvenc_oscillator::output, sstvenc_pulseshape::phase, sstvenc_mod::ps, sstvenc_modulator_compute(), and SSTVENC_PS_PHASE_DONE.
void sstvenc_modulator_init | ( | struct sstvenc_mod *const | mod, |
const struct sstvenc_mode * | mode, | ||
const char * | fsk_id, | ||
const uint8_t * | framebuffer, | ||
double | rise_time, | ||
double | fall_time, | ||
uint32_t | sample_rate, | ||
uint8_t | time_unit ) |
Initialise the SSTV modulator with the given parameters.
[in,out] | mod | SSTV modulator context to initialise |
[in] | mode | SSTV mode to encode |
[in] | fsk_id | FSK ID to send at the end, NULL to disable. |
[in] | framebuffer | Framebuffer data representing the image. |
[in] | rise_time | Carrier rise time, set to 0 to disable. |
[in] | fall_time | Carrier fall time, set to 0 to disable. |
[in] | sample_rate | Sample rate in Hz |
[in] | time_unit | Time unit used to measure rise_time and fall_time. |
Definition at line 14 of file sstvmod.c.
References sstvenc_mod::enc, sstvenc_mod::osc, sstvenc_mod::ps, sstvenc_mod::remaining, sstvenc_encoder_init(), SSTVENC_FREQ_SYNC, sstvenc_osc_init(), sstvenc_ps_init(), sstvenc_mod::total_ns, and sstvenc_mod::total_samples.
Referenced by main(), and sstvenc_sequencer_begin_image().
|
static |
Compute the next sample whilst in the FALL phase of the pulse shaper state machine.
Definition at line 119 of file sstvmod.c.
References sstvenc_oscillator::amplitude, sstvenc_mod::osc, sstvenc_pulseshape::output, sstvenc_mod::ps, sstvenc_osc_compute(), and sstvenc_ps_compute().
Referenced by sstvenc_modulator_compute().
|
static |
Compute the next sample whilst in the HOLD phase of the pulse shaper state machine.
Definition at line 91 of file sstvmod.c.
References sstvenc_oscillator::amplitude, sstvenc_mod::enc, sstvenc_mod::osc, sstvenc_pulseshape::output, sstvenc_encoder::phase, sstvenc_pulseshape::phase, sstvenc_mod::ps, sstvenc_mod::remaining, SSTVENC_ENCODER_PHASE_DONE, sstvenc_modulator_next_tone(), sstvenc_osc_compute(), sstvenc_ps_advance(), sstvenc_ps_compute(), and SSTVENC_PS_PHASE_FALL.
Referenced by sstvenc_modulator_compute().
|
static |
Compute the next sample whilst in the RISE phase of the pulse shaper state machine.
Definition at line 37 of file sstvmod.c.
References sstvenc_oscillator::amplitude, sstvenc_mod::osc, sstvenc_pulseshape::output, sstvenc_mod::ps, sstvenc_osc_compute(), and sstvenc_ps_compute().
Referenced by sstvenc_modulator_compute().
|
static |
Compute the next tone.
Definition at line 46 of file sstvmod.c.
References sstvenc_encoder_pulse::duration_ns, sstvenc_mod::enc, sstvenc_encoder_pulse::frequency, sstvenc_mod::osc, sstvenc_encoder::phase, sstvenc_mod::remaining, sstvenc_oscillator::sample_rate, sstvenc_encoder_next_pulse(), SSTVENC_ENCODER_PHASE_DONE, sstvenc_osc_set_frequency(), SSTVENC_TS_UNIT_NANOSECONDS, sstvenc_ts_unit_to_samples(), sstvenc_mod::total_ns, and sstvenc_mod::total_samples.
Referenced by sstvenc_modulator_next_hold_sample().