int mus_sound_initialize(void) { static bool sndlib_initialized = false; if (!sndlib_initialized) { int err = MUS_NO_ERROR; sndlib_initialized = true; mus_error_handler = default_mus_error; err = mus_header_initialize(); if (err == MUS_NO_ERROR) err = mus_audio_initialize(); return(err); } return(MUS_NO_ERROR); }
/* Creates a new file and writes a header with the given characteristics. <type> is a sndlib constant for header type (e.g. MUS_AIFF). <format> is a sndlib constant for sound data format (e.g. snd_16_linear). (These constants are defined in sndlib.h.) Caller is responsible for checking that the header type and data format are compatible, and that the header type is one that sndlib can write (is WRITEABLE_HEADER_TYPE()). Writes no comment. NOTE: This will truncate an existing file with <sfname>, so check first! On success, returns a standard file descriptor, and leaves the file position pointer at the end of the header. On failure, returns -1. Caller can check errno then. */ int sndlib_create(char *sfname, /* file name */ int type, /* file type, e.g. AIFF */ int format, /* data format, e.g., MU-LAW */ int srate, /* sampling rate in Hz */ int chans, /* 1 for mono, 2 for stereo */ char *comment) { int fd, loc; assert(sfname != NULL && strlen(sfname) <= FILENAME_MAX); mus_header_initialize(); // make sure relevant parts of sndlib are initialized //resample-1.8: sndlib_write_header(fd, 0, type, format, srate, chans, comment, &loc) //resample-1.8: mus_file_open_descriptors(fd, format, mus_header_data_format_to_bytes_per_sample(),loc); // int mus_file_open_descriptors(int tfd, const char *arg, int df, int ds, off_t dl, int dc, int dt); fd = mus_sound_open_output(sfname, srate, chans, format, type, "created by resample"); return fd; }
int mus_sound_initialize(void) { static bool sndlib_initialized = false; if (!sndlib_initialized) { int err = MUS_NO_ERROR; sndlib_initialized = true; mus_error_handler = default_mus_error; err = mus_header_initialize(); if (err == MUS_NO_ERROR) err = mus_audio_initialize(); sound_tables = (sound_file ***)calloc(NUM_SOUND_TABLES, sizeof(sound_file **)); sound_table_sizes = (int *)calloc(NUM_SOUND_TABLES, sizeof(int)); return(err); } return(MUS_NO_ERROR); }