public final class ToneSequenceBuilder
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ToneSequenceBuilder.AnnotationCVSFileHandlers |
static interface |
ToneSequenceBuilder.CSVFileHandler |
Constructor and Description |
---|
ToneSequenceBuilder()
Initializes the lists of frequencies and times.
|
Modifier and Type | Method and Description |
---|---|
void |
addTone(double frequency,
double realTime)
Add a tone with a certain frequency (in Hertz) starting at a certain time
(seconds).
|
void |
addTone(double frequency,
double realTime,
double power) |
void |
clear()
Clears the frequencies and times.
|
int |
getNumberOfExpectedColumn() |
java.lang.String |
getSeparator() |
void |
handleRow(ToneSequenceBuilder builder,
java.lang.String[] row) |
void |
playAnnotations(int smootFilterWindowSize) |
static void |
saveAsWav(java.lang.String csvFileName,
ToneSequenceBuilder.CSVFileHandler handler,
int smootFilterWindowSize)
Read data from a CSV-File, handle it with the handler, smooth it and save
it to the generated audio folder.
|
void |
setExtractor(SignalPowerExtractor extractor) |
void |
writeFile(java.lang.String fileName,
int smootFilterWindowSize,
java.lang.String sourceFile)
Write a stereo WAV-file (sample rate 44.1 kHz) with frequencies and their
respective durations (start times).
|
public ToneSequenceBuilder()
public void addTone(double frequency, double realTime)
The tone stops when the next tone starts. The last tone has a duration of 0 seconds. The entries should be added chronologically! Strange things will happen if you ignore this rule.
frequency
- the frequency in Hertz of the tone to addrealTime
- the starttime in seconds of the tone. The tone stops when the
next one starts. The last tone is never played.public void addTone(double frequency, double realTime, double power)
public void clear()
ToneSequenceBuilder
.public void playAnnotations(int smootFilterWindowSize)
public void writeFile(java.lang.String fileName, int smootFilterWindowSize, java.lang.String sourceFile) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileException, javax.sound.sampled.LineUnavailableException
fileName
- The name of the file to render. e.g. "out.wav".smootFilterWindowSize
- To prevent (very) sudden changes in the frequency of tones a
smoothing function can be applied. The window size of the
smoothing function defines what an unexpected value is and if
it is smoothed. When no smoothing is required set it
to zero. Otherwise a value between 5 and 50 is
normal. ( 50 x 10 ms = 500 ms = 0.5 seconds). A
median filter is used.sourceFile
- The source file usedjava.io.IOException
- When something goes awry.javax.sound.sampled.UnsupportedAudioFileException
javax.sound.sampled.LineUnavailableException
SinkIsFullException
java.lang.InterruptedException
BufferNotAvailableException
public static void saveAsWav(java.lang.String csvFileName, ToneSequenceBuilder.CSVFileHandler handler, int smootFilterWindowSize)
csvFileName
- the CSV-file to processhandler
- the handlersmootFilterWindowSize
- the window size for the smoothing function (Median filter).public void handleRow(ToneSequenceBuilder builder, java.lang.String[] row)
public java.lang.String getSeparator()
public int getNumberOfExpectedColumn()
public void setExtractor(SignalPowerExtractor extractor)