Skip to content

Instantly share code, notes, and snippets.

@kuniyoshi
Created March 2, 2014 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuniyoshi/9307819 to your computer and use it in GitHub Desktop.
Save kuniyoshi/9307819 to your computer and use it in GitHub Desktop.
A chirp sample. The sound's frequency changes from 2500 Hz to 1500 Hz, and fade out it.
gen(chirp, Options) ->
FirstFrequency = proplists:get_value(first_frequency, Options),
LastFrequency = proplists:get_value(last_frequency, Options),
SamplingFrequency = proplists:get_value(sampling_frequency, Options),
Count = proplists:get_value(count, Options),
Samples = lists:map(fun(I) ->
Frequency = FirstFrequency + (LastFrequency - FirstFrequency) / Count * I,
math:sin(2 * math:pi() * Frequency / SamplingFrequency * I)
end,
lists:seq(1, Count)),
Samples.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment