Csound Csound-dev Csound-tekno Search About

[Csnd] GMPlay.js

Date2022-12-18 20:55
FromVictor Lazzarini
Subject[Csnd] GMPlay.js
Attachmentsmaxresdefault.jpg  
Here's a more developed proof of concept of the simple coding environment I have been experimenting with.

The basis of it is the gm.csd code that is an adaptation of Istvan Varga's fluidComplex.csd example in the manual, made to work with sfplay instead.

GMPlay.js is a little library of functions to provide an interface to that code allowing instruments to be played and sequenced. MIDI device input also works directly and alongside it.

What took me a while to crack was to get a solid clock for the sequencer. In the end, I used a combination of Csound scheduling and the AudioContext clock. That allowed me to be independent of the JS timer, but I can still use it to create the time recursion needed for the sequences to be played. Anyway, with what I have now, it is possible to start new sequences on the fly and in sync to the beat.

Here's the quick preview

the system can be extended to have better synths beyond soundfonts, but the idea at the moment is to have a simple coding environment for run-of-the-mill music stuff.

Prof. Victor Lazzarini
Maynooth University
Ireland

Date2022-12-18 22:00
From"Dr. Richard Boulanger"
SubjectRe: [Csnd] GMPlay.js
Attachmentsmaxresdefault.jpg  
NICE., and thanks for the cool video demo as you work with it and modify it on the fly.  

- Dr.B


Dr. Richard Boulanger

Professor

Electronic Production and Design

Berklee College of Music

Professional Writing & Technology Division



On Sun, Dec 18, 2022 at 3:55 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
Here's a more developed proof of concept of the simple coding environment I have been experimenting with.

The basis of it is the gm.csd code that is an adaptation of Istvan Varga's fluidComplex.csd example in the manual, made to work with sfplay instead.

GMPlay.js is a little library of functions to provide an interface to that code allowing instruments to be played and sequenced. MIDI device input also works directly and alongside it.

What took me a while to crack was to get a solid clock for the sequencer. In the end, I used a combination of Csound scheduling and the AudioContext clock. That allowed me to be independent of the JS timer, but I can still use it to create the time recursion needed for the sequences to be played. Anyway, with what I have now, it is possible to start new sequences on the fly and in sync to the beat.

Here's the quick preview

the system can be extended to have better synths beyond soundfonts, but the idea at the moment is to have a simple coding environment for run-of-the-mill music stuff.

Prof. Victor Lazzarini
Maynooth University
Ireland
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

Date2022-12-19 03:57
FromHlöðver Sigurðsson
SubjectRe: [Csnd] GMPlay.js
Attachmentsmaxresdefault.jpg  
fantastic finding with the audio-context clock. I know it will be useful to many.

On Sun, 18 Dec 2022 at 23:02, Dr. Richard Boulanger <rboulanger@berklee.edu> wrote:
NICE., and thanks for the cool video demo as you work with it and modify it on the fly.  

- Dr.B


Dr. Richard Boulanger

Professor

Electronic Production and Design

Berklee College of Music

Professional Writing & Technology Division



On Sun, Dec 18, 2022 at 3:55 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
Here's a more developed proof of concept of the simple coding environment I have been experimenting with.

The basis of it is the gm.csd code that is an adaptation of Istvan Varga's fluidComplex.csd example in the manual, made to work with sfplay instead.

GMPlay.js is a little library of functions to provide an interface to that code allowing instruments to be played and sequenced. MIDI device input also works directly and alongside it.

What took me a while to crack was to get a solid clock for the sequencer. In the end, I used a combination of Csound scheduling and the AudioContext clock. That allowed me to be independent of the JS timer, but I can still use it to create the time recursion needed for the sequences to be played. Anyway, with what I have now, it is possible to start new sequences on the fly and in sync to the beat.

Here's the quick preview

the system can be extended to have better synths beyond soundfonts, but the idea at the moment is to have a simple coding environment for run-of-the-mill music stuff.

Prof. Victor Lazzarini
Maynooth University
Ireland
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

Date2022-12-19 08:00
Fromjoachim heintz
SubjectRe: [Csnd] GMPlay.js
all this stuff is awesome --- i am just going through your "vanilla" 
(actually much more than vanilla) examples and learning so much from it. 
  thanks!!!
	j


