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
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetStream(List<ToneSynthesizer.Tone> tones) Synthesize a list ofToneSynthesizer.Toneinto a wav audio streamstatic Set<AudioFormat> static ToneSynthesizer.TonenoteTone(ToneSynthesizer.Note note, long millis) static ToneSynthesizer.TonenoteTone(ToneSynthesizer.Note note, long millis, int octaves) static List<ToneSynthesizer.Tone> parseMelody(String melody) Parses a tone melody into a list ofToneSynthesizer.Toneinstances.static ToneSynthesizer.TonesilenceTone(long millis)
-
Constructor Details
-
ToneSynthesizer
-
-
Method Details
-
getSupportedFormats
-
parseMelody
Parses a tone melody into a list ofToneSynthesizer.Toneinstances. 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.Toneinstances. - Throws:
ParseException- if melody can not be played.
-
noteTone
-
noteTone
-
silenceTone
-
getStream
Synthesize a list ofToneSynthesizer.Toneinto 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
-