Building a DAW in Erlang

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Building a DAW in Erlang

Joe Armstrong-2
Hello,

I want to build a "proof of concept" DAW (Digital Audio Workstation)

Why? - just for fun.

DAWs involve complex GUIs, complex audio processing, and complex
man-machine interactions - I'd like to make the DAW from small well
defined isolated communicating components.

I was wondering about audio - has anybody ideas about this.

I want to build a synthesizer with as much Erlang as possible and
as little C as necessary - and even if I use C I'd like reference
algorithms in Erlang to validate the C. Has anybody implemented any
digital audio filters in Erlang?

The Synthesizer would have no GUI (The GUI is a separate issue).

Having got to the point where I can generate raw PCM samples
I need to output these - preferably send them to a socket,
with an audio server that reads and outputs the samples - has anybody
done this?

Initially I'll do this on mac but would eventually like it to run on
windows and linux.

All idea are very welcome

/Joe
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Building a DAW in Erlang

Jacob-2
Hello Joe,

On 31.08.2017 13:11, Joe Armstrong wrote:

> Hello,
>
> I want to build a "proof of concept" DAW (Digital Audio Workstation)
>
> Why? - just for fun.
>
> DAWs involve complex GUIs, complex audio processing, and complex
> man-machine interactions - I'd like to make the DAW from small well
> defined isolated communicating components.
>
> I was wondering about audio - has anybody ideas about this.

A big challenge with a (distributed) setting consisting of isolated
components is to get synchronisation right, especially with an
asynchronous  architecture. If you think of hardware components
connected via e.g. AES/EBU unidirectional digital links, each of these
components usually gets a clock source (either audio or wordclock input)
unless it is the clock master.

When doing audio with a computer, the clock master is in general the
audio sound card. If you want to have a distributed system with
_several_ sound cards (even on the same host), you will need a hardware
wordclock sync between them. Otherwise you would introduce new clock
domains.

If the system clock is used to generate audio samples (lets say to
generate 48000 samples per second) and the samples are just fed to the
sound card, evil things will happen (which things exactly depends mainly
on the hardware and on drivers, but they will be audible in general
which I consider evil). The cause is: the system clock is in another
clock domain than the audio card. And system oscillators are in general
cheap ones with relatively bad stability and temperature coefficients.

When different clock domains are involved, sample-rate conversion and
DLL/PLL and stuff like that are needed, with in turn may introduce
audible pitch changes (DVB for instance relies on a reference clock of
27MHz with a max change (1st derivation) of 75mHz/s to avoid this, see
ISO/IEC 13818-1). Nevertheless adaptive sample rate conversion is done
e.g. by vlc and other players to play broadcast radio/television e.g.
via RTP. I'd rather avoid doing that myself (I did it once and its no fun).

So when thinking about a system open for professional use, I'd design it
to use a single clock domain. Two approaches to achieve this on a
computer based system are
  1. broadcasting or distributing a reference clock (e.g. with a sample
index)
  2. using backpressure
I think the former is a good fit for an asynchronous (Erlang) system.

