Tone generation in Erlang