First time here? Check out the FAQ!
x

Can a Sound's parameter contain more than one triggered CapyTalk expression?

+1 vote
48 views

I suspect the answer to this is "no", but I want to understand how this works.

I've made a sound with the following expression in the "Left" parameter of a mixer to effectively gate the sound.

The intention of this code is that the !Gate1 button would increment a counter. The !Gate2 button would increment another counter and the !Gate button would only produce a sound when both counters are the same. But the !Gate1 and !Gate2 EventVariables don't appear in the VCS.

Why is that? Is it because the value left on the stack is only triggered from the expression "!Gate switchedOn..." so the other two expressions that include "!Gate1" and "!Gate2" are somehow optimised away by the compiler?

 

asked Nov 10 in Capytalk & Smalltalk by alan-jackson (Master) (6,090 points)

2 Answers

+1 vote
 
Best answer

Hi Alan,

Your expression will work if you combine the conditionals into a single Capytalk expression by using commas to create the sequences). In other words, it would look more like this:

(((!Gate switchedOn true: (ev1 eq: ev2) false: (nil)),

((!Gate2 switchedOn true: (ev2 <+ (ev2 + 1)) false: (nil)),

((!Gate1 switchedOn true: (ev1 <+ (ev1 + 1)) false: (nil)))

 

 

answered Nov 10 by ssc (Savant) (80,980 points)
selected Nov 11 by alan-jackson
0 votes

Thanks SCC! This comma thing is awesome. I think I'm starting to understand it. Correct me if I've got this wrong but I think a Sound parameter can only have one CapyTalk expression in it. But that expression can effectively be multiple sub-expressions separated by a comma.

Running with that idea I made a rotating sequencer in the frequency field of a SampleCloud:

The whole sequencer is in the Frequency parameter without any STGCs, just for fun. It cycles through eight note values set by eight faders. When you hit the "rotate" button it moves the starting point of the sequence along one step (you can't see any change in the faders but you can hear it).

What's puzzling me now is how I can replace those eight repetitive lines with some SmallTalk to generate that... but that is a related question.

 

 

Here's the code as text in case you want to copy-and-paste it:

| seqFaders eva rotation |

rotation := EventVariable new initialValue: 0.
eva := EventVariable new size: 8.

seqFaders := (1 to: 8) collect: [:i| !SeqNote suffix: i].

(
    (!Rotate switchedOn
        true: (rotation <+ ((rotation + 1) mod: 8))
        false: (nil)),
    ((eva @< 0) <+ (((0 + rotation) mod: 8) of: seqFaders)),  
    ((eva @< 1) <+ (((1 + rotation) mod: 8) of: seqFaders)),  
    ((eva @< 2) <+ (((2 + rotation) mod: 8) of: seqFaders)),  
    ((eva @< 3) <+ (((3 + rotation) mod: 8) of: seqFaders)),  
    ((eva @< 4) <+ (((4 + rotation) mod: 8) of: seqFaders)),  
    ((eva @< 5) <+ (((5 + rotation) mod: 8) of: seqFaders)),  
    ((eva @< 6) <+ (((6 + rotation) mod: 8) of: seqFaders)),  
    ((eva @< 7) <+ (((7 + rotation) mod: 8) of: seqFaders)),
    (eva @< ((1 bpm: !BPM) countTriggersMod: 8))
) nn

answered Nov 11 by alan-jackson (Master) (6,090 points)
edited Nov 11 by alan-jackson
...