java.lang.Object
org.refcodes.audio.AbstractCsvSampleWriter<SoundSample,CsvSoundSampleWriter>
org.refcodes.audio.CsvSoundSampleWriter
- All Implemented Interfaces:
AutoCloseable
,CsvSampleWriter<SoundSample,
,CsvSoundSampleWriter> SampleWriter<SoundSample,
,CsvSoundSampleWriter> SamplingRateAccessor
,SamplingRateAccessor.SamplingRateBuilder<CsvSoundSampleWriter>
,SamplingRateAccessor.SamplingRateMutator
,SamplingRateAccessor.SamplingRateProperty
,SoundSampleWriter<CsvSoundSampleWriter>
,org.refcodes.io.RowWriter<SoundSample>
public class CsvSoundSampleWriter
extends AbstractCsvSampleWriter<SoundSample,CsvSoundSampleWriter>
implements SoundSampleWriter<CsvSoundSampleWriter>
The
CsvSoundSampleWriter
provides means to write sound samples to a
CSV file.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.audio.SamplingRateAccessor
SamplingRateAccessor.SamplingRateBuilder<B extends SamplingRateAccessor.SamplingRateBuilder<B>>, SamplingRateAccessor.SamplingRateMutator, SamplingRateAccessor.SamplingRateProperty
-
Field Summary
Fields inherited from class org.refcodes.audio.AbstractCsvSampleWriter
_csvWriter, _deltaMode
-
Constructor Summary
ConstructorDescriptionCsvSoundSampleWriter
(File aFile) Constructs theCsvSoundSampleWriter
for writing sound samples to a CSV file or stream.CsvSoundSampleWriter
(File aFile, CsvDeltaMode aDeltaMode) Constructs theCsvSoundSampleWriter
for writing sound samples to a CSV file or stream.CsvSoundSampleWriter
(OutputStream aOutputStream) Constructs theCsvSoundSampleWriter
for writing sound samples to a CSV file or stream.CsvSoundSampleWriter
(OutputStream aOutputStream, CsvDeltaMode aDeltaMode) Constructs theCsvSoundSampleWriter
for writing sound samples to a CSV file or stream.CsvSoundSampleWriter
(PrintStream aPrintStream) Constructs theCsvSoundSampleWriter
for writing sound samples to a CSV file or stream.CsvSoundSampleWriter
(PrintStream aPrintStream, CsvDeltaMode aDeltaMode) Constructs theCsvSoundSampleWriter
for writing sound samples to a CSV file or stream. -
Method Summary
Modifier and TypeMethodDescriptionint
Retrieves the sampling rate from the sampling rate property.void
setSamplingRate
(int aSamplingRate) Sets the sampling rate for the sampling rate property.withSamplingRate
(int aSamplingRate) Sets the sampling rate for the sampling rate property.void
writeNext
(double... aSampleData) Writes the next samples, one sample for each channel.void
writeNext
(SoundSample aSample) Writes the next samples, one sample for each channel.Methods inherited from class org.refcodes.audio.AbstractCsvSampleWriter
close, format, toDouble, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.refcodes.audio.SampleWriter
close
Methods inherited from interface org.refcodes.audio.SamplingRateAccessor.SamplingRateProperty
letSamplingRate
-
Constructor Details
-
CsvSoundSampleWriter
Constructs theCsvSoundSampleWriter
for writing sound samples to a CSV file or stream.- Parameters:
aFile
- TheFile
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.
-
CsvSoundSampleWriter
Constructs theCsvSoundSampleWriter
for writing sound samples to a CSV file or stream.- Parameters:
aOutputStream
- TheOutputStream
where to write the CSV records to.
-
CsvSoundSampleWriter
Constructs theCsvSoundSampleWriter
for writing sound samples to a CSV file or stream.- Parameters:
aPrintStream
- ThePrintStream
where to write the CSV records to.
-
CsvSoundSampleWriter
Constructs theCsvSoundSampleWriter
for writing sound samples to a CSV file or stream.- Parameters:
aFile
- TheFile
where to write the CSV records to.aDeltaMode
- TheCsvDeltaMode
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.
-
CsvSoundSampleWriter
Constructs theCsvSoundSampleWriter
for writing sound samples to a CSV file or stream.- Parameters:
aOutputStream
- TheOutputStream
where to write the CSV records to.aDeltaMode
- TheCsvDeltaMode
to use when writing the CSV rows.
-
CsvSoundSampleWriter
Constructs theCsvSoundSampleWriter
for writing sound samples to a CSV file or stream.- Parameters:
aPrintStream
- ThePrintStream
where to write the CSV records to.aDeltaMode
- TheCsvDeltaMode
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 interfaceSoundSampleWriter<CsvSoundSampleWriter>
- Parameters:
aSampleData
- The samples, one for each channel.
-
writeNext
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 interfaceorg.refcodes.io.RowWriter<SoundSample>
- Specified by:
writeNext
in interfaceSampleWriter<SoundSample,
CsvSoundSampleWriter> - Specified by:
writeNext
in interfaceSoundSampleWriter<CsvSoundSampleWriter>
- 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 interfaceSamplingRateAccessor
- 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 interfaceSamplingRateAccessor.SamplingRateMutator
- Parameters:
aSamplingRate
- The sampling rate to be stored by the sampling rate property.
-
withSamplingRate
Sets the sampling rate for the sampling rate property.- Specified by:
withSamplingRate
in interfaceSamplingRateAccessor.SamplingRateBuilder<CsvSoundSampleWriter>
- Parameters:
aSamplingRate
- The sampling rate to be stored by the sampling rate property.- Returns:
- The builder for applying multiple build operations.
-