1
2 /*
3 * Diverse Bristol audio routines.
4 * Copyright (c) by Nick Copeland <nickycopeland@hotmail.com> 1996,2012
5 *
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 3 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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22 /*
23 * Library routines for operator management. Initialisation, creation and
24 * destruction of operator.s
25 */
26
27 #include "bristol.h"
28
29 extern void bristolfree(char *);
30
31 void
bristolOPfree(bristolOP * operator)32 bristolOPfree(bristolOP *operator)
33 {
34 #ifdef DEBUG
35 printf("bristolOPfree(%x)\n", operator);
36 #endif
37
38 bristolfree((char *) operator);
39 }
40
41 /*
42 * Free up any memory from our op and io structures. Should be in library.
43 */
44 int
cleanup(bristolOP * operator)45 cleanup(bristolOP *operator)
46 {
47 #ifdef DEBUG
48 printf("cleanup(%x)\n", operator);
49 #endif
50
51 bristolOPfree(operator);
52
53 return(0);
54 }
55
56 bristolIO *
bristolIOinit(bristolIO ** io,int index,char * name,int rate,int samplecount)57 bristolIOinit(bristolIO **io, int index, char *name, int rate, int samplecount)
58 {
59 #ifdef DEBUG
60 printf("bristolIOinit(%x, %i, %s, %i, %i)\n",
61 io, index, name, rate, samplecount);
62 #endif
63
64 *io = (bristolIO *) bristolmalloc(sizeof(bristolIO));
65
66 /*
67 * Much of this will probably go into a library, for the basic init work
68 * of any operator. The local stuff will remain in the operator code.
69 */
70 (*io)->IOname = name;
71 (*io)->index = index;
72 (*io)->flags = 0;
73 (*io)->last = (struct BristolIO *) NULL;
74 (*io)->next = (struct BristolIO *) NULL;
75 (*io)->samplecnt = samplecount;
76 (*io)->samplerate = rate;
77
78 /*
79 * And get an IO buffer.
80 */
81 (*io)->bufmem = (float *) bristolmalloc((*io)->samplecnt * sizeof(float));
82
83 return(*io);
84 }
85
86 /*
87 * Create the operator structure, and do some basic init work.
88 */
89 bristolOP *
bristolOPinit(bristolOP ** operator,int index,int samplecount)90 bristolOPinit(bristolOP **operator, int index, int samplecount)
91 {
92 #ifdef DEBUG
93 printf("bristolOPinit(%x, %i, %i)\n", operator, index, samplecount);
94 #endif
95
96 *operator = (bristolOP *) bristolmalloc(sizeof(bristolOP));
97
98 /*
99 * Much of this will probably go into a library, for the basic init work
100 * of any operator. The local stuff will remain in the operator code.
101 */
102 (*operator)->index = index;
103 (*operator)->flags = 0;
104 (*operator)->last = (struct BristolOP *) NULL; /* filled in by parent */
105 (*operator)->next = (struct BristolOP *) NULL; /* filled in by parent */
106
107 return(*operator);
108 }
109
110