On 18/12/2022 21:55, Victor Lazzarini wrote:
> Here's a more developed proof of concept of the simple coding 
> environment I have been experimenting with.
> 
> The basis of it is the gm.csd code that is an adaptation of Istvan 
> Varga's fluidComplex.csd example in the manual, made to work with sfplay 
> instead.
> 
> GMPlay.js is a little library of functions to provide an interface to 
> that code allowing instruments to be played and sequenced. MIDI device 
> input also works directly and alongside it.
> 
> What took me a while to crack was to get a solid clock for the 
> sequencer. In the end, I used a combination of Csound scheduling and the 
> AudioContext clock. That allowed me to be independent of the JS timer, 
> but I can still use it to create the time recursion needed for the 
> sequences to be played. Anyway, with what I have now, it is possible to 
> start new sequences on the fly and in sync to the beat.
> 
> Here's the quick preview
> 
> maxresdefault.jpg
> GMPlay.js preview 
> youtu.be 
> 
> 
> 
> the system can be extended to have better synths beyond soundfonts, but 
> the idea at the moment is to have a simple coding environment for 
> run-of-the-mill music stuff.
> 
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
> 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

Date2022-12-19 10:04
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] GMPlay.js
Attachmentsmaxresdefault.jpg  
yes, the AudioContext clock is reliable. The issue becomes firing Csound events at a regular interval, which setTimout() can do.

If we use the audio clock to give us a reliable reference, we can fire events at or near the target time, even if setTimeout() is slightly late. That may give an error that is noticeable or not, but the overall pulse keeps going.

That works for the first minute or so, after that setTimeout() becomes really irregular becoming late at times by over 100ms.

The solution then is not to fire events at the time of the call but schedule them ahead, with the time difference between the audio clock and the target time taken in consideration.
That way, unless the error is absurdly high, events are scheduled correctly and Csound then takes care of delivering them in time. This also takes care of any minor timing errors and so it sounds much more correct.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 19 Dec 2022, at 03:59, Hlöðver Sigurðsson <hlolli@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.

fantastic finding with the audio-context clock. I know it will be useful to many.

On Sun, 18 Dec 2022 at 23:02, Dr. Richard Boulanger <rboulanger@berklee.edu> wrote:
NICE., and thanks for the cool video demo as you work with it and modify it on the fly.  

- Dr.B


Dr. Richard Boulanger

Professor

Electronic Production and Design

Berklee College of Music

Professional Writing & Technology Division



On Sun, Dec 18, 2022 at 3:55 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
Here's a more developed proof of concept of the simple coding environment I have been experimenting with.

The basis of it is the gm.csd code that is an adaptation of Istvan Varga's fluidComplex.csd example in the manual, made to work with sfplay instead.

GMPlay.js is a little library of functions to provide an interface to that code allowing instruments to be played and sequenced. MIDI device input also works directly and alongside it.

What took me a while to crack was to get a solid clock for the sequencer. In the end, I used a combination of Csound scheduling and the AudioContext clock. That allowed me to be independent of the JS timer, but I can still use it to create the time recursion needed for the sequences to be played. Anyway, with what I have now, it is possible to start new sequences on the fly and in sync to the beat.

Here's the quick preview

<maxresdefault.jpg>

the system can be extended to have better synths beyond soundfonts, but the idea at the moment is to have a simple coding environment for run-of-the-mill music stuff.

Prof. Victor Lazzarini
Maynooth University
Ireland
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

Date2022-12-19 10:12
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] GMPlay.js
Also, it is important to say that all of this trouble is only required if you are not programing in Csound, but doing everything in JS and *only* firing off inputMessages().

The simplest way to deal with time is to do all the sequencer programming etc in Csound. Then there is no hassle or need to deal with unreliable clocks.

This particular proof of concept is to see if Csound can be completely wrapped in JS and only used as a sound engine. All programming in this case is done in JS. The Csound code is just a standard CSD with two instruments (one to intercept midi, the other to run sfplay)
and nothing else.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 19 Dec 2022, at 10:05, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:

 yes, the AudioContext clock is reliable. The issue becomes firing Csound events at a regular interval, which setTimout() can do.

If we use the audio clock to give us a reliable reference, we can fire events at or near the target time, even if setTimeout() is slightly late. That may give an error that is noticeable or not, but the overall pulse keeps going.

That works for the first minute or so, after that setTimeout() becomes really irregular becoming late at times by over 100ms.

