/** * Writes the header and data to a plain text file. * * @param hdr const reference to feature header * @param featureArray const reference to feature data array */ public override bool Write(FeatureHeader hdr, double[][] featureArray) { if (featureArray.Length == 0) { throw new Exception("Empty feature array!"); } TextWriter ofs = File.CreateText(m_filename); ofs.WriteLine("# Generated with: Aquila v. {0}", Dtw.VERSION); ofs.WriteLine("# Original wave file: {0}", hdr.wavFilename); ofs.WriteLine("# Audio sampling frequency: ?????"); ofs.WriteLine("# Frame length: {0}", hdr.frameLength); ofs.WriteLine("# Frames count: {0}", featureArray.Length); ofs.WriteLine("# Parameters type: {0}", hdr.type); ofs.WriteLine("# Parameters per frame: {0}", hdr.paramsPerFrame); ofs.WriteLine("# Save timestamp: {0}", hdr.timestamp); //ofs.precision(13); for (int i = 0, size = featureArray.Length; i < size; ++i) { ofs.WriteLine("#frame: {0}", i); for (int j = 0; j < hdr.paramsPerFrame; ++j) { ofs.WriteLine("{0}", featureArray[i][j]); } } ofs.Close(); return true; }
/** * Writes the header and data to a plain text file. * * @param hdr const reference to feature header * @param featureArray const reference to feature data array */ public override bool Write(FeatureHeader hdr, double[][] featureArray) { if (featureArray.Length == 0) { throw new Exception("Empty feature array!"); } TextWriter ofs = File.CreateText(m_filename); ofs.WriteLine("# Generated with: Aquila v. {0}", Dtw.VERSION); ofs.WriteLine("# Original wave file: {0}", hdr.wavFilename); ofs.WriteLine("# Audio sampling frequency: ?????"); ofs.WriteLine("# Frame length: {0}", hdr.frameLength); ofs.WriteLine("# Frames count: {0}", featureArray.Length); ofs.WriteLine("# Parameters type: {0}", hdr.type); ofs.WriteLine("# Parameters per frame: {0}", hdr.paramsPerFrame); ofs.WriteLine("# Save timestamp: {0}", hdr.timestamp); //ofs.precision(13); for (int i = 0, size = featureArray.Length; i < size; ++i) { ofs.WriteLine("#frame: {0}", i); for (int j = 0; j < hdr.paramsPerFrame; ++j) { ofs.WriteLine("{0}", featureArray[i][j]); } } ofs.Close(); return(true); }
/** * Saves calculated feature to a writer object (usually to file). * * @param writer non-const reference to a writer object */ public bool Save(FeatureWriter writer) { FeatureHeader hdr = new FeatureHeader(); hdr.type = type; hdr.frameLength = m_frameLength; hdr.paramsPerFrame = m_paramsPerFrame; hdr.wavFilename = wavFilename; hdr.timestamp = DateTime.Now; return(writer.Write(hdr, featureArray)); }
/** * Reads feature from a reader object. * * @param reader non-const reference to a reader object */ public bool Read(ref FeatureReader reader) { FeatureHeader hdr = new FeatureHeader(); //featureArray.Clear(); if (reader.Read(ref hdr, ref featureArray)) { type = hdr.type; m_frameLength = hdr.frameLength; m_paramsPerFrame = hdr.paramsPerFrame; wavFilename = hdr.wavFilename; timestamp = hdr.timestamp; return(true); } else { return(false); } }
/** * Creates an extractor object according to header information. * * This method is a wrapper for the main getExtractor method. * * @param hdr feature header * @return pointer to object of one of Extractor-derived classes */ public static Extractor GetExtractor(FeatureHeader hdr) { return(GetExtractor(hdr.type, hdr.frameLength, hdr.paramsPerFrame)); }
/** * Creates an extractor object according to header information. * * This method is a wrapper for the main getExtractor method. * * @param hdr feature header * @return pointer to object of one of Extractor-derived classes */ public static Extractor GetExtractor(FeatureHeader hdr) { return GetExtractor(hdr.type, hdr.frameLength, hdr.paramsPerFrame); }
/** * Reads feature from a reader object. * * @param reader non-const reference to a reader object */ public bool Read(ref FeatureReader reader) { FeatureHeader hdr = new FeatureHeader(); //featureArray.Clear(); if (reader.Read(ref hdr, ref featureArray)) { type = hdr.type; m_frameLength = hdr.frameLength; m_paramsPerFrame = hdr.paramsPerFrame; wavFilename = hdr.wavFilename; timestamp = hdr.timestamp; return true; } else { return false; } }
/** * Saves calculated feature to a writer object (usually to file). * * @param writer non-const reference to a writer object */ public bool Save(FeatureWriter writer) { FeatureHeader hdr = new FeatureHeader(); hdr.type = type; hdr.frameLength = m_frameLength; hdr.paramsPerFrame = m_paramsPerFrame; hdr.wavFilename = wavFilename; hdr.timestamp = DateTime.Now; return writer.Write(hdr, featureArray); }