Csound Csound-dev Csound-tekno Search About

[Csnd] Can outputs be closely timed, e.g. by NTP?

Date2023-03-25 18:03
FromMichael Jinks
Subject[Csnd] Can outputs be closely timed, e.g. by NTP?
I'm a life-long Csound newbie.  Maybe this'll be the case that finally convinces me to learn something.

I have a room where I'd like to play sound from a single source, over two output channels (say, "left and right", but maybe more eventually); to coordinate two executions, I only have WiFi; no wired network, and there isn't the right space for cabling a single source across two parts of the room.

So, I thought: why not have two mini machines (a pair of Raspberry Pi's, for instance), closely linked in time by NTP, with one doing the right channel, the other doing the left?  There are science projects doing things like this, where time syncing is more sensitive that sound, so...?

My first guess for an app to handle this was MPD:


...but I've been told that MPD isn't that sort of a tool, it's more like the delivery system of the files, not the execution of them.  I think.

And, I can't find any playback apps that do something like this either -- like, where "instance A" just happens to have its left channel turned down, "instance B" happens to have the right channel turned down, and the two are set to run sound closely timed, according to some common set of files.

So!  Hi!  I'm a proud owner of The Book, but there it sits.  I know that if you want some kind of sound to happen, Csound can do it, in a variety of circumstances, but, um, how?

My ideal would be something like:

  - there's a source of sound files stored on the network, reachable on a shared filesystem; <- this is done
  - we have a set of PC's (Pi, laptops, whatever) running Csound; <- this is done
  - ...they each have at least one speaker attached; <- yeah, yeah...
  - there's a source of commands, something like:
       'play [file] over [channel] at [time]'
    ...where "time" is a constantly changing, agreed-upon number, from NTP;
    ..."file" refers to one shared over some common source;
    ...and "channel" is set set up however;
  - then, there's some simple user interface (web page, app, whatever) that can act as a jukebox: choose the file from some list; start/stop, louder, softer, pause... like Amberol, Ario, Rhythmbox, Snapcast, whatever, but with Csound providing the active layer.

I know (right?) that Csound contains all the libraries for handling something like this, but I don't have a clue how I would use it to set this sort of thing up.  So, cluse?  Tell me what I should read?  I can't be the first person who's had this idea.  Successfully I mean.

Thanks.









Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2023-03-25 19:07
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Can outputs be closely timed, e.g. by NTP?
I know zero about NTP,  but assuming you have access to it I see some possibilities

1) possibly running Csound in JavaScript could be the simplest thing if you can access NTP in the browser. Then you can fire events to start at a known time.

2) write a C/C++, python, or java program that handles NTP and fires Csound events at a given time. 

3) These two options run Csound embedded into your app through its API. Another possibility is to run Csound as a UDP server and fire events over UDP to it. Not sure what kind of sync you'd get. There's also Open Sound Control but I'd say syncing is not easy through it.

Oeyvind Brandtsegg probably has a thing or two to say about this.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 25 Mar 2023, at 18:15, Michael Jinks <michael.jinks@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

I'm a life-long Csound newbie.  Maybe this'll be the case that finally convinces me to learn something.

I have a room where I'd like to play sound from a single source, over two output channels (say, "left and right", but maybe more eventually); to coordinate two executions, I only have WiFi; no wired network, and there isn't the right space for cabling a single source across two parts of the room.