The solution then is not to fire events at the time of the call but schedule them ahead, with the time difference between the audio clock and the target time taken in consideration.
That way, unless the error is absurdly high, events are scheduled correctly and Csound then takes care of delivering them in time. This also takes care of any minor timing errors and so it sounds much more correct.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 19 Dec 2022, at 03:59, Hlöðver Sigurðsson <hlolli@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.

fantastic finding with the audio-context clock. I know it will be useful to many.

On Sun, 18 Dec 2022 at 23:02, Dr. Richard Boulanger <rboulanger@berklee.edu> wrote:
NICE., and thanks for the cool video demo as you work with it and modify it on the fly.  

- Dr.B


Dr. Richard Boulanger

Professor

Electronic Production and Design

Berklee College of Music

Professional Writing & Technology Division



On Sun, Dec 18, 2022 at 3:55 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
Here's a more developed proof of concept of the simple coding environment I have been experimenting with.

The basis of it is the gm.csd code that is an adaptation of Istvan Varga's fluidComplex.csd example in the manual, made to work with sfplay instead.

GMPlay.js is a little library of functions to provide an interface to that code allowing instruments to be played and sequenced. MIDI device input also works directly and alongside it.

What took me a while to crack was to get a solid clock for the sequencer. In the end, I used a combination of Csound scheduling and the AudioContext clock. That allowed me to be independent of the JS timer, but I can still use it to create the time recursion needed for the sequences to be played. Anyway, with what I have now, it is possible to start new sequences on the fly and in sync to the beat.

Here's the quick preview

<maxresdefault.jpg>

the system can be extended to have better synths beyond soundfonts, but the idea at the moment is to have a simple coding environment for run-of-the-mill music stuff.

Prof. Victor Lazzarini
Maynooth University
Ireland
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

Date2022-12-19 10:56
FromRory Walsh
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] GMPlay.js
Yes, that's key. If you use Csound as the main clock you can't go wrong. But this is also an interesting approach. Although I have to admit, I was scratching my head a little once you mentioned JS timers 😂

On Mon, 19 Dec 2022 at 10:12, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
Also, it is important to say that all of this trouble is only required if you are not programing in Csound, but doing everything in JS and *only* firing off inputMessages().

The simplest way to deal with time is to do all the sequencer programming etc in Csound. Then there is no hassle or need to deal with unreliable clocks.

This particular proof of concept is to see if Csound can be completely wrapped in JS and only used as a sound engine. All programming in this case is done in JS. The Csound code is just a standard CSD with two instruments (one to intercept midi, the other to run sfplay)
and nothing else.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 19 Dec 2022, at 10:05, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:

 yes, the AudioContext clock is reliable. The issue becomes firing Csound events at a regular interval, which setTimout() can do.

If we use the audio clock to give us a reliable reference, we can fire events at or near the target time, even if setTimeout() is slightly late. That may give an error that is noticeable or not, but the overall pulse keeps going.

That works for the first minute or so, after that setTimeout() becomes really irregular becoming late at times by over 100ms.

The solution then is not to fire events at the time of the call but schedule them ahead, with the time difference between the audio clock and the target time taken in consideration.
That way, unless the error is absurdly high, events are scheduled correctly and Csound then takes care of delivering them in time. This also takes care of any minor timing errors and so it sounds much more correct.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 19 Dec 2022, at 03:59, Hlöðver Sigurðsson <hlolli@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.

fantastic finding with the audio-context clock. I know it will be useful to many.

On Sun, 18 Dec 2022 at 23:02, Dr. Richard Boulanger <rboulanger@berklee.edu> wrote:
NICE., and thanks for the cool video demo as you work with it and modify it on the fly.  

- Dr.B


Dr. Richard Boulanger

Professor

Electronic Production and Design

Berklee College of Music

Professional Writing & Technology Division



On Sun, Dec 18, 2022 at 3:55 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
Here's a more developed proof of concept of the simple coding environment I have been experimenting with.

The basis of it is the gm.csd code that is an adaptation of Istvan Varga's fluidComplex.csd example in the manual, made to work with sfplay instead.

GMPlay.js is a little library of functions to provide an interface to that code allowing instruments to be played and sequenced. MIDI device input also works directly and alongside it.

