~ubuntu-branches/ubuntu/trusty/multimon/trusty-proposed

« back to all changes in this revision

Viewing changes to gen_sin.c

  • Committer: Bazaar Package Importer
  • Author(s): A. Maitland Bottoms
  • Date: 2000-06-27 22:28:14 UTC
  • Revision ID: james.westby@ubuntu.com-20000627222814-r12knsgtb3acg3r0
Tags: 1.0-2
* test for Intel architecture before using (e.g. -m486) flags, 
  (closes:Bug#66281)
* Initial Emergency Alert System (EAS) decoder hacking

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *      gen_sine.c -- generate DTMF sequences
 
3
 *
 
4
 *      Copyright (C) 1997
 
5
 *          Thomas Sailer (sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu)
 
6
 *
 
7
 *      This program is free software; you can redistribute it and/or modify
 
8
 *      it under the terms of the GNU General Public License as published by
 
9
 *      the Free Software Foundation; either version 2 of the License, or
 
10
 *      (at your option) any later version.
 
11
 *
 
12
 *      This program is distributed in the hope that it will be useful,
 
13
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 *      GNU General Public License for more details.
 
16
 *
 
17
 *      You should have received a copy of the GNU General Public License
 
18
 *      along with this program; if not, write to the Free Software
 
19
 *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
20
 */
 
21
 
 
22
/* ---------------------------------------------------------------------- */
 
23
 
 
24
#include "gen.h"
 
25
#include <string.h>
 
26
 
 
27
/* ---------------------------------------------------------------------- */
 
28
 
 
29
void gen_init_sine(struct gen_params *p, struct gen_state *s)
 
30
{
 
31
        memset(s, 0, sizeof(struct gen_state));
 
32
        s->s.sine.ph = 0;
 
33
        s->s.sine.phinc = (float)0x10000 * p->p.sine.freq / SAMPLE_RATE;
 
34
        s->s.sine.time = p->p.sine.duration;
 
35
}
 
36
 
 
37
int gen_sine(signed short *buf, int buflen, struct gen_params *p, struct gen_state *s)
 
38
{
 
39
        int num = 0;
 
40
 
 
41
        for (; (buflen > 0) && (s->s.sine.time > 0); buflen--, buf++, num++, s->s.sine.time--) {
 
42
                *buf += (p->ampl * COS(s->s.sine.ph)) >> 15;
 
43
                s->s.sine.ph += s->s.sine.phinc;
 
44
        }
 
45
        return num;
 
46
}