query2.c
3.98 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
Audio File Library
Copyright 1998-2000, Michael Pruett <michael@68k.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
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 General Public
License along with this program; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307, USA.
*/
#ifdef __USE_SGI_HEADERS__
#include <dmedia/audiofile.h>
#include <dmedia/audioutil.h>
#else
#include <audiofile.h>
#include <aupvlist.h>
#endif
#include <stdio.h>
#include <stdlib.h>
const char *paramtypename (int paramtype);
void printinstparams (int format);
#define DEBUG
#ifdef DEBUG
#define DEBG printf
#else
#define DEBG
#endif
int main (int ac, char **av)
{
AUpvlist formatlist;
int *flist;
long lvalue;
int i, formatcount;
formatlist = afQuery(AF_QUERYTYPE_FILEFMT, AF_QUERY_IDS, 0, 0, 0);
formatcount = afQueryLong(AF_QUERYTYPE_FILEFMT, AF_QUERY_ID_COUNT, 0, 0, 0);
DEBG("formatcount = %d\n", formatcount);
AUpvgetval(formatlist, 0, &flist);
AUpvfree(formatlist);
for (i=0; i<formatcount; i++)
{
int format;
char *formatstring;
format = flist[i];
DEBG("format = %d\n", format);
formatstring = afQueryPointer(AF_QUERYTYPE_FILEFMT, AF_QUERY_NAME,
format, 0, 0);
DEBG("format = %s\n", formatstring);
lvalue = afQueryLong(AF_QUERYTYPE_INST, AF_QUERY_SUPPORTED,
format, 0, 0);
DEBG("instrument query: supported: %ld\n", lvalue);
lvalue = afQueryLong(AF_QUERYTYPE_INST, AF_QUERY_MAX_NUMBER,
format, 0, 0);
DEBG("instrument query: maximum number: %ld\n", lvalue);
lvalue = afQueryLong(AF_QUERYTYPE_INSTPARAM, AF_QUERY_SUPPORTED,
format, 0, 0);
DEBG("instrument parameter query: supported: %ld\n", lvalue);
/*
Print instrument parameter information only if
instrument parameters are supported.
*/
if (lvalue)
printinstparams(format);
}
free(flist);
return 0;
}
void printinstparams (int format)
{
int i, *iarray;
long instParamCount;
instParamCount = afQueryLong(AF_QUERYTYPE_INSTPARAM, AF_QUERY_ID_COUNT,
format, 0, 0);
DEBG("instrument parameter query: id count: %ld\n", instParamCount);
iarray = afQueryPointer(AF_QUERYTYPE_INSTPARAM, AF_QUERY_IDS,
format, 0, 0);
if (iarray == NULL)
printf("AF_QUERYTYPE_INSTPARAM failed for format %d\n", format);
for (i=0; i<instParamCount; i++)
{
int paramType;
AUpvlist defaultValue;
DEBG("instrument parameter query: id: %d\n", iarray[i]);
paramType = afQueryLong(AF_QUERYTYPE_INSTPARAM,
AF_QUERY_TYPE, format, iarray[i], 0);
DEBG("\ttype of parameter: %s\n", paramtypename(paramType));
DEBG("\tname of parameter: %s\n",
(char *) afQueryPointer(AF_QUERYTYPE_INSTPARAM,
AF_QUERY_NAME, format, iarray[i], 0));
defaultValue = afQuery(AF_QUERYTYPE_INSTPARAM, AF_QUERY_DEFAULT,
format, iarray[i], 0);
if (paramType == AU_PVTYPE_LONG)
{
long ldefault;
AUpvgetval(defaultValue, 0, &ldefault);
DEBG("\tdefault value: %ld\n", ldefault);
}
else if (paramType == AU_PVTYPE_DOUBLE)
{
double ddefault;
AUpvgetval(defaultValue, 0, &ddefault);
DEBG("\tdefault value: %f\n", ddefault);
}
else if (paramType == AU_PVTYPE_PTR)
{
void *vdefault;
AUpvgetval(defaultValue, 0, &vdefault);
DEBG("\tdefault value: %p\n", vdefault);
}
}
free(iarray);
}
const char *paramtypename (int paramtype)
{
static const char *longname = "long";
static const char *doublename = "double";
static const char *pointername = "pointer";
switch (paramtype)
{
case AU_PVTYPE_LONG:
return longname;
case AU_PVTYPE_DOUBLE:
return doublename;
case AU_PVTYPE_PTR:
return pointername;
}
return NULL;
}