kopia lustrzana https://github.com/eleccoder/raspi-pico-aprs-tnc
Extra parameter for aprs_pico_send_sine_wave()
rodzic
5869d83de5
commit
09256da282
|
@ -65,8 +65,9 @@ bool aprs_pico_sendAPRS(audio_buffer_pool_t* audio_buffer_pool,
|
||||||
*
|
*
|
||||||
* \param[in, out] audio_buffer_pool The pool of audio buffers to be used for rendering the sine audio signal
|
* \param[in, out] audio_buffer_pool The pool of audio buffers to be used for rendering the sine audio signal
|
||||||
* \param[in] freq_in_hz The frequency of the sine wave to be generated (in Hz)
|
* \param[in] freq_in_hz The frequency of the sine wave to be generated (in Hz)
|
||||||
|
* \param[in] sample_freq_in_hz The sampling frequency of the sine wave to be generated (in Hz)
|
||||||
* \param[in] volume The volume level of the generated signal (0 ... 256)
|
* \param[in] volume The volume level of the generated signal (0 ... 256)
|
||||||
*/
|
*/
|
||||||
void aprs_pico_send_sine_wave(audio_buffer_pool_t* audio_buffer_pool, unsigned int freq_in_hz, uint16_t volume);
|
void aprs_pico_send_sine_wave(audio_buffer_pool_t* audio_buffer_pool, unsigned int freq_in_hz, unsigned int sample_freq_in_hz, uint16_t volume);
|
||||||
|
|
||||||
#endif // APRS_PICO_H
|
#endif // APRS_PICO_H
|
||||||
|
|
|
@ -183,20 +183,17 @@ audio_buffer_pool_t* aprs_pico_init()
|
||||||
|
|
||||||
|
|
||||||
// See the header file for documentation
|
// See the header file for documentation
|
||||||
void aprs_pico_send_sine_wave(audio_buffer_pool_t* audio_buffer_pool, unsigned int freq_in_hz, uint16_t volume)
|
void aprs_pico_send_sine_wave(audio_buffer_pool_t* audio_buffer_pool, unsigned int freq_in_hz, unsigned int sample_freq_in_hz, uint16_t volume)
|
||||||
{
|
{
|
||||||
assert(audio_buffer_pool != NULL);
|
assert(audio_buffer_pool != NULL);
|
||||||
|
|
||||||
// WARNING: ATTOW, the pico audio PWM lib worked only @ 22050 Hz sampling frequency and 48 MHz system clock
|
|
||||||
// This is documented here: https://github.com/raspberrypi/pico-extras
|
|
||||||
const unsigned int SAMPLE_FREQ_IN_HZ = APRS_PICO__PICO_EXTRA_AUDIO_PWM_LIB_FIXED_SAMPLE_FREQ_IN_HZ;
|
|
||||||
const unsigned int num_samples_per_period = SAMPLE_FREQ_IN_HZ / freq_in_hz;
|
|
||||||
|
|
||||||
typedef int16_t wave_table_value_t;
|
typedef int16_t wave_table_value_t;
|
||||||
const wave_table_value_t WAVE_TABLE_VALUE_MAX = INT16_MAX;
|
const wave_table_value_t WAVE_TABLE_VALUE_MAX = INT16_MAX;
|
||||||
|
|
||||||
|
|
||||||
aprs_pico_initClock(SAMPLE_FREQ_IN_HZ);
|
aprs_pico_initClock(sample_freq_in_hz);
|
||||||
|
|
||||||
|
const unsigned int num_samples_per_period = sample_freq_in_hz / freq_in_hz;
|
||||||
|
|
||||||
wave_table_value_t* sine_period_wave_table = malloc(num_samples_per_period * sizeof(wave_table_value_t));
|
wave_table_value_t* sine_period_wave_table = malloc(num_samples_per_period * sizeof(wave_table_value_t));
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,11 @@ int main()
|
||||||
|
|
||||||
#if (SINE_WAVE_TEST == 1)
|
#if (SINE_WAVE_TEST == 1)
|
||||||
|
|
||||||
const unsigned int FREQ_IN_HZ = 1000u;
|
const unsigned int FREQ_IN_HZ = 1000u;
|
||||||
const uint16_t VOLUME = 128u;
|
const unsigned int SAMPLE_FREQ_IN_HZ = 48000u;
|
||||||
|
const uint16_t VOLUME = 128u;
|
||||||
|
|
||||||
aprs_pico_send_sine_wave(audio_buffer_pool, FREQ_IN_HZ, VOLUME);
|
aprs_pico_send_sine_wave(audio_buffer_pool, FREQ_IN_HZ, SAMPLE_FREQ_IN_HZ, VOLUME);
|
||||||
|
|
||||||
#else // !SINE_WAVE_TEST
|
#else // !SINE_WAVE_TEST
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue