Kyma Forum
  Kyma Support
  bug? or user error?

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   bug? or user error?
Phi Curtis
Member
posted 17 August 2006 15:32         Edit/Delete Message   Reply w/Quote
Hi,

If I put this in a field:

|asdf|
asdf := 3.
asdf

I can select it and evaluate it with Command-Y, and I get 3 as expected. If I paste a constant with this expression into the value field of a SoundToGlobalController and then compile the SoundToGlobalController, the resulting fader in the VCS shows 1. If I put the code directly in the value field of the the SoundToGlobalController and compile it, the VCS doesn't appear.

I'm also having problems evaluting this:

|asdf|
asdf := 3.
1 of: #(asdf)

In this case I get a message that asdf is never used (this is using Command-Y - also, I can't close the sound with this script).

Am I doing something fundamentally wrong? (Of course I was trying to do something a little more involved, but discovered this problem when trying to figure out what was wrong with the more complex code...)

thanks,
Phil

IP: Logged

HectorBenard
Member
posted 18 August 2006 03:10         Edit/Delete Message   Reply w/Quote
Hi Phil,

I think the first problem has to do with the range of the Constant, which is -1 to 1. If you wanted to use 3 here you would have to scale it down to that range by dividing by 3, and then multiply it by 3 in the value field of the SoundToGobalController. This will give you the right value on the vcs. Otherwise the constant clips at 1, which is why you were getting that value.

The second one may have to do with the fact that the soundToGlobalController is expecting a time-varying value (though SSC might want to correct me here if I'm wrong). If you want to use a fixed number here you need to do it through the constant Sound. But if you try the following in the value field of STGC it will work on the vcs:

|asdf|
asdf := 3.
asdf * !On

I'm not sure about the last problem with the array, but one thing I noticed is that you are using of: , which is the capytalk expression for referencing arrays. That being the case, you should start counting with 0, not 1. Remember that smalltalk starts counting from 1, but capytalk from 0. That still doesn't solve the problem though, but it's worth pointing out.

I hope this helps.


Cheers,

Hector

[This message has been edited by HectorBenard (edited 18 August 2006).]

IP: Logged

tuscland
Member
posted 18 August 2006 04:00         Edit/Delete Message   Reply w/Quote
Hi,

About the SoundToGlobalController.
As Hector has pointed out, it expects an EventValue, so you can write this in the Value field:

| asdr |
asdr := EventVariable new initialValue: 3.
asdr


Cheers,
Camille

IP: Logged

SSC
Administrator
posted 18 August 2006 08:45         Edit/Delete Message   Reply w/Quote
There is a Smalltalk subtlety here. You can form a *literal* array using the number sign (#) but if you want to use variables in the array, you have to use the full creation method. So if you use:

|asdf|
asdf := 3.
1 of: (Array with: asdf)

it ought to work.

IP: Logged

Phi Curtis
Member
posted 18 August 2006 11:59         Edit/Delete Message   Reply w/Quote
Thanks everybody! I thought I was going crazy.

The last item with the arrays was what was causing the problem with the sound I was building (and is the least embarrasing of the three problems :-)).

IP: Logged

HectorBenard
Member
posted 18 August 2006 12:22         Edit/Delete Message   Reply w/Quote
While on the subject...

If you had to create a long array with variables, is there a more efficient way to specify its elements than using the with: message for every single item? For example, to fill up an array with numbers 1 to 25 you could do the following:

|array|
array := (Array with: 1).
(2 to: 25) do: [ :i | array := array copyWith: i].
array

But how could you do something similar if those 25 values were variables?

IP: Logged

tuscland
Member
posted 18 August 2006 16:33         Edit/Delete Message   Reply w/Quote
Hi Hector,

What about using the collect: message :

code:
| array |

array := (1 to: 8) collect: [:i | EventVariable new initialValue: i].
2 of: array


Is that what you were asking?

IP: Logged

HectorBenard
Member
posted 18 August 2006 17:28         Edit/Delete Message   Reply w/Quote
Hi Cam,

What I want to know is how you could make an array from a set of variables without using the with: message each time. Suppose you had the following:

|a b c d e f g h|

a := 1.
b:= 3.
c:=7.
d := 11.
e := 13.5
f := 27.
g := 33.
h := 18.

If you wanted to put them into an array you couldn't use the number sign method, as SSC mentioned. But if you used Array with: you would have to use a with: message for each item:

Array with: a with: b with: c with: d ... etc.

I've tried using do: and collect: loops, but I can't seem to get it right. I imagine there should be a way to do this algorithmically, right?

As much as I love Kyma, my least favorite feature is that the smalltalk seems to be rather obscure and cumbersome compared to more recent languages like supercollider (which itself comes from smalltalk). I'm not much of a programmer, but somehow I find it much trickier to program in smalltalk than in supercollider or lisp. I don't know if I'm the only one who feels this way. Anybody?

Having said that, I love the unique way that Kyma lets you use a graphical interface right along with scripts and little pieces of code wherever you need them in parameter fields. That definitely makes it worth the occasional frustrations with the smalltalk code! I just wish the smalltalk part was a little more *efficient*.

Anyway, just my little midnight reflection on the subject.

Thanks for your help Cam!

Cheers,

Hector

IP: Logged

SSC
Administrator
posted 19 August 2006 11:14         Edit/Delete Message   Reply w/Quote
What would be the purpose of an Array of local variables? Cam's code makes a lot of sense because it would give you an Array of hot values that you could control from the VCS. But I don't see any purpose to an Array of local variables. (BTW, LISP is one of the oldest programming languages (~1958): http://www-formal.stanford.edu/jmc/history/lisp/lisp.html)

IP: Logged

HectorBenard
Member
posted 19 August 2006 14:27         Edit/Delete Message   Reply w/Quote
I never said LISP was new, did I? I said "some of the more recent languages, like supercollider", and then I said I found it easier to do some of these things in supercollider or lisp. The link you provided doesn't seem to work, but I am well aware of the origins of lisp. I'm not *that* ignorant!

As for the code, it was just a stupid example to illustrate the point. I was just wondering if it can be done. I have some code here from a sound for which I wanted to do something like that:

{| a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13|

a0:= ("Unison" 1 to: 15) collect: [ :i | ((!KeyNumber - 129) / 12.0) twoExp - 1].

a1 := ("16ths of tone" 1 to: 15) collect: [ :i | ((i * 1/8) + (!KeyNumber - 129) / 12.0) twoExp - 1].

a2 := ("1/4 Tones" 1 to: 15) collect: [ :i | ((i * 1/2) + (!KeyNumber - 129) / 12.0) twoExp - 1].

a3:= ("chromatic" 0 to: 15) collect: [ :i | (i + (!KeyNumber - 129) / 12.0) twoExp -1].

a4 := #("Major Tonic Triad" 0 0 4 4 4 7 7 12 12 16 16 19 19 24 24) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1].

a5 := #("minor Tonic Triad" 0 0 3 3 3 7 7 12 12 15 15 19 19 24 24) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1].

a6 := #("Dominant 7th Chord (on Tonic)" 0 0 4 4 7 7 10 10 12 12 16 16 19 19 22) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1].

a7 := #("Major Scale" 0 2 4 5 7 9 11 12 14 16 17 19 21 23 24) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1].

a8 := #("minor Scale" 0 2 3 5 7 8 10 12 14 15 17 19 20 22 24) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1].

a9 := #("Harmonic minor Scale" 0 2 3 5 7 8 11 12 14 15 17 19 20 23 24) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1].

a10 := #("Major, Biased Tonic Triad" 0 0 0 2 4 4 4 5 7 7 7 9 11 12 12) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1].

a11 := #("Major, Biased Subdominant Triad" 0 2 4 5 5 5 7 9 9 9 11 12 12 12 17) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1].

a12 := #("Major, Biased Dominant Triad" -5 0 2 4 5 7 7 7 9 11 11 11 12 14 14) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1].

a13 := #("Whole-Tone Scale" 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1].

(1 to: a1 size) collect: [ :i | !Mode of: (Array with: (a0 at: i) with: (a1 at: i) with: (a2 at: i) with: (a3 at: i) with: (a4 at: i) with: (a5 at: i) with: (a6 at: i) with: (a7 at:i) with: (a8 at: i) with: (a9 at: i) with: (a10 at: i) with: (a11 at: i) with: (a12 at: i) with: (a13 at: i))]}


The last part, where the !Mode of: is used, I was wondering if there would be a more efficient way to write this than using the with: message 14 times.

I get the feeling that sometimes my comments are interpreted rather harshly. I don't mean them like that. I'm just giving my most honest and humble opinion, without any sort of pretension or bad intentions. It really is meant as constructive criticism when I say those things. I really love Kyma and I am very greatful for the wonderful tools that SSC has given us to work with.

IP: Logged

SSC
Administrator
posted 19 August 2006 17:03         Edit/Delete Message   Reply w/Quote
If you don't want to use with:, you could do this:

| arrayOfArrays |
arrayOfArrays := #(
{("Unison" 1 to: 15) collect: [ :i | ((!KeyNumber - 129) / 12.0) twoExp - 1]}

{("16ths of tone" 1 to: 15) collect: [ :i | ((i * 1/8) + (!KeyNumber - 129) / 12.0) twoExp - 1]}

{("1/4 Tones" 1 to: 15) collect: [ :i | ((i * 1/2) + (!KeyNumber - 129) / 12.0) twoExp - 1]}

{("chromatic" 0 to: 15) collect: [ :i | (i + (!KeyNumber - 129) / 12.0) twoExp -1]}

{#("Major Tonic Triad" 0 0 4 4 4 7 7 12 12 16 16 19 19 24 24) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1]}

{#("minor Tonic Triad" 0 0 3 3 3 7 7 12 12 15 15 19 19 24 24) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1]}

{#("Dominant 7th Chord (on Tonic)" 0 0 4 4 7 7 10 10 12 12 16 16 19 19 22) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1]}

{#("Major Scale" 0 2 4 5 7 9 11 12 14 16 17 19 21 23 24) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1]}

{#("minor Scale" 0 2 3 5 7 8 10 12 14 15 17 19 20 22 24) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1]}

{#("Harmonic minor Scale" 0 2 3 5 7 8 11 12 14 15 17 19 20 23 24) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1]}

{#("Major, Biased Tonic Triad" 0 0 0 2 4 4 4 5 7 7 7 9 11 12 12) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1]}

{#("Major, Biased Subdominant Triad" 0 2 4 5 5 5 7 9 9 9 11 12 12 12 17) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1]}

{#("Major, Biased Dominant Triad" -5 0 2 4 5 7 7 7 9 11 11 11 12 14 14) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1]}

{#("Whole-Tone Scale" 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28) collect: [ :i | ((i - 129 + !KeyNumber) / 12.0) twoExp - 1]}
).

(1 to: arrayOfArrays first size) collect: [ :i | !Mode of: (arrayOfArrays collect: [ :anArray | anArray at: i])]

---
(But I think your original using the with: might be clearer)

IP: Logged

tuscland
Member
posted 19 August 2006 18:20         Edit/Delete Message   Reply w/Quote
Hi Hector,

Like Carla, I think you code is as clear as the compact version with arrays of arrays.
Sure, the with: message repetition is a bit messy, but you could use indentation to make it more clearer ; this is actually what SmallTalk programmers do, they use indentation a lot to emphasize on the meaning of their program.

As for another way to write your code, let's face it: even in Lisp, Simula, Cobol or C++ this code would be lenghtly anyway: there is a lot of different statements, like if you had a lot of sentences you could not summary easily because they all have an important meaning.

(A last paragraph, just because I love to talk about programming languages :-) )

About the Lisp being old or new, I just think Carla said this on an informational purpose. The way Smalltalk is implemented in Kyma is absolutely standard ; Capytalk is the only exception. Do you know why Kyma has been lasting for so many years, with patches compatibles all along on many differents platforms (all Windows flavors, Mac OS 9/X, Capybara LS/320/etc)? That's because of the flexibility and cleanliness of Smalltalk. Sure you'd have been able do to something very nice with Lisp, but there is no standard implementation which is mature enough on every platform. Franz's Allegro Lisp and Lispworks are eventually some, but that's another story, they have been exprenciencing many irregularities over the years.
And for SuperCollider :
SC Language combines the object oriented structure of Smalltalk and features from functional programming languages with a C programming language family syntax (taken from Wikipedia). Well let's say that's a kind of flavor Python, which is a widely spreaded language. But SC is not written in its own language, only high level parts of it. Kyma is implemented and runs with the same language, which let's you benefit of a common platform and standardization. Yes Smalltalk's syntax can be cumbersome sometimes, but I think this is worth it!

Cheers,
Cam

IP: Logged

HectorBenard
Member
posted 19 August 2006 19:19         Edit/Delete Message   Reply w/Quote
Hi Cam,

I see your point about compatibility and all, and I agree. With lisp I've only had to deal with MCL, which is of course only for the mac, and even now with the intel switch there have been some serious issues.

I think that one of the reason some of us find it tricky to work with smalltalk is that we simply don't have to use it often enough, as most things you simply do graphically in kyma, and we've never dealt with smalltalk as a general-purpose program on its own. In supercollider you have to use the language to do even the simplest things, so the syntax really becomes second nature. But this is precisely one of the strong point of kyma: it lets you focus more on the music and less on the coding, while still giving you all the options when you need them.

I guess I've gotten a little spoiled with all the nice little convenience methods in supercollider that make it seem like a more friendly version of smalltalk. Maybe my perspective in that sense is only from the surface, from the point of view of the composer that only has to program some times to get something done, but who doesn't have to worry so much about all the other things going on *behind the scenes* that make things possible.

And yes, one of the nicest things about Kyma is its backward compatibility, so you never have to worry about patches not working anymore when there's an update, even a major one. That is definitely not the case with supercollider, where all of a sudden somebody changes something and your code won't work anymore (not to mention having to re-do everything when the major switches happened, as was the case for many people). I guess everything has its pros and cons.

But yes, and as I also said before, I do think it's well worth it in the end.

As for the code itself, thanks SSC! I just wanted to know if there was an obvious alternative to the with: 's that I was missing. Even if the original version is clearer, it always helps to take a look at alternative ways of doing these things, and for me those examples are the best way to learn.

Cheers,

Hector

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply

Contact Us | Symbolic Sound Home

This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.


Ultimate Bulletin Board 5.45c