Class CsvMonoSampleWriter

All Implemented Interfaces:
AutoCloseable, CsvSampleWriter<MonoSample,CsvMonoSampleWriter>, MonoSampleWriter<CsvMonoSampleWriter>, SampleWriter<MonoSample,CsvMonoSampleWriter>, SamplingRateAccessor, SamplingRateAccessor.SamplingRateBuilder<CsvMonoSampleWriter>, SamplingRateAccessor.SamplingRateMutator, SamplingRateAccessor.SamplingRateProperty, org.refcodes.io.RowWriter<MonoSample>

public class CsvMonoSampleWriter extends AbstractCsvSampleWriter<MonoSample,CsvMonoSampleWriter> implements MonoSampleWriter<CsvMonoSampleWriter>
The CsvMonoSampleWriter provides means to write sound samples to a CSV file.
  • Constructor Details

    • CsvMonoSampleWriter

      public CsvMonoSampleWriter(File aFile) throws FileNotFoundException
      Constructs the CsvMonoSampleWriter for writing sound samples to a CSV file or stream.
      Parameters:
      aFile - The File where to write the CSV records to.
      Throws:
      FileNotFoundException - If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file.
    • CsvMonoSampleWriter

      public CsvMonoSampleWriter(OutputStream aOutputStream)
      Constructs the CsvMonoSampleWriter for writing sound samples to a CSV file or stream.
      Parameters:
      aOutputStream - The OutputStream where to write the CSV records to.
    • CsvMonoSampleWriter

      public CsvMonoSampleWriter(PrintStream aPrintStream)
      Constructs the CsvMonoSampleWriter for writing sound samples to a CSV file or stream.
      Parameters:
      aPrintStream - The PrintStream where to write the CSV records to.
    • CsvMonoSampleWriter

      public CsvMonoSampleWriter(File aFile, CsvDeltaMode aDeltaMode) throws FileNotFoundException
      Constructs the CsvMonoSampleWriter for writing sound samples to a CSV file or stream.
      Parameters:
      aFile - The File where to write the CSV records to.
      aDeltaMode - The CsvDeltaMode to use when writing the CSV rows.
      Throws:
      FileNotFoundException - If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file.
    • CsvMonoSampleWriter

      public CsvMonoSampleWriter(OutputStream aOutputStream, CsvDeltaMode aDeltaMode)
      Constructs the CsvMonoSampleWriter for writing sound samples to a CSV file or stream.
      Parameters:
      aOutputStream - The OutputStream where to write the CSV records to.
      aDeltaMode - The CsvDeltaMode to use when writing the CSV rows.
    • CsvMonoSampleWriter

      public CsvMonoSampleWriter(PrintStream aPrintStream, CsvDeltaMode aDeltaMode)
      Constructs the CsvMonoSampleWriter for writing sound samples to a CSV file or stream.
      Parameters:
      aPrintStream - The PrintStream where to write the CSV records to.
      aDeltaMode - The CsvDeltaMode to use when writing the CSV rows.
  • Method Details

    • writeNext

      public void writeNext(double aSampleData)
      Writes the next samples, one sample for each channel. Provide one sample for mono audio, two samples for stereo audio and so on. In case you provide more or less samples than channels being supported by the writer, then it is up to the writer whether to duplicate the samples or calculate an average or the like.
      Specified by:
      writeNext in interface MonoSampleWriter<CsvMonoSampleWriter>
      Parameters:
      aSampleData - The samples, one for each channel.
    • writeNext

      public void writeNext(MonoSample aSample)
      Writes the next samples, one sample for each channel. Provide one sample for mono audio, two samples for stereo audio and so on. In case you provide more or less samples than channels being supported by the writer, then it is up to the writer whether to duplicate the samples or calculate an average or the like.
      Specified by:
      writeNext in interface org.refcodes.io.RowWriter<MonoSample>
      Specified by:
      writeNext in interface SampleWriter<MonoSample,CsvMonoSampleWriter>
      Parameters:
      aSample - The samples, one for each channel.
    • getSamplingRate

      public int getSamplingRate()
      Retrieves the sampling rate from the sampling rate property.
      Specified by:
      getSamplingRate in interface SamplingRateAccessor
      Returns:
      The sampling rate stored by the sampling rate property.
    • setSamplingRate

      public void setSamplingRate(int aSamplingRate)
      Sets the sampling rate for the sampling rate property.
      Specified by:
      setSamplingRate in interface SamplingRateAccessor.SamplingRateMutator
      Parameters:
      aSamplingRate - The sampling rate to be stored by the sampling rate property.
    • withSamplingRate

      public CsvMonoSampleWriter withSamplingRate(int aSamplingRate)
      Sets the sampling rate for the sampling rate property.
      Specified by:
      withSamplingRate in interface SamplingRateAccessor.SamplingRateBuilder<CsvMonoSampleWriter>
      Parameters:
      aSamplingRate - The sampling rate to be stored by the sampling rate property.
      Returns:
      The builder for applying multiple build operations.