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); }
TEST(Query, CompressionFormats) { IgnoreErrors ignoreErrors; int compressionFormats[] = { AF_COMPRESSION_NONE, AF_COMPRESSION_G711_ULAW, AF_COMPRESSION_G711_ALAW, AF_COMPRESSION_IMA, AF_COMPRESSION_MS_ADPCM, AF_COMPRESSION_G722, AF_COMPRESSION_APPLE_ACE2, AF_COMPRESSION_APPLE_ACE8, AF_COMPRESSION_APPLE_MAC3, AF_COMPRESSION_APPLE_MAC6 }; int numCompressionFormats = sizeof (compressionFormats) / sizeof (int); for (int i=0; i<numCompressionFormats; i++) { long implemented = afQueryLong(AF_QUERYTYPE_COMPRESSION, AF_QUERY_IMPLEMENTED, compressionFormats[i], 0, 0); long nativeSampleFormat = afQueryLong(AF_QUERYTYPE_COMPRESSION, AF_QUERY_NATIVE_SAMPFMT, compressionFormats[i], 0, 0); if (implemented) EXPECT_TRUE(nativeSampleFormat == AF_SAMPFMT_TWOSCOMP || nativeSampleFormat == AF_SAMPFMT_UNSIGNED || nativeSampleFormat == AF_SAMPFMT_FLOAT || nativeSampleFormat == AF_SAMPFMT_DOUBLE); long nativeSampleWidth = afQueryLong(AF_QUERYTYPE_COMPRESSION, AF_QUERY_NATIVE_SAMPWIDTH, compressionFormats[i], 0, 0); if (implemented) { EXPECT_GE(nativeSampleWidth, 1); EXPECT_LE(nativeSampleWidth, 64); } const char *label = static_cast<const char *>(afQueryPointer(AF_QUERYTYPE_COMPRESSION, AF_QUERY_LABEL, compressionFormats[i], 0, 0)); if (implemented) EXPECT_TRUE(label); const char *name = static_cast<const char *>(afQueryPointer(AF_QUERYTYPE_COMPRESSION, AF_QUERY_NAME, compressionFormats[i], 0, 0)); if (implemented) EXPECT_TRUE(name); const char *description = static_cast<const char *>(afQueryPointer(AF_QUERYTYPE_COMPRESSION, AF_QUERY_DESC, compressionFormats[i], 0, 0)); if (implemented) EXPECT_TRUE(description); } }
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; }
TEST(Query, FileFormats) { IgnoreErrors ignoreErrors; int fileFormats[] = { AF_FILE_UNKNOWN, AF_FILE_RAWDATA, AF_FILE_AIFFC, AF_FILE_AIFF, AF_FILE_NEXTSND, AF_FILE_WAVE, AF_FILE_BICSF, AF_FILE_MPEG1BITSTREAM, AF_FILE_SOUNDDESIGNER1, AF_FILE_SOUNDDESIGNER2, AF_FILE_AVR, AF_FILE_IFF_8SVX, AF_FILE_SAMPLEVISION, AF_FILE_VOC, AF_FILE_NIST_SPHERE, AF_FILE_SOUNDFONT2, AF_FILE_CAF }; int numFileFormats = sizeof (fileFormats) / sizeof (int); for (int i=0; i<numFileFormats; i++) { long implemented = afQueryLong(AF_QUERYTYPE_FILEFMT, AF_QUERY_IMPLEMENTED, fileFormats[i], 0, 0); const char *label = static_cast<const char *>(afQueryPointer(AF_QUERYTYPE_FILEFMT, AF_QUERY_LABEL, fileFormats[i], 0, 0)); if (implemented) EXPECT_TRUE(label); const char *name = static_cast<const char *>(afQueryPointer(AF_QUERYTYPE_FILEFMT, AF_QUERY_NAME, fileFormats[i], 0, 0)); if (implemented) EXPECT_TRUE(name); const char *description = static_cast<const char *>(afQueryPointer(AF_QUERYTYPE_FILEFMT, AF_QUERY_DESC, fileFormats[i], 0, 0)); if (implemented) EXPECT_TRUE(description); } }
//*************************************************************************** QList<Kwave::Compression::Type> Kwave::audiofileCompressionTypes() { QList<Kwave::Compression::Type> list; const long int numCompressionTypes = afQueryLong( AF_QUERYTYPE_COMPRESSION, AF_QUERY_ID_COUNT, 0, 0, 0); if (numCompressionTypes != 0) { int *compressions = static_cast<int *>(afQueryPointer( AF_QUERYTYPE_COMPRESSION, AF_QUERY_IDS, 0, 0, 0)); if (compressions) { for (long int index = 0; index < numCompressionTypes; index++) { Kwave::Compression::Type compression_type = Kwave::Compression::fromAudiofile(compressions[index]); if (!list.contains(compression_type)) list.append(compression_type); } free(compressions); } } return list; }