What took me a while to crack was to get a solid clock for the sequencer. In the end, I used a combination of Csound scheduling and the AudioContext clock. That allowed me to be independent of the JS timer, but I can still use it to create the time recursion needed for the sequences to be played. Anyway, with what I have now, it is possible to start new sequences on the fly and in sync to the beat.

Here's the quick preview

the system can be extended to have better synths beyond soundfonts, but the idea at the moment is to have a simple coding environment for run-of-the-mill music stuff.

Prof. Victor Lazzarini
Maynooth University
Ireland
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
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

Date2022-12-19 12:16
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] GMPlay.js
JS quasi-timers ;) or lazy-on-a-sunday-afternoon timers.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 19 Dec 2022, at 10:56, Rory Walsh  wrote:
> 
> Yes, that's key. If you use Csound as the main clock you can't go wrong. But this is also an interesting approach. Although I have to admit, I was scratching my head a little once you mentioned JS timers 😂
> 
> On Mon, 19 Dec 2022 at 10:12, Victor Lazzarini  wrote:
> Also, it is important to say that all of this trouble is only required if you are not programing in Csound, but doing everything in JS and *only* firing off inputMessages().
> 
> The simplest way to deal with time is to do all the sequencer programming etc in Csound. Then there is no hassle or need to deal with unreliable clocks.
> 
> This particular proof of concept is to see if Csound can be completely wrapped in JS and only used as a sound engine. All programming in this case is done in JS. The Csound code is just a standard CSD with two instruments (one to intercept midi, the other to run sfplay)
> and nothing else.
> 
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
> 
>> On 19 Dec 2022, at 10:05, Victor Lazzarini  wrote:
>> 
>>  yes, the AudioContext clock is reliable. The issue becomes firing Csound events at a regular interval, which setTimout() can do.
>> 
>> If we use the audio clock to give us a reliable reference, we can fire events at or near the target time, even if setTimeout() is slightly late. That may give an error that is noticeable or not, but the overall pulse keeps going.
>> 
>> That works for the first minute or so, after that setTimeout() becomes really irregular becoming late at times by over 100ms.
>> 
>> The solution then is not to fire events at the time of the call but schedule them ahead, with the time difference between the audio clock and the target time taken in consideration.
>> That way, unless the error is absurdly high, events are scheduled correctly and Csound then takes care of delivering them in time. This also takes care of any minor timing errors and so it sounds much more correct.
>> 
>> Prof. Victor Lazzarini
>> Maynooth University
>> Ireland
>> 
>>> On 19 Dec 2022, at 03:59, Hlöðver Sigurðsson  wrote:
>>> 
>>> 
>>> WARNINGThis 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.
>>> fantastic finding with the audio-context clock. I know it will be useful to many.
>>> 
>>> On Sun, 18 Dec 2022 at 23:02, Dr. Richard Boulanger  wrote:
>>> NICE., and thanks for the cool video demo as you work with it and modify it on the fly.  
>>> 
>>> - Dr.B
>>> 
>>> Dr. Richard Boulanger
>>> Professor
>>> Electronic Production and Design
>>> Berklee College of Music
>>> Professional Writing & Technology Division
>>> 
>>> 
>>> On Sun, Dec 18, 2022 at 3:55 PM Victor Lazzarini  wrote:
>>> Here's a more developed proof of concept of the simple coding environment I have been experimenting with.
>>> 
>>> The basis of it is the gm.csd code that is an adaptation of Istvan Varga's fluidComplex.csd example in the manual, made to work with sfplay instead.
>>> 
>>> GMPlay.js is a little library of functions to provide an interface to that code allowing instruments to be played and sequenced. MIDI device input also works directly and alongside it.
>>> 
>>> What took me a while to crack was to get a solid clock for the sequencer. In the end, I used a combination of Csound scheduling and the AudioContext clock. That allowed me to be independent of the JS timer, but I can still use it to create the time recursion needed for the sequences to be played. Anyway, with what I have now, it is possible to start new sequences on the fly and in sync to the beat.
>>> 
>>> Here's the quick preview
>>> 
>>> 
>>> GMPlay.js preview
>>> youtu.be
>>> 
>>> the system can be extended to have better synths beyond soundfonts, but the idea at the moment is to have a simple coding environment for run-of-the-mill music stuff. 
>>> 
>>> Prof. Victor Lazzarini
>>> Maynooth University
>>> Ireland
>>> 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
> 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