📄 audiofile.h
字号:
// static void* operator new(size_t size) { return mgr_d.get(); } // method: operator new[] // static void* operator new[](size_t size) { return mgr_d.getBlock(size); } // method: operator delete // static void operator delete(void* ptr) { mgr_d.release(ptr); } // method: operator delete[] // static void operator delete[](void* ptr) { mgr_d.releaseBlock(ptr); } // method: setGrowSize // static boolean setGrowSize(long grow_size) { return mgr_d.setGrow(grow_size); } boolean clear(Integral::CMODE cmode = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods // //--------------------------------------------------------------------------- // constructor(s) // AudioFile(FILE_TYPE file_type, FILE_FORMAT file_format, double sample_frequency, long sample_num_bytes, long num_channels); // open and close methods: // these also handle clearing the internal data // boolean open(const Filename& filename, MODE mode = READ_ONLY); boolean open(const unichar* filename, MODE mode = READ_ONLY); boolean close(); // method: getData // long getData(Vector<VectorFloat>& data, double start_time = DEF_START_TIME, double duration = DEF_DURATION) { return getData(data, timeToSample(start_time), timeToSample(duration)); } // method: getData // long getData(VectorFloat& data, long channel_tag, double start_time = DEF_START_TIME, double duration = DEF_DURATION) { return getData(data, channel_tag, timeToSample(start_time), timeToSample(duration)); } // other getData methods // long getData(Vector<VectorFloat>& data, long start_samp, long num_samp); long getData(VectorFloat& data, long channel_tag, long start_samp, long num_samp); // method: getWindow // long getWindow(Vector<VectorFloat>& data, double center_time, double duration = DEF_DURATION) { double start_time = center_time - duration / 2.0; return getData(data, timeToSample(start_time), timeToSample(duration)); } // method: getWindow // long getWindow(VectorFloat& data, long channel_tag, double center_time, double duration = DEF_DURATION) { double start_time = center_time - duration / 2.0; return getData(data, channel_tag, timeToSample(start_time), timeToSample(duration)); } // method: getRange // long getRange(Vector<VectorFloat>& data, double start_time, double end_time) { double duration = end_time - start_time; return getData(data, timeToSample(start_time), timeToSample(duration) + 1); } // method: getRange // long getRange(VectorFloat& data, long channel_tag, double start_time, double end_time) { double duration = end_time - start_time; return getData(data, channel_tag, timeToSample(start_time), timeToSample(duration) + 1); } // this is currently the only way to output data. it writes the // entirety of the input vector at the current location. // long writeAudioData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG); // audio file format i/o methods: // read data of certain duration from the audio file, in the default case, // read the whole file // long readAudioData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG, long start_samp = DEF_START_SAMP, long num_samp = DEF_NUM_SAMP); // method: setFileType // boolean setFileType(FILE_TYPE file_type) { file_type_d = file_type; return true; } // method: setFileFormat // boolean setFileFormat(FILE_FORMAT file_format) { file_format_d = file_format; return true; } // method: setCompType // boolean setCompType(COMP_TYPE comp_type) { if (comp_type != LINEAR) { return Error::handle(name(), L"setCompType", Error::NOT_IMPLEM, __FILE__, __LINE__); } compression_type_d = comp_type; return true; } // method: setAmplitudeRange // boolean setAmplitudeRange(double amplitude_range) { amplitude_range_d = amplitude_range; return true; } // method: setSampleFrequency // boolean setSampleFrequency(double sample_freq) { if (sample_freq < 0) { return Error::handle(name(), L"setSampleFrequency", Error::ARG, __FILE__, __LINE__); } sample_freq_d = sample_freq; return true; } boolean setSampleNumBytes(long sample_num_bytes); boolean setSamplePrecision(SAMPLE_PRECISION sample_precision); boolean setNumChannels(long num_channels); boolean setBufferSize(long nblocks); boolean setBlockSize(long nbytes); // filter parameter set methods // boolean setMaCoeff(const VectorFloat& ma_coeff); boolean setArCoeff(const VectorFloat& ar_coeff); // get methods // // method: getFileType // FILE_TYPE getFileType() const { return file_type_d; } // method: getFileFormat // FILE_FORMAT getFileFormat() const { return file_format_d; } // method: getCompType // COMP_TYPE getCompType() const { return compression_type_d; } // method: getAmplitudeRange // double getAmplitudeRange() const { return amplitude_range_d; } // method: getSampleFrequency // double getSampleFrequency() const { return sample_freq_d; } // method: getSampleNumBytes // long getSampleNumBytes() const { return sample_num_bytes_d; } // method: getNumChannels // long getNumChannels() const { return num_channels_d; } // method: getSamplePrecision // SAMPLE_PRECISION getSamplePrecision() const { return sample_precision_d; } boolean isOpen() const; // method: getMaCoeff // const VectorFloat& getMaCoeff() const { return ma_coeff_d; } // method: getArCoeff // const VectorFloat& getArCoeff() const { return ar_coeff_d; } long getNumSamples() const; // method: timeToSample // long timeToSample(double time) const { return (long)Integral::round(time * sample_freq_d); } // method: sampleToTime // double sampleToTime(long index) const { return (double)index / sample_freq_d; } // method: getID // const String& getID() const { return id_d; } // method: setID // boolean setID(const String& id) { return id_d.assign(id); } //--------------------------------------------------------------------------- // // private methods // //---------------------------------------------------------------------------private: // methods to get the starting and ending time points of the // internal buffer // // method: getStartSamp // long getStartSamp(long ctag = DEF_CHANNEL_TAG) const { long buf_duration = buffers_d(ctag).getNumElements(); long buf_end = buf_end_samp_d(ctag); // calculate and return the start time // return (buf_end - buf_duration); } // method: getEndSamp // long getEndSamp(long ctag = DEF_CHANNEL_TAG) const { return buf_end_samp_d(ctag); } // methods to read the next block of data // boolean appendData(); // methods to get data from audio file // long readRawData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG, long start_samp = DEF_START_SAMP, long num_samp = DEF_NUM_SAMP); long readSofData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG, long start_samp = DEF_START_SAMP, long num_samp = DEF_NUM_SAMP); long readWavData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG, long start_samp = DEF_START_SAMP, long num_samp = DEF_NUM_SAMP); long readSphereData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG, long start_samp = DEF_START_SAMP, long num_samp = DEF_NUM_SAMP); // methods to write data to audio file // long writeRawData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG); long writeWavData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG); long writeSphereData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG); long writeSofData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG); // methods to convert the Vector<VectorFloat> to bytes for writing // boolean revertData(VectorLong& whole_data, Vector<VectorFloat>& data, long channel_tag) const; // methods to round the sample number up or down by block boundaries // long blockFloor(long samp_num) const; long blockCeil(long samp_num) const; // methods to clear out buffer and pointers // boolean resetBuffer(long channel_tag = CHANNEL_TAG_ALL); boolean resetFilter(long channel_tag = CHANNEL_TAG_ALL); // methods to start the read or write in an Sof file // boolean readSofStart(); boolean writeSofStart();};// end of include file//#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -