From: sjlongland Date: Thu, 24 Sep 2015 08:12:04 +0000 (+0000) Subject: Relocate header files to inc X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=34e3d734c6d66053c0b97aa9c9a45b8af1ee4908;p=freetel-svn-tracking.git Relocate header files to inc git-svn-id: https://svn.code.sf.net/p/freetel/code@2363 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/stm32/inc/morse.h b/codec2-dev/stm32/inc/morse.h new file mode 100644 index 00000000..632f2e24 --- /dev/null +++ b/codec2-dev/stm32/inc/morse.h @@ -0,0 +1,65 @@ +#ifndef _MORSE_H +#define _MORSE_H +/*! + * Morse code library. + * + * This implements a state machine for playing back morse code messages. + * + * Author Stuart Longland + * Copyright (C) 2015 FreeDV project. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see + * . + */ + +#include "sfx.h" + +/*! + * Maximum length of a morse symbol, including gaps and termination. + * Allowing for 8 actual sub-symbols (dahs and dits), that's up to + * 8 gaps between plus a terminator. + */ +#define MORSE_SYM_LEN (17) + +/*! + * Morse code playback state machine + */ +struct morse_player_t { + /*! Symbol being transmitted */ + struct sfx_note_t sym[MORSE_SYM_LEN]; + /*! + * Pointer to the string being emitted. Playback is finished + * when this is NULL. + */ + const char* msg; + /*! Sound effect player state machine */ + struct sfx_player_t sfx_player; + /*! "Dit" period in milliseconds */ + uint16_t dit_time; + /*! Tone frequency */ + uint16_t freq; +}; + +/*! + * Play a morse code message. + * @param morse_player Morse code player state machine + * @param msg Message to play back (NULL == stop) + */ +void morse_play(struct morse_player_t* const morse_player, + const char* msg); + +/*! + * Retrieve the next sample to be played. + */ +int16_t morse_next(struct morse_player_t* const morse_player); + +#endif diff --git a/codec2-dev/stm32/inc/sfx.h b/codec2-dev/stm32/inc/sfx.h new file mode 100644 index 00000000..97450186 --- /dev/null +++ b/codec2-dev/stm32/inc/sfx.h @@ -0,0 +1,63 @@ +#ifndef _SFX_H +#define _SFX_H +/*! + * Sound effect player library. + * + * This implements a state machine for playing back various monophonic + * sound effects such as morse code symbols, clicks and alert tones. + * + * Author Stuart Longland + * Copyright (C) 2015 FreeDV project. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see + * . + */ + +#include "tone.h" + +/*! + * A sound effect "note" + */ +struct sfx_note_t { + /*! Note frequency. 0 == pause */ + uint16_t freq; + /*! Note duration in msec. 0 == end of effect */ + uint16_t duration; +}; + +/*! + * Sound effect player state machine + */ +struct sfx_player_t { + /*! + * Pointer to the current "note". When this is NULL, + * playback is complete. + */ + const struct sfx_note_t* note; + /*! Tone generator state machine */ + struct tone_gen_t tone_gen; +}; + +/*! + * Start playing a particular effect. + * @param sfx_player Effect player state machine + * @param effect Pointer to sound effect (NULL == stop) + */ +void sfx_play(struct sfx_player_t* const sfx_player, + const struct sfx_note_t* effect); + +/*! + * Retrieve the next sample to be played. + */ +int16_t sfx_next(struct sfx_player_t* const sfx_player); + +#endif diff --git a/codec2-dev/stm32/inc/sine.h b/codec2-dev/stm32/inc/sine.h new file mode 100644 index 00000000..3a3ce46d --- /dev/null +++ b/codec2-dev/stm32/inc/sine.h @@ -0,0 +1,48 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: sine.h + AUTHOR......: David Rowe + DATE CREATED: 1/11/94 + + Header file for sinusoidal analysis and synthesis functions. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2009 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. This program is + distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, see . +*/ + +#ifndef __SINE__ +#define __SINE__ + +#include "defines.h" +#include "comp.h" +#include "kiss_fft.h" + +void make_analysis_window(kiss_fft_cfg fft_fwd_cfg, float w[], COMP W[]); +float hpf(float x, float states[]); +void dft_speech(kiss_fft_cfg fft_fwd_cfg, COMP Sw[], float Sn[], float w[]); +void two_stage_pitch_refinement(MODEL *model, COMP Sw[]); +void estimate_amplitudes(MODEL *model, COMP Sw[], COMP W[], int est_phase); +float est_voicing_mbe(MODEL *model, COMP Sw[], COMP W[], COMP Sw_[],COMP Ew[], + float prev_Wo); +void make_synthesis_window(float Pn[]); +void synthesise(kiss_fft_cfg fft_inv_cfg, float Sn_[], MODEL *model, float Pn[], int shift); + +#define CODEC2_RAND_MAX 32767 +int codec2_rand(void); + +#endif diff --git a/codec2-dev/stm32/inc/sounds.h b/codec2-dev/stm32/inc/sounds.h new file mode 100644 index 00000000..34f8fad0 --- /dev/null +++ b/codec2-dev/stm32/inc/sounds.h @@ -0,0 +1,32 @@ +#ifndef _SOUNDS_H +#define _SOUNDS_H +/*! + * Sound effect library. + * + * This provides some sound effects for the SM1000 UI. + * + * Author Stuart Longland + * Copyright (C) 2015 FreeDV project. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see + * . + */ + +#include "sfx.h" + +/*! Start-up tune */ +extern struct sfx_note_t sound_startup[]; + +/*! Click sound */ +extern struct sfx_note_t sound_click[]; + +#endif diff --git a/codec2-dev/stm32/inc/tone.h b/codec2-dev/stm32/inc/tone.h new file mode 100644 index 00000000..b7441ca4 --- /dev/null +++ b/codec2-dev/stm32/inc/tone.h @@ -0,0 +1,84 @@ +#ifndef _TONE_H +#define _TONE_H +/*! + * Fixed-point tone generator. + * + * The code here implements a simple fixed-point tone generator that uses + * integer arithmetic to generate a sinusoid at a fixed sample rate of + * 16kHz. + * + * To set the initial state of the state machine, you specify a frequency + * and duration using tone_reset. The corresponding C file embeds a + * sinusoid look-up table. The total number of samples is computed for + * the given time and used to initialise 'remain', 'time' is initialised + * to 0, and 'step' gives the amount to increment 'time' by each iteration. + * + * The samples are retrieved by repeatedly calling tone_next. This + * advances 'time' and decrements 'remain'. The tone is complete when + * 'remain' is zero. + * + * Author Stuart Longland + * Copyright (C) 2015 FreeDV project. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 2.1, + * as published by the Free Software Foundation. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see + * . + */ + +#include + +/*! Tone sampling rate in Hz. */ +#define TONE_FS 16000 + +/*! + * Tone generator state. This holds the current state of the tone + * generator in order to decide what sample to release next. + */ +struct tone_gen_t { + /*! Current sample. (Q12) */ + uint32_t sample; + /*! + * Time remaining in samples. (integer) Playback is finished + * when this reaches zero. + */ + uint16_t remain; + /*! + * Subsample step (Q12). This is the number of samples (or part + * thereof) to advance "sample". Special case: when zero, sample + * is not advanced, silence is generated instead. + */ + uint16_t step; +}; + +/*! + * Re-set the tone generator. + * + * @param tone_gen Tone generator to reset. + * @param freq Frequency in Hz, 0 = silence. + * @param duration Duration in milliseconds. 0 to stop. + */ +void tone_reset( + struct tone_gen_t* const tone_gen, + uint16_t freq, uint16_t duration); + +/*! + * Retrieve the next sample from the tone generator. + * @param tone_gen Tone generator to update. + */ +int16_t tone_next( + struct tone_gen_t* const tone_gen); + +/*! + * Retrieve the current time in milliseconds. + */ +uint32_t tone_msec(const struct tone_gen_t* const tone_gen); + +#endif diff --git a/codec2-dev/stm32/src/morse.h b/codec2-dev/stm32/src/morse.h deleted file mode 100644 index 632f2e24..00000000 --- a/codec2-dev/stm32/src/morse.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef _MORSE_H -#define _MORSE_H -/*! - * Morse code library. - * - * This implements a state machine for playing back morse code messages. - * - * Author Stuart Longland - * Copyright (C) 2015 FreeDV project. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License version 2.1, - * as published by the Free Software Foundation. This program is - * distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see - * . - */ - -#include "sfx.h" - -/*! - * Maximum length of a morse symbol, including gaps and termination. - * Allowing for 8 actual sub-symbols (dahs and dits), that's up to - * 8 gaps between plus a terminator. - */ -#define MORSE_SYM_LEN (17) - -/*! - * Morse code playback state machine - */ -struct morse_player_t { - /*! Symbol being transmitted */ - struct sfx_note_t sym[MORSE_SYM_LEN]; - /*! - * Pointer to the string being emitted. Playback is finished - * when this is NULL. - */ - const char* msg; - /*! Sound effect player state machine */ - struct sfx_player_t sfx_player; - /*! "Dit" period in milliseconds */ - uint16_t dit_time; - /*! Tone frequency */ - uint16_t freq; -}; - -/*! - * Play a morse code message. - * @param morse_player Morse code player state machine - * @param msg Message to play back (NULL == stop) - */ -void morse_play(struct morse_player_t* const morse_player, - const char* msg); - -/*! - * Retrieve the next sample to be played. - */ -int16_t morse_next(struct morse_player_t* const morse_player); - -#endif diff --git a/codec2-dev/stm32/src/sfx.h b/codec2-dev/stm32/src/sfx.h deleted file mode 100644 index 97450186..00000000 --- a/codec2-dev/stm32/src/sfx.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef _SFX_H -#define _SFX_H -/*! - * Sound effect player library. - * - * This implements a state machine for playing back various monophonic - * sound effects such as morse code symbols, clicks and alert tones. - * - * Author Stuart Longland - * Copyright (C) 2015 FreeDV project. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License version 2.1, - * as published by the Free Software Foundation. This program is - * distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see - * . - */ - -#include "tone.h" - -/*! - * A sound effect "note" - */ -struct sfx_note_t { - /*! Note frequency. 0 == pause */ - uint16_t freq; - /*! Note duration in msec. 0 == end of effect */ - uint16_t duration; -}; - -/*! - * Sound effect player state machine - */ -struct sfx_player_t { - /*! - * Pointer to the current "note". When this is NULL, - * playback is complete. - */ - const struct sfx_note_t* note; - /*! Tone generator state machine */ - struct tone_gen_t tone_gen; -}; - -/*! - * Start playing a particular effect. - * @param sfx_player Effect player state machine - * @param effect Pointer to sound effect (NULL == stop) - */ -void sfx_play(struct sfx_player_t* const sfx_player, - const struct sfx_note_t* effect); - -/*! - * Retrieve the next sample to be played. - */ -int16_t sfx_next(struct sfx_player_t* const sfx_player); - -#endif diff --git a/codec2-dev/stm32/src/sine.h b/codec2-dev/stm32/src/sine.h deleted file mode 100644 index 3a3ce46d..00000000 --- a/codec2-dev/stm32/src/sine.h +++ /dev/null @@ -1,48 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: sine.h - AUTHOR......: David Rowe - DATE CREATED: 1/11/94 - - Header file for sinusoidal analysis and synthesis functions. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2009 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. This program is - distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program; if not, see . -*/ - -#ifndef __SINE__ -#define __SINE__ - -#include "defines.h" -#include "comp.h" -#include "kiss_fft.h" - -void make_analysis_window(kiss_fft_cfg fft_fwd_cfg, float w[], COMP W[]); -float hpf(float x, float states[]); -void dft_speech(kiss_fft_cfg fft_fwd_cfg, COMP Sw[], float Sn[], float w[]); -void two_stage_pitch_refinement(MODEL *model, COMP Sw[]); -void estimate_amplitudes(MODEL *model, COMP Sw[], COMP W[], int est_phase); -float est_voicing_mbe(MODEL *model, COMP Sw[], COMP W[], COMP Sw_[],COMP Ew[], - float prev_Wo); -void make_synthesis_window(float Pn[]); -void synthesise(kiss_fft_cfg fft_inv_cfg, float Sn_[], MODEL *model, float Pn[], int shift); - -#define CODEC2_RAND_MAX 32767 -int codec2_rand(void); - -#endif diff --git a/codec2-dev/stm32/src/sounds.h b/codec2-dev/stm32/src/sounds.h deleted file mode 100644 index 34f8fad0..00000000 --- a/codec2-dev/stm32/src/sounds.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _SOUNDS_H -#define _SOUNDS_H -/*! - * Sound effect library. - * - * This provides some sound effects for the SM1000 UI. - * - * Author Stuart Longland - * Copyright (C) 2015 FreeDV project. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License version 2.1, - * as published by the Free Software Foundation. This program is - * distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see - * . - */ - -#include "sfx.h" - -/*! Start-up tune */ -extern struct sfx_note_t sound_startup[]; - -/*! Click sound */ -extern struct sfx_note_t sound_click[]; - -#endif diff --git a/codec2-dev/stm32/src/tone.h b/codec2-dev/stm32/src/tone.h deleted file mode 100644 index b7441ca4..00000000 --- a/codec2-dev/stm32/src/tone.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef _TONE_H -#define _TONE_H -/*! - * Fixed-point tone generator. - * - * The code here implements a simple fixed-point tone generator that uses - * integer arithmetic to generate a sinusoid at a fixed sample rate of - * 16kHz. - * - * To set the initial state of the state machine, you specify a frequency - * and duration using tone_reset. The corresponding C file embeds a - * sinusoid look-up table. The total number of samples is computed for - * the given time and used to initialise 'remain', 'time' is initialised - * to 0, and 'step' gives the amount to increment 'time' by each iteration. - * - * The samples are retrieved by repeatedly calling tone_next. This - * advances 'time' and decrements 'remain'. The tone is complete when - * 'remain' is zero. - * - * Author Stuart Longland - * Copyright (C) 2015 FreeDV project. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License version 2.1, - * as published by the Free Software Foundation. This program is - * distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see - * . - */ - -#include - -/*! Tone sampling rate in Hz. */ -#define TONE_FS 16000 - -/*! - * Tone generator state. This holds the current state of the tone - * generator in order to decide what sample to release next. - */ -struct tone_gen_t { - /*! Current sample. (Q12) */ - uint32_t sample; - /*! - * Time remaining in samples. (integer) Playback is finished - * when this reaches zero. - */ - uint16_t remain; - /*! - * Subsample step (Q12). This is the number of samples (or part - * thereof) to advance "sample". Special case: when zero, sample - * is not advanced, silence is generated instead. - */ - uint16_t step; -}; - -/*! - * Re-set the tone generator. - * - * @param tone_gen Tone generator to reset. - * @param freq Frequency in Hz, 0 = silence. - * @param duration Duration in milliseconds. 0 to stop. - */ -void tone_reset( - struct tone_gen_t* const tone_gen, - uint16_t freq, uint16_t duration); - -/*! - * Retrieve the next sample from the tone generator. - * @param tone_gen Tone generator to update. - */ -int16_t tone_next( - struct tone_gen_t* const tone_gen); - -/*! - * Retrieve the current time in milliseconds. - */ -uint32_t tone_msec(const struct tone_gen_t* const tone_gen); - -#endif