|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbe.hogent.tarsos.midi.ToneSequenceBuilder
public final class ToneSequenceBuilder
Create a sequence of tones. Tones are in this case a sine wave of a certain frequency (in Hertz) starting at a certain time (in seconds) the current tone stops when another tone starts: this class generates only one tone at the time (monophonic).
Nested Class Summary | |
---|---|
static class |
ToneSequenceBuilder.AnnotationCVSFileHandlers
|
static interface |
ToneSequenceBuilder.CSVFileHandler
|
Constructor Summary | |
---|---|
ToneSequenceBuilder()
Initializes the lists of frequencies and times. |
Method Summary | |
---|---|
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. |
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 |
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). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ToneSequenceBuilder()
Method Detail |
---|
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 used
java.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).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |