[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] A method.chaining idiom for livecoding?



Am 30.12.2018 um 11:58 schrieb tedthetrumpet@xxxxxxxxx:

I'm not a programmer, so probably something fundamentally wrong with this… just an idea…

Not at all wrong, and: programming is mainly about saving typing !



Am 30.12.2018 um 12:31 schrieb info@xxxxxxxxxxxxxxxx:

Here's a simple example of how you could add such a method to ArrayedCollection. Put this in a class file (.sc) in your extensions directory.

+ ArrayedCollection {
    seq {|repeats=inf, offset=0|
        ^Pseq(this, repeats, offset);
    }
}


I second the idea. It's very easy to do, many people are using such personal wrappers.
One thing to take care of is the naming convention: as e.g. 'rand' is already taken for arrays
you wouldn't want to override the core method.
So it would look more natural to me to name the methods 'pseq', 'prand' etc.

Also +1 for the default repeats = inf in such case.

My PLx list patterns all default to repeats = inf.
miSCellaneous_lib contains several shortcuts for patterns, e.g. EventShortcuts which lets you customize
abbreviations for keys, by default e.g.  'n' means 'note', 'd' means 'dur' etc.
 
EventShortcuts.on

// PLbindef is also a wrapper for shorter replacement syntax

PLbindef(\x, \n, Pwhite(0, 10), \d, 0.2).play
~x.n = PLseq((0..5))

~x.n = PLrand((0..5))


// with pattern methods defined you could write

~x.n = (5..0).pseq
~x.n = (5..0).prand


BTW, already there are already some more core Patterns, where methods exist, 
resp. the methods are more commonly used than the syntax with Pattern objects, e.g. Pcollect

Regards

Daniel

----------------------------------------------------
http://daniel-mayer.at/software_en.htm
----------------------------------------------------