[chuck-dev] ChucKJS

Casper Schipper casper.schipper at gmail.com
Sat Dec 28 12:02:53 EST 2013


Hello Arve,

I’ve been using ChucK for quite some time, but also started to get an interest for the Web Audio API. I think I agree that having chuck compile in a browser would give a huge boost for the language! It is very powerful to be able to directly share musical programs through the internet, without the receiver having to install or run external software. I do fear however that there is a strong difference between ChucK and the way that Web Audio API is designed not to mention the difference between C++ and JavaScript. ChucK has a way of expressing time that is fundamentally different from any other programming language I know.

Your implementation at first sight seems to me like like quite a thorough port of the complete structure of ChucK, complete with VM etc.. Does that mean that it will be possible to have sample accurate timing in your code execution just like ChucK ? Playing a little bit with JavaScript I’ve noticed that the JavaScript setTimeout clock is very unpredictable and found it to be messy even for a simple drum machine. Of course there are ways of dealing with that by scheduling ahead and using the WebAudio API clock, but that would not work very well with the way ChucK deals with time. But maybe your implementation doesn’t require the clock to be accurate ? I’m very curious to hear what your experience has been!

Anyway what surprised me (shocked is maybe a better word, considering the bad reputation of JavaScript) while playing with the Web Audio API, is that JavaScript is quite interesting as an algorithmic composition scripting language, since it is fundamentally a functional language not that unlike Scheme or Lisp (and some powerful algorithmic musical tools have been built in those like: AC toolbox, Niquist and AthenaCL in Python). Here JavaScript could have an advantage above the more traditional way ChucK deals with types and classes. When using ChucK I found that I almost always wanted to add functionalities to the arrays like iterating, choosing, sorting, mapping functions, lambda functions etc… These are also in the LicK library for ChucK, but I haven’t seen many people use that, I guess because it complicates the syntax a bit*. In JavaScript you get those things from the start (or they are very simple to add). Also it’s easy to change behavior of objects like adding methods dynamically to objects, which is very interesting from the point of view of on the fly programming.

So summing this up, I think there is definitely a need for a good JavaScript library to facilitate the generation of music with the Web Audio API. 
ChucK could be a source of inspiration because it has some very good ideas:
- the => syntax is kind of cute and works well for uGens.
- the native time type and way of dealing with time (.2::second => now) is very powerful.
- the fact that chuck allows 1::sample feedback loops is great!
- the control rate can be anything you need it to be.
- the ability to spork shreds is very handy when dealing with any type of polyphony.
 but also perhaps:
- the timing system might not translate well (or at all) to JavaScript.
- JavaScript functional style programming has it’s own advantages that would be perhaps a waste to overlook when simply putting ChucK into JavaScript.

Anyway keep me posted about your progress, I will closely watch your Github! Perhaps I can be of help concerning ChucK, because I cannot really help you with coffee script I’m afraid, since I don’t know it very well.

Cheers,
Casper

* although I must admit that I think it can’t be done any better than LicK did.




Casper Schipper
casper.schipper at gmail.com
www.casperschipper.nl
+316 52322590

On 27 dec. 2013, at 02:58, chuck-dev-request at lists.cs.princeton.edu wrote:
> Hi guys
> 
> I've begun work on a JavaScript (well, CoffeeScript) implementation of ChucK, ChucKJS, for which I'm seeking feedback from ChucK developers in particular. Web Audio API is used to produce sound. Very little of the language is implemented so far, I've just today finished end-to-end support (including a VM) for playing back a sine tone for a certain interval of time as in the following program:
> 
>     SinOsc sin => dac;
>     2::second => now;
> 
> Even though this may seem minor, I'm pretty happy that this is at all possible just from within the browser :) As explained in the project's README, there is a self-contained example (examples/example1.html) which demonstrates the aforementioned sine wave playback capability.
> 
> What do you guys think, are anyone else interested in being able to run ChucK programs in the browser? Anyone interested in helping out on ChucKJS (like ChucK it's GPL licensed)?
> 
> My motivation for writing ChucKJS is to develop an online development environment for ChucK where one can execute the programs directly in the browser, I figure this will lower the threshold and make the language more fun to work with.
> 
> Merry Christmas,
> Arve

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-dev/attachments/20131228/f1ac5dd0/attachment.html>


More information about the chuck-dev mailing list