source: roaraudio/libroardsp/synth.c @ 2426:122c29dbcd87

Last change on this file since 2426:122c29dbcd87 was 2426:122c29dbcd87, checked in by phi, 15 years ago

added very basic code for synth

File size: 2.0 KB
Line 
1//synth.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009
5 *
6 *  This file is part of libroardsp a part of RoarAudio,
7 *  a cross-platform sound system for both, home and professional use.
8 *  See README for details.
9 *
10 *  This file is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU General Public License version 3
12 *  as published by the Free Software Foundation.
13 *
14 *  libroardsp is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU General Public License for more details.
18 *
19 *  You should have received a copy of the GNU General Public License
20 *  along with this software; see the file COPYING.  If not, write to
21 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */
24
25#include "libroardsp.h"
26
27#define _CHECK_BASIC() if ( state == NULL ) return -1
28
29int roar_synth_init(struct roar_synth_state * state, struct roar_note_octave * note, int rate) {
30 _CHECK_BASIC();
31
32 if ( rate <= 0 )
33  return -1;
34
35 memset(state, 0, sizeof(struct roar_synth_state));
36
37 state->note = note; // NULL is valid here!
38 state->rate = rate;
39
40 state->func = ROAR_SYNTH_SYNF_SINE;
41
42 return 0;
43}
44
45int roar_synth_set_offset(struct roar_synth_state * state, size_t offset) {
46 _CHECK_BASIC();
47
48 state->pcmoffset = offset;
49
50 return 0;
51}
52
53int roar_synth_set_func  (struct roar_synth_state * state, ROAR_SYNTH_FUNC_TYPE(func)) {
54 _CHECK_BASIC();
55
56 state->func = func;
57
58 return 0;
59}
60
61int roar_synth_pcmout_i16n(struct roar_synth_state * state, int16_t * out, size_t frames, int channels) {
62 _CHECK_BASIC();
63
64 if ( out == NULL )
65  return -1;
66
67 if ( frames == 0 )
68  return 0;
69
70 switch (channels) {
71  case 1: return roar_synth_pcmout_i161(state, out, frames);
72  default:
73    return -1;
74 }
75
76 return 0;
77}
78
79int roar_synth_pcmout_i161(struct roar_synth_state * state, int16_t * out, size_t frames) {
80 _CHECK_BASIC();
81
82 return -1;
83}
84
85
86//ll
Note: See TracBrowser for help on using the repository browser.