Package org.openhab.core.audio.utils
Class ToneSynthesizer
java.lang.Object
org.openhab.core.audio.utils.ToneSynthesizer
An audio tone synthesizer. A utility to sent tone melodies to audio sinks.
Limited to wav little endian streams.
- Author:
- Miguel Álvarez - Initial contribution
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetStream
(List<ToneSynthesizer.Tone> tones) Synthesize a list ofToneSynthesizer.Tone
into a wav audio streamstatic Set<AudioFormat>
static ToneSynthesizer.Tone
noteTone
(ToneSynthesizer.Note note, long millis) static ToneSynthesizer.Tone
noteTone
(ToneSynthesizer.Note note, long millis, int octaves) static List<ToneSynthesizer.Tone>
parseMelody
(String melody) Parses a tone melody into a list ofToneSynthesizer.Tone
instances.static ToneSynthesizer.Tone
silenceTone
(long millis)
-
Constructor Details
-
ToneSynthesizer
-
-
Method Details
-
getSupportedFormats
-
parseMelody
Parses a tone melody into a list ofToneSynthesizer.Tone
instances. The melody should be a spaced separated list of note names or silences (character 0 or O). You can optionally add the character "'" to increase the note one octave. You can optionally add ":ms" where ms is an int value to customize the note/silence milliseconds duration (defaults to 200ms).- Parameters:
melody
- to be parsed.- Returns:
- list of
ToneSynthesizer.Tone
instances. - Throws:
ParseException
- if melody can not be played.
-
noteTone
-
noteTone
-
silenceTone
-
getStream
Synthesize a list ofToneSynthesizer.Tone
into a wav audio stream- Parameters:
tones
- the list ofToneSynthesizer.Tone
- Returns:
- an audio stream with the synthesized tones
- Throws:
IOException
- in case of problems writing the audio stream
-