Package org.refcodes.audio
Class SvgMonoSampleWriter
- java.lang.Object
-
- org.refcodes.audio.AbstractSvgSampleWriter<MonoSample,SvgMonoSampleWriter>
-
- org.refcodes.audio.SvgMonoSampleWriter
-
- All Implemented Interfaces:
AutoCloseable
,MonoSampleWriter<SvgMonoSampleWriter>
,SampleWriter<MonoSample,B>
,SamplingRateAccessor
,SamplingRateAccessor.SamplingRateBuilder<SvgMonoSampleWriter>
,SamplingRateAccessor.SamplingRateMutator
,SamplingRateAccessor.SamplingRateProperty
,org.refcodes.io.RowWriter<SvgMonoSampleWriter>
public class SvgMonoSampleWriter extends AbstractSvgSampleWriter<MonoSample,SvgMonoSampleWriter> implements MonoSampleWriter<SvgMonoSampleWriter>
TheSvgMonoSampleWriter
provides means to write sound samples to a SVG 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.AbstractSvgSampleWriter
_printStream
-
-
Constructor Summary
Constructors Constructor Description SvgMonoSampleWriter(File aFile)
Constructs theSvgMonoSampleWriter
for writing sound samples to a SVG file or stream.SvgMonoSampleWriter(OutputStream aOutputStream)
Constructs theSvgMonoSampleWriter
for writing sound samples to a SVG file or stream.SvgMonoSampleWriter(PrintStream aPrintStream)
Constructs theSvgMonoSampleWriter
for writing sound samples to a SVG file or stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
int
getSamplingRate()
Retrieves the sampling rate from the sampling rate property.void
setSamplingRate(int aSamplingRate)
Sets the sampling rate for the sampling rate property.SvgMonoSampleWriter
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(MonoSample aSample)
Writes the next samples, one sample for each channel.-
Methods inherited from class org.refcodes.audio.AbstractSvgSampleWriter
format, toDouble, toString, toYCoordinate, writeSvgHeader
-
-
-
-
Constructor Detail
-
SvgMonoSampleWriter
public SvgMonoSampleWriter(File aFile) throws FileNotFoundException
Constructs theSvgMonoSampleWriter
for writing sound samples to a SVG file or stream.- Parameters:
aFile
- TheFile
where to write the SVG 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.
-
SvgMonoSampleWriter
public SvgMonoSampleWriter(OutputStream aOutputStream)
Constructs theSvgMonoSampleWriter
for writing sound samples to a SVG file or stream.- Parameters:
aOutputStream
- TheOutputStream
where to write the SVG records to.
-
SvgMonoSampleWriter
public SvgMonoSampleWriter(PrintStream aPrintStream)
Constructs theSvgMonoSampleWriter
for writing sound samples to a SVG file or stream.- Parameters:
aPrintStream
- ThePrintStream
where to write the SVG records to.
-
-
Method Detail
-
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 interfaceMonoSampleWriter<SvgMonoSampleWriter>
- 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 interfaceorg.refcodes.io.RowWriter<SvgMonoSampleWriter>
- Specified by:
writeNext
in interfaceSampleWriter<MonoSample,B extends MonoSampleWriter<B>>
- Parameters:
aSample
- The samples, one for each channel.
-
close
public void close() throws IOException
Description copied from class:AbstractSvgSampleWriter
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSampleWriter<MonoSample,B extends MonoSampleWriter<B>>
- Overrides:
close
in classAbstractSvgSampleWriter<MonoSample,SvgMonoSampleWriter>
- Throws:
IOException
-
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
public SvgMonoSampleWriter withSamplingRate(int aSamplingRate)
Sets the sampling rate for the sampling rate property.- Specified by:
withSamplingRate
in interfaceSamplingRateAccessor.SamplingRateBuilder<SvgMonoSampleWriter>
- Parameters:
aSamplingRate
- The sampling rate to be stored by the sampling rate property.- Returns:
- The builder for applying multiple build operations.
-
-