Writing Efficient Code

View: New views
8 Messages — Rating Filter:   Alert me  

Writing Efficient Code

by surgesg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I've been trying to optimize some code I'm working on, and I think it'd be great to have a help file / tutorial on writing efficient synthesis code. I'm wondering if people would share strategies and techniques for efficiency. I'd be glad to compile a help file out of the suggestions.

Thanks,

- gs

Re: Writing Efficient Code

by Dan Stowell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi -

It depends on what exactly you're working on but this might help:
http://swiki.hfbk-hamburg.de/MusicTechnology/867

It contains languagey tips, not synth tips

Dan

2009/4/24, surgesg <surgesg@...>:

>
>  Hi,
>
>  I've been trying to optimize some code I'm working on, and I think it'd be
>  great to have a help file / tutorial on writing efficient synthesis code.
>  I'm wondering if people would share strategies and techniques for
>  efficiency. I'd be glad to compile a help file out of the suggestions.
>
>  Thanks,
>
>  - gs
>  --
>  View this message in context: http://www.nabble.com/Writing-Efficient-Code-tp23218503p23218503.html
>  Sent from the Supercollider - User mailing list archive at Nabble.com.
>
>
>  _______________________________________________
>  sc-users mailing list
>
>  info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
>  archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
>  search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
>


--
http://www.mcld.co.uk

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Writing Efficient Code

by surgesg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Personally, I'm looking for help with the Synth side of things, but language tips are always helpful too.

Thanks -

Dan Stowell wrote:
Hi -

It depends on what exactly you're working on but this might help:
http://swiki.hfbk-hamburg.de/MusicTechnology/867

It contains languagey tips, not synth tips

Dan

2009/4/24, surgesg <surgesg@gmail.com>:
>
>  Hi,
>
>  I've been trying to optimize some code I'm working on, and I think it'd be
>  great to have a help file / tutorial on writing efficient synthesis code.
>  I'm wondering if people would share strategies and techniques for
>  efficiency. I'd be glad to compile a help file out of the suggestions.
>
>  Thanks,
>
>  - gs
>  --
>  View this message in context: http://www.nabble.com/Writing-Efficient-Code-tp23218503p23218503.html
>  Sent from the Supercollider - User mailing list archive at Nabble.com.
>
>
>  _______________________________________________
>  sc-users mailing list
>
>  info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
>  archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
>  search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
>


--
http://www.mcld.co.uk

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Writing Efficient Code

by kernel-12 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

 From my experience most if not all the basic UGens in SC are very  
efficient so I suppose it comes down to how you use them - things like  
running a group of synths through a single effect/filter process  
instead of spawning the effect with each SynthDef.

What code are you trying to optimize?  The obvious tip is to use .kr  
UGens instead of .ar UGens where possible but maybe you trade some  
sound quality or maybe it isn't practical or makes little difference  
in some situations.

Other tips include not running your server at 192KHz with 16 sample  
block sizes :)  Of course the best joke of all is to suggest buying a  
new computer but you may just end up with more cores which just  
complicates things and isn't very funny.

Good luck,
kernel

On 24 Apr 2009, at 09:26, surgesg wrote:

>
> Personally, I'm looking for help with the Synth side of things, but  
> language
> tips are always helpful too.
>
> Thanks -
>
>
> Dan Stowell wrote:
>>
>> Hi -
>>
>> It depends on what exactly you're working on but this might help:
>> http://swiki.hfbk-hamburg.de/MusicTechnology/867
>>
>> It contains languagey tips, not synth tips
>>
>> Dan
>>
>> 2009/4/24, surgesg <surgesg@...>:
>>>
>>> Hi,
>>>
>>> I've been trying to optimize some code I'm working on, and I think  
>>> it'd
>>> be
>>> great to have a help file / tutorial on writing efficient synthesis
>>> code.
>>> I'm wondering if people would share strategies and techniques for
>>> efficiency. I'd be glad to compile a help file out of the  
>>> suggestions.
>>>
>>> Thanks,
>>>
>>> - gs
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Writing-Efficient-Code- 
>>> tp23218503p23218503.html
>>> Sent from the Supercollider - User mailing list archive at  
>>> Nabble.com.
>>>
>>>
>>> _______________________________________________
>>> sc-users mailing list
>>>
>>> info (subscription, etc.):
>>> http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
>>> archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
>>> search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
>>>
>>
>>
>> --
>> http://www.mcld.co.uk
>>
>> _______________________________________________
>> sc-users mailing list
>>
>> info (subscription, etc.):
>> http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
>> archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
>> search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Writing-Efficient-Code-tp23218503p23218759.html
> Sent from the Supercollider - User mailing list archive at Nabble.com.
>
>
> _______________________________________________
> sc-users mailing list
>
> info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
> archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
> search: http://www.listarc.bham.ac.uk/lists/sc-users/search/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Writing Efficient Code

by Josh Parmenter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

One of my big optimizations is to see what kinds of things (controls  
or even audio) that can be re-used by many synths. If it can, become  
familiar with busses and routing. If you are using 10 reverbs with the  
same settings, see if you can create one reverb and send your 10  
synths to it (for instance).

Best,

Josh

On Apr 24, 2009, at 1:35 PM, kernel wrote:

> Hello,
>
> From my experience most if not all the basic UGens in SC are very  
> efficient so I suppose it comes down to how you use them - things  
> like running a group of synths through a single effect/filter  
> process instead of spawning the effect with each SynthDef.
>
> What code are you trying to optimize?  The obvious tip is to use .kr  
> UGens instead of .ar UGens where possible but maybe you trade some  
> sound quality or maybe it isn't practical or makes little difference  
> in some situations.
>
> Other tips include not running your server at 192KHz with 16 sample  
> block sizes :)  Of course the best joke of all is to suggest buying  
> a new computer but you may just end up with more cores which just  
> complicates things and isn't very funny.
>
> Good luck,
> kernel
>
> On 24 Apr 2009, at 09:26, surgesg wrote:
>
>>
>> Personally, I'm looking for help with the Synth side of things, but  
>> language
>> tips are always helpful too.
>>
>> Thanks -
>>
>>
>> Dan Stowell wrote:
>>>
>>> Hi -
>>>
>>> It depends on what exactly you're working on but this might help:
>>> http://swiki.hfbk-hamburg.de/MusicTechnology/867
>>>
>>> It contains languagey tips, not synth tips
>>>
>>> Dan
>>>
>>> 2009/4/24, surgesg <surgesg@...>:
>>>>
>>>> Hi,
>>>>
>>>> I've been trying to optimize some code I'm working on, and I  
>>>> think it'd
>>>> be
>>>> great to have a help file / tutorial on writing efficient synthesis
>>>> code.
>>>> I'm wondering if people would share strategies and techniques for
>>>> efficiency. I'd be glad to compile a help file out of the  
>>>> suggestions.
>>>>
>>>> Thanks,
>>>>
>>>> - gs
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Writing-Efficient-Code-tp23218503p23218503.html
>>>> Sent from the Supercollider - User mailing list archive at  
>>>> Nabble.com.
>>>>
>>>>
>>>> _______________________________________________
>>>> sc-users mailing list
>>>>
>>>> info (subscription, etc.):
>>>> http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
>>>> archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
>>>> search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
>>>>
>>>
>>>
>>> --
>>> http://www.mcld.co.uk
>>>
>>> _______________________________________________
>>> sc-users mailing list
>>>
>>> info (subscription, etc.):
>>> http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
>>> archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
>>> search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
>>>
>>>
>>
>> --
>> View this message in context: http://www.nabble.com/Writing-Efficient-Code-tp23218503p23218759.html
>> Sent from the Supercollider - User mailing list archive at  
>> Nabble.com.
>>
>>
>> _______________________________________________
>> sc-users mailing list
>>
>> info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
>> archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
>> search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
>
>
> _______________________________________________
> sc-users mailing list
>
> info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
> archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
> search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

******************************************
/* Joshua D. Parmenter
http://www.realizedsound.net/josh/

“Every composer – at all times and in all cases – gives his own  
interpretation of how modern society is structured: whether actively  
or passively, consciously or unconsciously, he makes choices in this  
regard. He may be conservative or he may subject himself to continual  
renewal; or he may strive for a revolutionary, historical or social  
palingenesis." - Luigi Nono
*/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Writing Efficient Code

by andrea valle-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It's trivial, but...

I always prefer to create synths on the fly and deallocate them with doneAction:2 (the other concept of synth, not as an instrument but as an event).
But if you have high densities of synths while scheduling, you gain a bunch by allocating once all the synths, and retriggering/setting them.

Best

-a-


On 24 Apr 2009, at 22:55, Josh Parmenter wrote:

One of my big optimizations is to see what kinds of things (controls or even audio) that can be re-used by many synths. If it can, become familiar with busses and routing. If you are using 10 reverbs with the same settings, see if you can create one reverb and send your 10 synths to it (for instance).

Best,

Josh

On Apr 24, 2009, at 1:35 PM, kernel wrote:

Hello,

From my experience most if not all the basic UGens in SC are very efficient so I suppose it comes down to how you use them - things like running a group of synths through a single effect/filter process instead of spawning the effect with each SynthDef.

What code are you trying to optimize?  The obvious tip is to use .kr UGens instead of .ar UGens where possible but maybe you trade some sound quality or maybe it isn't practical or makes little difference in some situations.

Other tips include not running your server at 192KHz with 16 sample block sizes :)  Of course the best joke of all is to suggest buying a new computer but you may just end up with more cores which just complicates things and isn't very funny.

Good luck,
kernel

On 24 Apr 2009, at 09:26, surgesg wrote:


Personally, I'm looking for help with the Synth side of things, but language
tips are always helpful too.

Thanks -


Dan Stowell wrote:

Hi -

It depends on what exactly you're working on but this might help:

It contains languagey tips, not synth tips

Dan

2009/4/24, surgesg <surgesg@...>:

Hi,

I've been trying to optimize some code I'm working on, and I think it'd
be
great to have a help file / tutorial on writing efficient synthesis
code.
I'm wondering if people would share strategies and techniques for
efficiency. I'd be glad to compile a help file out of the suggestions.

Thanks,

- gs
--
View this message in context:
Sent from the Supercollider - User mailing list archive at Nabble.com.


_______________________________________________
sc-users mailing list

info (subscription, etc.):



-- 

_______________________________________________
sc-users mailing list

info (subscription, etc.):



-- 
Sent from the Supercollider - User mailing list archive at Nabble.com.


_______________________________________________
sc-users mailing list



_______________________________________________
sc-users mailing list


******************************************
/* Joshua D. Parmenter

“Every composer – at all times and in all cases – gives his own interpretation of how modern society is structured: whether actively or passively, consciously or unconsciously, he makes choices in this regard. He may be conservative or he may subject himself to continual renewal; or he may strive for a revolutionary, historical or social palingenesis." - Luigi Nono
*/


_______________________________________________
sc-users mailing list


--------------------------------------------------
Andrea Valle
--------------------------------------------------
CIRMA - DAMS
Università degli Studi di Torino
--------------------------------------------------
" This is a very complicated case, Maude. You know, a lotta ins, a lotta outs, a lotta what-have-yous." 
(Jeffrey 'The Dude' Lebowski)


Re: Writing Efficient Code

by James Harkins-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Be aware, when creating parallel UGens with loops, of units that are
doing the same thing. Those could be created outside the loop and
shared across all the downstream units.

// inefficient: 5 SinOscs that will produce the exact same signal

SynthDef(\chainedDelays, { |delayFreq = 0.15, delayCtr = 0.05,
delayMod = 0.03, out = 0|
        var sig = In.ar(out, 2),
                new = sig;
        5.do {
                new = DelayL.ar(new, 0.1, SinOsc.kr(delayFreq, 0, delayMod, delayCtr));
        };
        Out.ar(out, sig);
});

// better:

SynthDef(\chainedDelays, { |delayFreq = 0.15, delayCtr = 0.05,
delayMod = 0.03, out = 0|
        var sig = In.ar(out, 2),
                delayTime = SinOsc.kr(delayFreq, 0, delayMod, delayCtr),
                new = sig;
        5.do {
                new = DelayL.ar(new, 0.1, delayTime);
        };
        Out.ar(out, sig);
});

This kind of inefficiency is really easy to overlook.
James

PS Am I the only person who trims old replies from the e-mail? Some
messages get really huge just because of quoted material that doesn't
add anything to the discussion. (Speaking of efficiency...!)


--
James Harkins /// dewdrop world
jamshark70@...
http://www.dewdrop-world.net

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: Writing Efficient Emails

by kernel-12 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> PS Am I the only person who trims old replies from the e-mail? Some
> messages get really huge just because of quoted material that doesn't
> add anything to the discussion. (Speaking of efficiency...!)

Sometimes I'm a trimmer but if you read a mailing list from a forum or  
from the archives I find it is easier if the post includes a bit of  
history.  So there we go, you optimize here but you lose somewhere  
else, perhaps :)

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/