Module org.refcodes.audio
Package org.refcodes.audio
Class AbstractSvgSampleWriter<S extends SoundSample,B extends SampleWriter<S,B>>
- java.lang.Object
-
- org.refcodes.audio.AbstractSvgSampleWriter<S,B>
-
- Type Parameters:
S- TheSoundSample(sub-)type on which theSampleWriterimplementation is to operate on.B- TheSampleWriterimplementing thisAbstractSvgSampleWriter.
- All Implemented Interfaces:
AutoCloseable,SampleWriter<S,B>,SamplingRateAccessor,SamplingRateAccessor.SamplingRateBuilder<B>,SamplingRateAccessor.SamplingRateMutator,SamplingRateAccessor.SamplingRateProperty,org.refcodes.io.RowWriter<S>
- Direct Known Subclasses:
SvgMonoSampleWriter
public abstract class AbstractSvgSampleWriter<S extends SoundSample,B extends SampleWriter<S,B>> extends Object implements SampleWriter<S,B>
TheAbstractSvgSampleWriterprovides a foundation 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 Modifier and Type Field Description protected PrintStream_printStream
-
Constructor Summary
Constructors Constructor Description AbstractSvgSampleWriter(File aFile)Constructs theAbstractSvgSampleWriterfor writing sound samples to a SVG file or stream.AbstractSvgSampleWriter(OutputStream aOutputStream)Constructs theAbstractSvgSampleWriterfor writing sound samples to a SVG file or stream.AbstractSvgSampleWriter(PrintStream aPrintStream)Constructs theAbstractSvgSampleWriterfor writing sound samples to a SVG file or stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()protected static Stringformat(String aDouble)Hackishly removes trailing zeros if there is no additional value from them unifying the decimal point.protected static doubletoDouble(String aDouble)Converts a string to a double by hackishly removing trailing zeros if there is no additional value from them and unifying the decimal point.protected static StringtoString(double aDouble)Converts a double to a string by hackishly removing trailing zeros if there is no additional value from them unifying the decimal point.protected doubletoYCoordinate(double aSampleData, double aFactor)protected voidwriteSvgHeader()Writes the SVG file's header, the SVG's tail is written upon invokingclose().-
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
writeNext
-
Methods inherited from interface org.refcodes.audio.SamplingRateAccessor
getSamplingRate
-
Methods inherited from interface org.refcodes.audio.SamplingRateAccessor.SamplingRateBuilder
withSamplingRate
-
Methods inherited from interface org.refcodes.audio.SamplingRateAccessor.SamplingRateMutator
setSamplingRate
-
Methods inherited from interface org.refcodes.audio.SamplingRateAccessor.SamplingRateProperty
letSamplingRate
-
-
-
-
Field Detail
-
_printStream
protected PrintStream _printStream
-
-
Constructor Detail
-
AbstractSvgSampleWriter
public AbstractSvgSampleWriter(File aFile) throws FileNotFoundException
Constructs theAbstractSvgSampleWriterfor writing sound samples to a SVG file or stream.- Parameters:
aFile- TheFilewhere 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.
-
AbstractSvgSampleWriter
public AbstractSvgSampleWriter(OutputStream aOutputStream)
Constructs theAbstractSvgSampleWriterfor writing sound samples to a SVG file or stream.- Parameters:
aOutputStream- TheOutputStreamwhere to write the SVG records to.
-
AbstractSvgSampleWriter
public AbstractSvgSampleWriter(PrintStream aPrintStream)
Constructs theAbstractSvgSampleWriterfor writing sound samples to a SVG file or stream.- Parameters:
aPrintStream- ThePrintStreamwhere to write the SVG records to.
-
-
Method Detail
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSampleWriter<S extends SoundSample,B extends SampleWriter<S,B>>- Throws:
IOException
-
toYCoordinate
protected double toYCoordinate(double aSampleData, double aFactor)
-
writeSvgHeader
protected void writeSvgHeader()
Writes the SVG file's header, the SVG's tail is written upon invokingclose().
-
toString
protected static String toString(double aDouble)
Converts a double to a string by hackishly removing trailing zeros if there is no additional value from them unifying the decimal point.- Parameters:
aDouble- The double to be converted to a string.- Returns:
- The formatted double without any trailing zeros.
-
toDouble
protected static double toDouble(String aDouble)
Converts a string to a double by hackishly removing trailing zeros if there is no additional value from them and unifying the decimal point.- Parameters:
aDouble- The double from which to remove trailing zeros.- Returns:
- The formatted double without any trailing zeros.
-
-