static Xen g_mus_sound_maxamp_exists(Xen file) { #define H_mus_sound_maxamp_exists "(" S_mus_sound_maxamp_exists " filename): " PROC_TRUE " if sound's maxamp data is available \ in the sound cache; if it isn't, a call on " S_mus_sound_maxamp " has to open and read the data to get the maxamp." bool val; char *str = NULL; Xen_check_type(Xen_is_string(file), file, 1, S_mus_sound_maxamp_exists, "a string"); val = mus_sound_maxamp_exists(str = mus_expand_filename(Xen_string_to_C_string(file))); if (str) free(str); return(C_bool_to_Xen_boolean(val)); }
int main(int argc, char *argv[]) { int chans, srate, ctr; mus_sample_t samp_type; mus_header_t type; mus_long_t samples; float length = 0.0; time_t date; int *loops = NULL; char *comment, *header_name; char *samp_type_info = NULL, *samp_type_name, *ampstr = NULL; char timestr[64]; if (argc == 1) {printf("usage: sndinfo file\n"); exit(0);} mus_sound_initialize(); for (ctr = 1; ctr < argc; ctr++) { if (mus_file_probe(argv[ctr])) /* see if it exists */ { date = mus_sound_write_date(argv[ctr]); srate = mus_sound_srate(argv[ctr]); if (srate == MUS_ERROR) { fprintf(stdout, "%s: not a sound file?\n", argv[ctr]); continue; } chans = mus_sound_chans(argv[ctr]); samples = mus_sound_samples(argv[ctr]); comment = mus_sound_comment(argv[ctr]); if ((chans > 0) && (srate > 0)) length = (float)((double)samples / (double)(chans * srate)); loops = mus_sound_loop_info(argv[ctr]); type = mus_sound_header_type(argv[ctr]); header_name = (char *)mus_header_type_name(type); samp_type = mus_sound_sample_type(argv[ctr]); if (samp_type != MUS_UNKNOWN_SAMPLE) samp_type_info = (char *)mus_sample_type_name(samp_type); else { int orig_type; if (samp_type_info == NULL) samp_type_info = (char *)calloc(64, sizeof(char)); orig_type = mus_sound_original_sample_type(argv[ctr]); samp_type_name = (char *)mus_header_original_sample_type_name(orig_type, type); if (samp_type_name) snprintf(samp_type_info, 64, "%d (%s)", orig_type, samp_type_name); else snprintf(samp_type_info, 64, "%d", orig_type); } fprintf(stdout, "%s:\n srate: %d\n chans: %d\n length: %f", argv[ctr], srate, chans, length); if (length < 10.0) { int samps; samps = mus_sound_framples(argv[ctr]); fprintf(stdout, " (%d sample%s)", samps, (samps != 1) ? "s" : ""); } fprintf(stdout, "\n"); fprintf(stdout, " header type: %s\n sample type: %s\n ", header_name, samp_type_info); strftime(timestr, 64, "%a %d-%b-%Y %H:%M %Z", localtime(&date)); fprintf(stdout, "written: %s", timestr); if ((chans > 0) && (mus_sound_maxamp_exists(argv[ctr]))) { ampstr = display_maxamps(argv[ctr], chans); if (ampstr) fprintf(stdout, "%s", ampstr); } fprintf(stdout, "\n"); if (comment) fprintf(stdout, " comment: %s\n", comment); if (loops) { fprintf(stdout, " loop: %d to %d\n", loops[0], loops[1]); if (loops[2] != 0) fprintf(stdout, " loop: %d to %d\n", loops[2], loops[3]); if (loops[0] != 0) fprintf(stdout, " base: %d, detune: %d\n", loops[4], loops[5]); } } else fprintf(stderr, "%s: %s\n", argv[ctr], strerror(errno)); if (ctr < argc - 1) fprintf(stdout, "\n"); } return(0); }