[erlang-questions] Generating sine waves and/or audio stream output

Willem de Jong w.a.de.jong@REDACTED
Wed Mar 24 19:34:34 CET 2010


Hello Ivan,

I have an erlang module that generates sounds. It can generate different
wave forms (right now all I need is a saw-like shape and a sinus shape). I
am attaching it. It is a bit messy, perhaps, but it should give you an
impression of how it can be done.

The synthesize() function uses the sinus() function to create a number of
complete waves, and then pastes  these together repeatedly (I assumed that
would be more efficient that calculating the sinus() function for each
sample).

The syntesize() function returns a couple of sound fragments: an "attaque"
bit that starts with an amplitude of zero, a fade-out bit where the volume
decreases back to 0, and a long and a short bit of sound with a stable
volume. Another module creates a complete sound-fragment of the desired
duration by pasting together the attaque, a number of long fragments and
short fragments in such a way that it matches the duration (as precisely as
possible), and a fade out bit.

As you can see this creates sounds with a fixed pitch and volume (within one
sound, that is). Also note that both the length and the pitch of the sound
will be approximations.

I created this to generate music for my web-site: http://coria.nl.  You can
try the result there, if you want. It is a site that enables me and the
other members of my choir (and anyone else who is interested) to practise
our music.

Any comments or suggestions will be quite welcome,
Good luck,
Willem





On Wed, Mar 24, 2010 at 11:28 AM, Ivan Uemlianin <ivan@REDACTED> wrote:

> Dear All
>
> I am learning Erlang and one of the things I'm interested in is
> generating sine waves, merging them and streaming them to audio output.
>
> I can kind of imagine how generating and merging would work, with a sine
> wave represented as a list of numbers.  Is there an Erlang library or
> project working with sine waves?
>
> I can't imagine how to stream a list of numbers to audio output.  Can
> anyone point me to projects/libraries/ideas for that one?  Writing the
> data to a file would be OK for now, but "live" sound would be much nicer.
>
> With thanks and best wishes
>
> Ivan
>
> --
> ============================================================
> Ivan A. Uemlianin
> Speech Technology Research and Development
>
>                   ivan@REDACTED
>                    www.llaisdy.com
>                        llaisdy.wordpress.com
>                    www.linkedin.com/in/ivanuemlianin
>
>   "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen"
>                    (Schiller, Beethoven)
> ============================================================
>
>
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20100324/9a795e86/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sound.hrl
Type: application/octet-stream
Size: 159 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20100324/9a795e86/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sound.erl
Type: application/octet-stream
Size: 4495 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20100324/9a795e86/attachment-0001.obj>


More information about the erlang-questions mailing list