So, I thought: why not have two mini machines (a pair of Raspberry Pi's, for instance), closely linked in time by NTP, with one doing the right channel, the other doing the left?  There are science projects doing things like this, where time syncing is more sensitive that sound, so...?

My first guess for an app to handle this was MPD:


...but I've been told that MPD isn't that sort of a tool, it's more like the delivery system of the files, not the execution of them.  I think.

And, I can't find any playback apps that do something like this either -- like, where "instance A" just happens to have its left channel turned down, "instance B" happens to have the right channel turned down, and the two are set to run sound closely timed, according to some common set of files.

So!  Hi!  I'm a proud owner of The Book, but there it sits.  I know that if you want some kind of sound to happen, Csound can do it, in a variety of circumstances, but, um, how?

My ideal would be something like:

  - there's a source of sound files stored on the network, reachable on a shared filesystem; <- this is done
  - we have a set of PC's (Pi, laptops, whatever) running Csound; <- this is done
  - ...they each have at least one speaker attached; <- yeah, yeah...
  - there's a source of commands, something like:
       'play [file] over [channel] at [time]'
    ...where "time" is a constantly changing, agreed-upon number, from NTP;
    ..."file" refers to one shared over some common source;
    ...and "channel" is set set up however;
  - then, there's some simple user interface (web page, app, whatever) that can act as a jukebox: choose the file from some list; start/stop, louder, softer, pause... like Amberol, Ario, Rhythmbox, Snapcast, whatever, but with Csound providing the active layer.

I know (right?) that Csound contains all the libraries for handling something like this, but I don't have a clue how I would use it to set this sort of thing up.  So, cluse?  Tell me what I should read?  I can't be the first person who's had this idea.  Successfully I mean.

Thanks.









Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2023-03-27 08:52
FromOeyvind Brandtsegg
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Can outputs be closely timed, e.g. by NTP?
Hi Michael,
It is an interesting problem with time sync. 
Wireless home audio systems like Sonos apparently manage to play stereo audio on separate wireless speakers, so perhaps look into how they solve it. I do not know their internals, but please let us know when you find out.

Generally, I do think that it will be problematic to get a good enough synchronization between two separate computers to enable you to play each separate channel of a stereo file on each of those two machines. You would need sample-accurate sync, not only to start the sounds, but also continuously to keep the two computers in sync while playing. Even with two separate sound cards connected to the same computer, one will very likely get clock drift over time, which is why we use word clock and similar master syncing techniques between devices. I do think that a cabled connection and some sort of master clock going on that cable would make it much easier to create stable sync. I guess this is what is also used for scientific experiments in particle physics and the like. 

Let us know what you come up with.
All best
Øyvind

lør. 25. mar. 2023 kl. 20:07 skrev Victor Lazzarini <Victor.Lazzarini@mu.ie>:
I know zero about NTP,  but assuming you have access to it I see some possibilities

1) possibly running Csound in JavaScript could be the simplest thing if you can access NTP in the browser. Then you can fire events to start at a known time.

2) write a C/C++, python, or java program that handles NTP and fires Csound events at a given time. 

3) These two options run Csound embedded into your app through its API. Another possibility is to run Csound as a UDP server and fire events over UDP to it. Not sure what kind of sync you'd get. There's also Open Sound Control but I'd say syncing is not easy through it.

Oeyvind Brandtsegg probably has a thing or two to say about this.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 25 Mar 2023, at 18:15, Michael Jinks <michael.jinks@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

I'm a life-long Csound newbie.  Maybe this'll be the case that finally convinces me to learn something.

I have a room where I'd like to play sound from a single source, over two output channels (say, "left and right", but maybe more eventually); to coordinate two executions, I only have WiFi; no wired network, and there isn't the right space for cabling a single source across two parts of the room.

