Add sound manager initial source code
[staging/soundmanager.git] / sample / radio / binding / convenience / convenience.h
1 /*
2  * Copyright (C) 2014 by Kyle Keen <keenerd@gmail.com>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 /* a collection of user friendly tools */
19
20 /*!
21  * Convert standard suffixes (k, M, G) to double
22  *
23  * \param s a string to be parsed
24  * \return double
25  */
26
27 double atofs(char *s);
28
29 /*!
30  * Convert time suffixes (s, m, h) to double
31  *
32  * \param s a string to be parsed
33  * \return seconds as double
34  */
35
36 double atoft(char *s);
37
38 /*!
39  * Convert percent suffixe (%) to double
40  *
41  * \param s a string to be parsed
42  * \return double
43  */
44
45 double atofp(char *s);
46
47 /*!
48  * Find nearest supported gain
49  *
50  * \param dev the device handle given by rtlsdr_open()
51  * \param target_gain in tenths of a dB
52  * \return 0 on success
53  */
54
55 int nearest_gain(rtlsdr_dev_t *dev, int target_gain);
56
57 /*!
58  * Set device frequency and report status on stderr
59  *
60  * \param dev the device handle given by rtlsdr_open()
61  * \param frequency in Hz
62  * \return 0 on success
63  */
64
65 int verbose_set_frequency(rtlsdr_dev_t *dev, uint32_t frequency);
66
67 /*!
68  * Set device sample rate and report status on stderr
69  *
70  * \param dev the device handle given by rtlsdr_open()
71  * \param samp_rate in samples/second
72  * \return 0 on success
73  */
74
75 int verbose_set_sample_rate(rtlsdr_dev_t *dev, uint32_t samp_rate);
76
77 /*!
78  * Enable or disable the direct sampling mode and report status on stderr
79  *
80  * \param dev the device handle given by rtlsdr_open()
81  * \param on 0 means disabled, 1 I-ADC input enabled, 2 Q-ADC input enabled
82  * \return 0 on success
83  */
84
85 int verbose_direct_sampling(rtlsdr_dev_t *dev, int on);
86
87 /*!
88  * Enable offset tuning and report status on stderr
89  *
90  * \param dev the device handle given by rtlsdr_open()
91  * \return 0 on success
92  */
93
94 int verbose_offset_tuning(rtlsdr_dev_t *dev);
95
96 /*!
97  * Enable auto gain and report status on stderr
98  *
99  * \param dev the device handle given by rtlsdr_open()
100  * \return 0 on success
101  */
102
103 int verbose_auto_gain(rtlsdr_dev_t *dev);
104
105 /*!
106  * Set tuner gain and report status on stderr
107  *
108  * \param dev the device handle given by rtlsdr_open()
109  * \param gain in tenths of a dB
110  * \return 0 on success
111  */
112
113 int verbose_gain_set(rtlsdr_dev_t *dev, int gain);
114
115 /*!
116  * Set the frequency correction value for the device and report status on stderr.
117  *
118  * \param dev the device handle given by rtlsdr_open()
119  * \param ppm_error correction value in parts per million (ppm)
120  * \return 0 on success
121  */
122
123 int verbose_ppm_set(rtlsdr_dev_t *dev, int ppm_error);
124
125 /*!
126  * Reset buffer
127  *
128  * \param dev the device handle given by rtlsdr_open()
129  * \return 0 on success
130  */
131
132 int verbose_reset_buffer(rtlsdr_dev_t *dev);
133
134 /*!
135  * Find the closest matching device.
136  *
137  * \param s a string to be parsed
138  * \return dev_index int, -1 on error
139  */
140
141 int verbose_device_search(char *s);
142