On the other hand, one could start with an RTP sender (e.g. payload type
10 or 11, see https://en.wikipedia.org/wiki/RTP_audio_video_profile )
and rely on the system clock as a quick start (both encapsulated in a
single process, accepting timestamped audio and distributing timestamped
clock references). Perhaps vlc can be convinced to send RTP/RTCP based
on the audio input of the same audio interface, that would be a better
time reference (same clock domain).

The more pro audio open source variant would probably be to use jackd,
e.g. by writing an Erlang netjack1 client
(https://github.com/jackaudio/jackaudio.github.com/wiki/WalkThrough_User_NetJack).

>
> All idea are very welcome

That's jump a dump of what came to my mind about your idea. I hope it's
useful.

Jacob
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Building a DAW in Erlang

Lloyd R. Prentice-2
In reply to this post by Joe Armstrong-2
Hey Joe,

Great project!

Sadly, for me, I can't help with the technical issues facing you. But, here are two wacky experiments that may or may not yield interesting results.

But first, some background:

Way back in my Stanford graduate student days friends and I got together for several sessions to play with audio recording. We were interested in creating the most far-our sounds possible--- anything goes from banging on oven racks to looping and messing with tape speeds. Pure play. We came out with a cacophony of eery sounds. A year later I produced a film on Robert Frost's childhood in San Francisco. But one scene defied our composer. We need something, but music didn't seem right. Then I remembered our cacophy tape. We found an interesting section, mixed it into the sound track at a low level, and it was perfect.

So, Experiment A:

1. Create a sample of N Erlang terms.
2. Run them through erlang:term_to_binary/1.
3. Play them back through audio.

You may need headers to play the audio, but you'd know more about that than I.

Thought (and maybe do) Experiment B:

1. Is it possible to write an Erlang term that generates an approximation of white noise?
2. Is it possible to write an Erlang term that generates short sequences of basic wave forms--- sine, triangle, square?
3. Is there a programmatic way to edit the generated binaries to improve aesthetic quality?

Love to hear if you come up with anything.

All the best,

LRP





-----Original Message-----
From: "Joe Armstrong" <[hidden email]>
Sent: Thursday, August 31, 2017 7:11am
To: "Erlang" <[hidden email]>
Subject: [erlang-questions] Building a DAW in Erlang

Hello,

I want to build a "proof of concept" DAW (Digital Audio Workstation)

Why? - just for fun.

DAWs involve complex GUIs, complex audio processing, and complex
man-machine interactions - I'd like to make the DAW from small well
defined isolated communicating components.

I was wondering about audio - has anybody ideas about this.

I want to build a synthesizer with as much Erlang as possible and
as little C as necessary - and even if I use C I'd like reference
algorithms in Erlang to validate the C. Has anybody implemented any
digital audio filters in Erlang?

The Synthesizer would have no GUI (The GUI is a separate issue).

Having got to the point where I can generate raw PCM samples
I need to output these - preferably send them to a socket,
with an audio server that reads and outputs the samples - has anybody
done this?

Initially I'll do this on mac but would eventually like it to run on
windows and linux.

All idea are very welcome

/Joe
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Building a DAW in Erlang

Richard A. O'Keefe-2


On 1/09/17 12:22 PM, [hidden email] wrote:
>
> 1. Is it possible to write an Erlang term that generates an approximation of white noise?
> 2. Is it possible to write an Erlang term that generates short sequences of basic wave forms--- sine, triangle, square?
> 3. Is there a programmatic way to edit the generated binaries to improve aesthetic quality?

Since the external term encoding of a binary includes the bytes of
that binary verbatim, yes, yes, and yes.

See BINARY_EXT in
http://erlang.org/doc/apps/erts/erl_ext_dist.html
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Building a DAW in Erlang

Lloyd R. Prentice-2
Hi,

So, great ignorance speculating here, if we can generate basic wave forms with Erlang terms then, next, we need to be able to edit, mix, amplify, attenuate, play with phase relationships, etc., etc.

My superficial Google search didn't come up with much. This exchange touches on the issues:

https://stackoverflow.com/questions/1569035/what-makes-erlang-suitable-for-soft-real-time-applications

But it does feel like a vast field for bottom-up play. Shame that there are so few hours in the day.

All the best,

Lloyd


-----Original Message-----
From: "Richard A. O'Keefe" <[hidden email]>
Sent: Thursday, August 31, 2017 11:44pm
To: [hidden email]
Subject: Re: [erlang-questions] Building a DAW in Erlang



On 1/09/17 12:22 PM, [hidden email] wrote:
>
> 1. Is it possible to write an Erlang term that generates an approximation of white noise?
> 2. Is it possible to write an Erlang term that generates short sequences of basic wave forms--- sine, triangle, square?
> 3. Is there a programmatic way to edit the generated binaries to improve aesthetic quality?

Since the external term encoding of a binary includes the bytes of
that binary verbatim, yes, yes, and yes.

See BINARY_EXT in
http://erlang.org/doc/apps/erts/erl_ext_dist.html
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Leo
Reply | Threaded
Open this post in threaded view
|

Re: Building a DAW in Erlang

Leo
In reply to this post by Joe Armstrong-2


2017-08-31 13:11 GMT+02:00 Joe Armstrong <[hidden email]>:
Hello,

I want to build a "proof of concept" DAW (Digital Audio Workstation)


Hi Joe,
I think a good point where you can start is this: http://lac.linuxaudio.org/
They condensate a good number of audio expert happy to help you. :)
I went some years ago to the conference and it was really cool!

Leo

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Building a DAW in Erlang

Max Lapshin-2
In reply to this post by Lloyd R. Prentice-2
Just short thing:
if you decide to play audio in Mac, you will suffer from "main thread problem".   Almost all specific mac API calls require you to call them from "main thread" of application that is inaccessible by erlang code (nif or driver).

It was so several years ago and I don't know if this has changed.

About performance, stability and so else.  We in Flussonic have a serious challenge with sending UDP.  We need to prepare and send UDP packets (mpegts) so that they form a very good and stable stream with stable bitrate and inter-packet time. This is sent to DVB headend that sends video to cable or even to satellite.

Problem is that this task sometimes require submillisecond timer precision that is inaccessible in erlang.

Our code works ok with dozens of channels but without submillisecond precision.

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions