Asterisk in front of array

In the docs for HLayout I came across an asterisk in front of an array.

(
w = Window().front;
a = { Button(w) } ! 10;
w.layout = HLayout(*a);
);

Can anybody tell me what the asterisk means in this context?

1 Like

It’s mentioned in Symbolic Notations help but not explained very well.

Basically it’s a shorter syntax for performListObject | SuperCollider 3.12.0 Help

hjh

1 Like

I see, thanks! It’s not widely used in the documentation, actually I don’t think I’ve seen it outside of the HLayout documentation. But I guess it makes sense as the layout objects are one of the only objects in SC that takes n arguments instead of an array as argument.

mySynth.set(\freq, 440, \pan, -0.6, \amp, 0.2);

mySynth.set(*[\freq, 440, \pan, -0.6, \amp, 0.2]);

Pbind is another, as is sendBundle. It may be more common than you think.

hjh

Ah yes, very interesting, never thought of that usage! It looks very convenient!

It may be more common than you think

I noticed the example at the top of Dictionary for Dictionary.with … & I’m hooked.

A quick example:

Hardware specifications for “system exclusive” messages (sort of like command codes instilled in the firmware level of the hardware) always involve a specific 8-bit Integer header and footer that is exactly the same for every message you want to send to it… the only changes are made to the varying types of command messages in between the header & footer specs.

I find the cleanest way is to do it like this… where:

| ...msg| // is collected as one msg array & can be as long as you want


~sysex = 
{
    |...msg| 

    ~send.sysex(Int8Array.with(-16, 4, 6, 13, 21, * msg putLast: -9 ) 
}

Note that you can’t: , * msg , 9 // comma causes failure

Instead you have to: , * msg ++ 9 // valid

The message must either finish with * etc, or have a method attached to the end.

1 Like

This looks very useful as well! I didn’t know about .with either.

.with creates a Collection via:

Set.with(8, 9, 7, 10, 13, 11)

IdentitySet.with(\etc)

OrderedIdentitySet.with( * (..10) )

It’s a class method, so when

~object.isKindOf(Collection)

then this will always be:

~object.class.respondsTo(\with) // -> true

There’s one offset exception I’m aware of … for Array2D , 'with' happens to double as an instance method.

((
	~scale = 
	
	(
		Array2D 
		
		( 
			7 , 7 
		) 
		
		.with 
		
		( 
			(
				( 
					1, (1+7) .. (1+ ( 7.squared -7 ))  
				) 
				
				+.x 
				
				(
					.. (7-1)
				) 
			)
			
			
			.collect
			
			{ 
				|x|	Scale.ionian.degreeToFreq // choose ( Scale , 7 ) 
				(			
					degree: x
					
					, rootFreq: 432 
					
					, octave: -4	
				)
			}
		)
	)
))

; 

~scale [ 0 , 0 ] // octave , note

;

~scale [ 6 , 6 ] // end frequency

;

~scale.array.printAll.size