void afInitMarkComment(AFfilesetup setup, int trackid, int markid, const char *commstr) { int markno; int length; if (!_af_filesetup_ok(setup)) return; TrackSetup *track = setup->getTrack(trackid); if (!track) return; for (markno=0; markno<track->markerCount; markno++) { if (track->markers[markno].id == markid) break; } if (markno == track->markerCount) { _af_error(AF_BAD_MARKID, "no marker id %d for file setup", markid); return; } length = strlen(commstr); if (track->markers[markno].comment) free(track->markers[markno].comment); if ((track->markers[markno].comment = (char *) _af_malloc(length+1)) == NULL) return; strcpy(track->markers[markno].comment, commstr); }
void afInitMarkIDs(AFfilesetup setup, int trackid, const int *markids, int nmarks) { if (!_af_filesetup_ok(setup)) return; TrackSetup *track = setup->getTrack(trackid); if (!track) return; if (track->markers != NULL) { for (int i=0; i<track->markerCount; i++) { if (track->markers[i].name != NULL) free(track->markers[i].name); if (track->markers[i].comment != NULL) free(track->markers[i].comment); } free(track->markers); } track->markers = (MarkerSetup *) _af_calloc(nmarks, sizeof (struct MarkerSetup)); track->markerCount = nmarks; for (int i=0; i<nmarks; i++) { track->markers[i].id = markids[i]; track->markers[i].name = _af_strdup(""); track->markers[i].comment = _af_strdup(""); } track->markersSet = true; }
void afInitLoopIDs (AFfilesetup setup, int instid, int *loopids, int nloops) { int instno; if (!_af_filesetup_ok(setup)) return; if (!_af_unique_ids(loopids, nloops, "loop", AF_BAD_LOOPID)) return; if ((instno = _af_setup_instrument_index_from_id(setup, instid)) == -1) return; _af_setup_free_loops(setup, instno); setup->instruments[instno].loopCount = nloops; setup->instruments[instno].loopSet = true; if (nloops == 0) setup->instruments[instno].loops = NULL; else { int i; if ((setup->instruments[instno].loops = _af_calloc(nloops, sizeof (_LoopSetup))) == NULL) return; for (i=0; i < nloops; i++) setup->instruments[instno].loops[i].id = loopids[i]; } }
void afInitAESChannelDataTo (AFfilesetup setup, int trackid, int willBeData) { _TrackSetup *track; if (!_af_filesetup_ok(setup)) return; if ((track = _af_filesetup_get_tracksetup(setup, trackid)) == NULL) return; track->aesDataSet = willBeData; }
void afInitAESChannelData (AFfilesetup setup, int trackid) { _TrackSetup *track; if (!_af_filesetup_ok(setup)) return; if ((track = _af_filesetup_get_tracksetup(setup, trackid)) == NULL) return; track->aesDataSet = AF_TRUE; }
void afInitSampleFormat (AFfilesetup setup, int trackid, int sampfmt, int sampwidth) { if (!_af_filesetup_ok(setup)) return; TrackSetup *track = setup->getTrack(trackid); if (!track) return; _af_set_sample_format(&track->f, sampfmt, sampwidth); track->sampleFormatSet = true; track->sampleWidthSet = true; }
void afInitCompression (AFfilesetup setup, int trackid, int compression) { _TrackSetup *track; if (!_af_filesetup_ok(setup)) return; if ((track = _af_filesetup_get_tracksetup(setup, trackid)) == NULL) return; if (findCompression(compression) == NULL) return; track->f.compressionType = compression; }
/* Initialize the PCM mapping for a given track. */ void afInitPCMMapping (AFfilesetup setup, int trackid, double slope, double intercept, double minClip, double maxClip) { _TrackSetup *track; if (!_af_filesetup_ok(setup)) return; if ((track = _af_filesetup_get_tracksetup(setup, trackid)) == NULL) return; track->f.pcm.slope = slope; track->f.pcm.intercept = intercept; track->f.pcm.minClip = minClip; track->f.pcm.maxClip = maxClip; }
/* Initialize instrument id list for audio file. */ void afInitInstIDs (AFfilesetup setup, const int *instids, int ninsts) { if (!_af_filesetup_ok(setup)) return; if (!_af_unique_ids(instids, ninsts, "instrument", AF_BAD_INSTID)) return; _af_setup_free_instruments(setup); setup->instrumentCount = ninsts; setup->instrumentSet = true; setup->instruments = _af_instsetup_new(setup->instrumentCount); for (int i=0; i < setup->instrumentCount; i++) setup->instruments[i].id = instids[i]; }
void afInitRate (AFfilesetup setup, int trackid, double rate) { if (!_af_filesetup_ok(setup)) return; TrackSetup *track = setup->getTrack(trackid); if (!track) return; if (rate <= 0.0) { _af_error(AF_BAD_RATE, "invalid sample rate %.30g", rate); return; } track->f.sampleRate = rate; track->rateSet = true; }
void afInitMarkName(AFfilesetup setup, int trackid, int markid, const char *namestr) { int markno; int length; if (!_af_filesetup_ok(setup)) return; TrackSetup *track = setup->getTrack(trackid); if (!track) return; for (markno=0; markno<track->markerCount; markno++) { if (track->markers[markno].id == markid) break; } if (markno == track->markerCount) { _af_error(AF_BAD_MARKID, "no marker id %d for file setup", markid); return; } length = strlen(namestr); if (length > 255) { _af_error(AF_BAD_STRLEN, "warning: marker name truncated to 255 characters"); length = 255; } if (track->markers[markno].name) free(track->markers[markno].name); if ((track->markers[markno].name = (char *) _af_malloc(length+1)) == NULL) return; strncpy(track->markers[markno].name, namestr, length); /* The null terminator is not set by strncpy if strlen(namestr) > length. Set it here. */ track->markers[markno].name[length] = '\0'; }
/* track data: data offset within the file (initialized for raw reading only) */ void afInitDataOffset (AFfilesetup setup, int trackid, AFfileoffset offset) { if (!_af_filesetup_ok(setup)) return; TrackSetup *track = setup->getTrack(trackid); if (!track) return; if (offset < 0) { #ifdef __WXOSX__ _af_error(AF_BAD_DATAOFFSET, "invalid data offset %jd", #else _af_error(AF_BAD_DATAOFFSET, "invalid data offset %"PRId64, #endif static_cast<intmax_t>(offset)); return; }
void afInitByteOrder (AFfilesetup setup, int trackid, int byteorder) { if (!_af_filesetup_ok(setup)) return; TrackSetup *track = setup->getTrack(trackid); if (!track) return; if (byteorder != AF_BYTEORDER_BIGENDIAN && byteorder != AF_BYTEORDER_LITTLEENDIAN) { _af_error(AF_BAD_BYTEORDER, "invalid byte order %d", byteorder); return; } track->f.byteOrder = byteorder; track->byteOrderSet = true; }
void afInitChannels (AFfilesetup setup, int trackid, int channels) { if (!_af_filesetup_ok(setup)) return; TrackSetup *track = setup->getTrack(trackid); if (!track) return; if (channels < 1) { _af_error(AF_BAD_CHANNELS, "invalid number of channels %d", channels); return; } track->f.channelCount = channels; track->channelCountSet = true; }
void afFreeFileSetup (AFfilesetup setup) { if (!_af_filesetup_ok(setup)) return; _af_setup_free_tracks(setup); _af_setup_free_instruments(setup); if (setup->miscellaneousCount) { free(setup->miscellaneous); setup->miscellaneous = NULL; setup->miscellaneousCount = 0; } memset(setup, 0, sizeof (_AFfilesetup)); free(setup); }
void afInitFileFormat (AFfilesetup setup, int filefmt) { if (!_af_filesetup_ok(setup)) return; if (filefmt < 0 || filefmt >= _AF_NUM_UNITS) { _af_error(AF_BAD_FILEFMT, "unrecognized file format %d", filefmt); return; } if (!_af_units[filefmt].implemented) { _af_error(AF_BAD_NOT_IMPLEMENTED, "%s format not currently supported", _af_units[filefmt].name); return; } setup->fileFormat = filefmt; }