blob: 632f2e2495791a71b5302f3929b7c25be88d533c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#ifndef _MORSE_H
#define _MORSE_H
/*!
* Morse code library.
*
* This implements a state machine for playing back morse code messages.
*
* Author Stuart Longland <[email protected]>
* 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
* <http://www.gnu.org/licenses/>.
*/
#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
|