void afSetMarkPosition (AFfilehandle file, int trackid, int markid, AFframecount position) { if (!_af_filehandle_ok(file)) return; if (!file->checkCanWrite()) return; Track *track = file->getTrack(trackid); if (!track) return; Marker *marker = track->getMarker(markid); if (!marker) return; if (position < 0) { #ifdef __WXOSX__ _af_error(AF_BAD_MARKPOS, "invalid marker position %jd", #else _af_error(AF_BAD_MARKPOS, "invalid marker position %"PRId64, #endif static_cast<intmax_t>(position)); position = 0; }
/* This routine checks and sets instrument parameters. npv is number of valid AUpvlist pairs. */ void _af_instparam_set (AFfilehandle file, int instid, AUpvlist pvlist, int npv) { if (!_af_filehandle_ok(file)) return; if (!file->checkCanWrite()) return; Instrument *instrument = file->getInstrument(instid); if (!instrument) return; if (AUpvgetmaxitems(pvlist) < npv) npv = AUpvgetmaxitems(pvlist); for (int i=0; i < npv; i++) { int param; AUpvgetparam(pvlist, i, ¶m); int j; if ((j = _af_instparam_index_from_id(file->m_fileFormat, param)) == -1) /* no parameter with that id; ignore */ continue; if (!file->isInstrumentParameterValid(pvlist, i)) /* bad parameter value; ignore */ continue; int type = _af_units[file->m_fileFormat].instrumentParameters[j].type; switch (type) { case AU_PVTYPE_LONG: AUpvgetval(pvlist, i, &instrument->values[j].l); break; case AU_PVTYPE_DOUBLE: AUpvgetval(pvlist, i, &instrument->values[j].d); break; case AU_PVTYPE_PTR: AUpvgetval(pvlist, i, &instrument->values[j].v); break; default: return; } } }
void afSetChannelMatrix (AFfilehandle file, int trackid, double* matrix) { if (!_af_filehandle_ok(file)) return; Track *track = file->getTrack(trackid); if (!track) return; if (track->channelMatrix != NULL) free(track->channelMatrix); track->channelMatrix = NULL; if (matrix != NULL) { int i, size; size = track->v.channelCount * track->f.channelCount; track->channelMatrix = (double *) malloc(size * sizeof (double)); for (i = 0; i < size; i++) track->channelMatrix[i] = matrix[i]; } }
AFframecount afSeekFrame (AFfilehandle file, int trackid, AFframecount frame) { if (!_af_filehandle_ok(file)) return -1; if (!file->checkCanRead()) return -1; Track *track = file->getTrack(trackid); if (!track) return -1; if (track->ms->isDirty() && track->ms->setup(file, track) == AF_FAIL) return -1; if (frame < 0) return track->nextvframe; /* Optimize the case of seeking to the current position. */ if (frame == track->nextvframe) return track->nextvframe; /* Limit request to the number of frames in the file. */ if (track->totalvframes != -1) if (frame > track->totalvframes) frame = track->totalvframes - 1; /* Now that the modules are not dirty and frame represents a valid virtual frame, we call _AFsetupmodules again after setting track->nextvframe. _AFsetupmodules will look at track->nextvframe and compute track->nextfframe in clever and mysterious ways. */ track->nextvframe = frame; if (track->ms->setup(file, track) == AF_FAIL) return -1; return track->nextvframe; }
/* XXXmpruett fix the version */ int afGetFileFormat (AFfilehandle file, int *version) { if (!_af_filehandle_ok(file)) return -1; if (version != NULL) *version = file->getVersion(); return file->m_fileFormat; }
/* This routine gets instrument parameters. npv is number of valid AUpvlist pairs */ void _af_instparam_get (AFfilehandle file, int instid, AUpvlist pvlist, int npv, bool forceLong) { if (!_af_filehandle_ok(file)) return; Instrument *instrument = file->getInstrument(instid); if (!instrument) return; if (AUpvgetmaxitems(pvlist) < npv) npv = AUpvgetmaxitems(pvlist); for (int i=0; i < npv; i++) { int param; AUpvgetparam(pvlist, i, ¶m); int j; if ((j = _af_instparam_index_from_id(file->m_fileFormat, param)) == -1) /* no parameter with that id; ignore */ continue; int type = _af_units[file->m_fileFormat].instrumentParameters[j].type; /* forceLong is true when this routine called by afGetInstParamLong(). */ if (forceLong && type != AU_PVTYPE_LONG) { _af_error(AF_BAD_INSTPTYPE, "type of instrument parameter %d is not AU_PVTYPE_LONG", param); continue; } AUpvsetvaltype(pvlist, i, type); switch (type) { case AU_PVTYPE_LONG: AUpvsetval(pvlist, i, &instrument->values[j].l); break; case AU_PVTYPE_DOUBLE: AUpvsetval(pvlist, i, &instrument->values[j].d); break; case AU_PVTYPE_PTR: AUpvsetval(pvlist, i, &instrument->values[j].v); break; default: _af_error(AF_BAD_INSTPTYPE, "invalid instrument parameter type %d", type); return; } } }
int afGetVirtualByteOrder (AFfilehandle file, int trackid) { if (!_af_filehandle_ok(file)) return -1; Track *track = file->getTrack(trackid); if (!track) return -1; return track->v.byteOrder; }
float afGetVirtualFrameSize (AFfilehandle file, int trackid, int stretch3to4) { if (!_af_filehandle_ok(file)) return -1; Track *track = file->getTrack(trackid); if (!track) return -1; return _af_format_frame_size(&track->v, stretch3to4); }
AFfileoffset afGetTrackBytes (AFfilehandle file, int trackid) { if (!_af_filehandle_ok(file)) return -1; Track *track = file->getTrack(trackid); if (!track) return -1; return track->data_size; }
AFfileoffset afGetDataOffset (AFfilehandle file, int trackid) { if (!_af_filehandle_ok(file)) return -1; Track *track = file->getTrack(trackid); if (!track) return -1; return track->fpos_first_frame; }
int afGetVirtualChannels (AFfilehandle file, int trackid) { if (!_af_filehandle_ok(file)) return -1; Track *track = file->getTrack(trackid); if (!track) return -1; return track->v.channelCount; }
double afGetVirtualRate (AFfilehandle file, int trackid) { if (!_af_filehandle_ok(file)) return -1; Track *track = file->getTrack(trackid); if (!track) return -1; return track->v.sampleRate; }
AFframecount afGetFrameCount (AFfilehandle file, int trackid) { if (!_af_filehandle_ok(file)) return -1; Track *track = file->getTrack(trackid); if (!track) return -1; if (track->ms->isDirty() && track->ms->setup(file, track) == AF_FAIL) return -1; return track->totalvframes; }
void afGetVirtualSampleFormat (AFfilehandle file, int trackid, int *sampleFormat, int *sampleWidth) { if (!_af_filehandle_ok(file)) return; Track *track = file->getTrack(trackid); if (!track) return; if (sampleFormat) *sampleFormat = track->v.sampleFormat; if (sampleWidth) *sampleWidth = track->v.sampleWidth; }
int afSetVirtualSampleFormat (AFfilehandle file, int trackid, int sampleFormat, int sampleWidth) { if (!_af_filehandle_ok(file)) return -1; Track *track = file->getTrack(trackid); if (!track) return -1; if (_af_set_sample_format(&track->v, sampleFormat, sampleWidth) == AF_FAIL) return -1; track->ms->setDirty(); return 0; }
int afSetVirtualChannels (AFfilehandle file, int trackid, int channelCount) { if (!_af_filehandle_ok(file)) return -1; Track *track = file->getTrack(trackid); if (!track) return -1; track->v.channelCount = channelCount; track->ms->setDirty(); if (track->channelMatrix) free(track->channelMatrix); track->channelMatrix = NULL; return 0; }
int afSetVirtualRate (AFfilehandle file, int trackid, double rate) { if (!_af_filehandle_ok(file)) return -1; Track *track = file->getTrack(trackid); if (!track) return -1; if (rate < 0) { _af_error(AF_BAD_RATE, "invalid sampling rate %.30g", rate); return -1; } track->v.sampleRate = rate; track->ms->setDirty(); return 0; }
int afSetVirtualByteOrder (AFfilehandle file, int trackid, int byteorder) { if (!_af_filehandle_ok(file)) return AF_FAIL; Track *track = file->getTrack(trackid); if (!track) return AF_FAIL; if (byteorder != AF_BYTEORDER_BIGENDIAN && byteorder != AF_BYTEORDER_LITTLEENDIAN) { _af_error(AF_BAD_BYTEORDER, "invalid byte order %d", byteorder); return AF_FAIL; } track->v.byteOrder = byteorder; track->ms->setDirty(); return AF_SUCCEED; }