So, I thought: why not have two mini machines (a pair of Raspberry Pi's, for instance), closely linked in time by NTP, with one doing the right channel, the other doing the left?  There are science projects doing things like this, where time syncing is more sensitive that sound, so...?

My first guess for an app to handle this was MPD:


...but I've been told that MPD isn't that sort of a tool, it's more like the delivery system of the files, not the execution of them.  I think.

And, I can't find any playback apps that do something like this either -- like, where "instance A" just happens to have its left channel turned down, "instance B" happens to have the right channel turned down, and the two are set to run sound closely timed, according to some common set of files.

So!  Hi!  I'm a proud owner of The Book, but there it sits.  I know that if you want some kind of sound to happen, Csound can do it, in a variety of circumstances, but, um, how?

My ideal would be something like:

  - there's a source of sound files stored on the network, reachable on a shared filesystem; <- this is done
  - we have a set of PC's (Pi, laptops, whatever) running Csound; <- this is done
  - ...they each have at least one speaker attached; <- yeah, yeah...
  - there's a source of commands, something like:
       'play [file] over [channel] at [time]'
    ...where "time" is a constantly changing, agreed-upon number, from NTP;
    ..."file" refers to one shared over some common source;
    ...and "channel" is set set up however;
  - then, there's some simple user interface (web page, app, whatever) that can act as a jukebox: choose the file from some list; start/stop, louder, softer, pause... like Amberol, Ario, Rhythmbox, Snapcast, whatever, but with Csound providing the active layer.

I know (right?) that Csound contains all the libraries for handling something like this, but I don't have a clue how I would use it to set this sort of thing up.  So, cluse?  Tell me what I should read?  I can't be the first person who's had this idea.  Successfully I mean.

Thanks.









Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2023-03-27 16:47
FromMichael Jinks
SubjectRe: [Csnd] [EXTERNAL] [Csnd] Can outputs be closely timed, e.g. by NTP?
Thanks Øyvind, Victor.

> Wireless home audio systems like Sonos apparently
> manage to play stereo audio on separate wireless
> speakers, so perhaps look into how they solve it.

I was about to ask!  So, "worth investigating."  Will do.

This is something I had no awareness of:

> Even with two separate sound cards connected to the
> same computer, one will very likely get clock drift over
> time

...so that's a bummer. 

I still hold hope that some combo of Network Time Protocol (mistake on my part to assume the whole world knows what NTP is; sorry about that), and, maybe, OS-level priority control, ought to be able to do this.  Like you said, there are companies offering to put sound in different corners of the kitchen.  So, I assumed there would be a way, hopefully a widely known way, to set up something like this.  It's turning out to be a harder project that I guessed.

Thanks for the tips.  I will sing back if I do get anywhere with it.


On Mon, Mar 27, 2023 at 2:54 AM Oeyvind Brandtsegg <obrandts@gmail.com> wrote:
Hi Michael,
It is an interesting problem with time sync. 
Wireless home audio systems like Sonos apparently manage to play stereo audio on separate wireless speakers, so perhaps look into how they solve it. I do not know their internals, but please let us know when you find out.

Generally, I do think that it will be problematic to get a good enough synchronization between two separate computers to enable you to play each separate channel of a stereo file on each of those two machines. You would need sample-accurate sync, not only to start the sounds, but also continuously to keep the two computers in sync while playing. Even with two separate sound cards connected to the same computer, one will very likely get clock drift over time, which is why we use word clock and similar master syncing techniques between devices. I do think that a cabled connection and some sort of master clock going on that cable would make it much easier to create stable sync. I guess this is what is also used for scientific experiments in particle physics and the like. 

Let us know what you come up with.
All best
Øyvind

lør. 25. mar. 2023 kl. 20:07 skrev Victor Lazzarini <Victor.Lazzarini@mu.ie>:
I know zero about NTP,  but assuming you have access to it I see some possibilities

1) possibly running Csound in JavaScript could be the simplest thing if you can access NTP in the browser. Then you can fire events to start at a known time.

2) write a C/C++, python, or java program that handles NTP and fires Csound events at a given time. 

3) These two options run Csound embedded into your app through its API. Another possibility is to run Csound as a UDP server and fire events over UDP to it. Not sure what kind of sync you'd get. There's also Open Sound Control but I'd say syncing is not easy through it.

Oeyvind Brandtsegg probably has a thing or two to say about this.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 25 Mar 2023, at 18:15, Michael Jinks <michael.jinks@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

I'm a life-long Csound newbie.  Maybe this'll be the case that finally convinces me to learn something.

I have a room where I'd like to play sound from a single source, over two output channels (say, "left and right", but maybe more eventually); to coordinate two executions, I only have WiFi; no wired network, and there isn't the right space for cabling a single source across two parts of the room.

So, I thought: why not have two mini machines (a pair of Raspberry Pi's, for instance), closely linked in time by NTP, with one doing the right channel, the other doing the left?  There are science projects doing things like this, where time syncing is more sensitive that sound, so...?

My first guess for an app to handle this was MPD:


...but I've been told that MPD isn't that sort of a tool, it's more like the delivery system of the files, not the execution of them.  I think.

And, I can't find any playback apps that do something like this either -- like, where "instance A" just happens to have its left channel turned down, "instance B" happens to have the right channel turned down, and the two are set to run sound closely timed, according to some common set of files.

So!  Hi!  I'm a proud owner of The Book, but there it sits.  I know that if you want some kind of sound to happen, Csound can do it, in a variety of circumstances, but, um, how?

My ideal would be something like:

  - there's a source of sound files stored on the network, reachable on a shared filesystem; <- this is done
  - we have a set of PC's (Pi, laptops, whatever) running Csound; <- this is done
  - ...they each have at least one speaker attached; <- yeah, yeah...
  - there's a source of commands, something like:
       'play [file] over [channel] at [time]'
    ...where "time" is a constantly changing, agreed-upon number, from NTP;
    ..."file" refers to one shared over some common source;
    ...and "channel" is set set up however;
  - then, there's some simple user interface (web page, app, whatever) that can act as a jukebox: choose the file from some list; start/stop, louder, softer, pause... like Amberol, Ario, Rhythmbox, Snapcast, whatever, but with Csound providing the active layer.

I know (right?) that Csound contains all the libraries for handling something like this, but I don't have a clue how I would use it to set this sort of thing up.  So, cluse?  Tell me what I should read?  I can't be the first person who's had this idea.  Successfully I mean.

Thanks.









Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here