electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Supercollider
Changing parameters of stored patterns.
Post new topic   Reply to topic Moderators: v-un-v
Page 1 of 1 [8 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Ataxian



Joined: Mar 03, 2009
Posts: 11
Location: UK

PostPosted: Sun Mar 08, 2009 12:03 pm    Post subject: Changing parameters of stored patterns. Reply with quote  Mark this post and the followings unread

Say I have the following PDef:

Code:


(   
   Pdef
   (
      \Pattern1,
      Pbind
      (      
         \instrument, "bass",
         \midinote, 40,
         \dur, Pseq([0.75, 0.25, 0.25, 0.25, 0.5], inf),      //Infinite Repeat
         \legato, Pseq([0.9, 0.3, 0.3, 0.3, 0.3], 1),
         \amp, 0.5,
         \detune, 0.005
      )
   );
)



Why can't I change the \midinote using this command:

Code:


Pdef(\Pattern1).set(\midinote, 15);



Is there a preferred method for storing a pattern, referring to it by a unique name and changing its parameters?

Thank you.
Back to top
View user's profile Send private message
dewdrop_world



Joined: Aug 28, 2006
Posts: 858
Location: Guangzhou, China
Audio files: 4

PostPosted: Sun Mar 08, 2009 6:37 pm    Post subject: Reply with quote  Mark this post and the followings unread

Pattern proxies.

http://supercollider.svn.sourceforge.net/viewvc/supercollider/trunk/build/Help/Streams-Patterns-Events/A%20Practical%20Guide/PG_Cookbook02_Manipulating_Patterns.html

James

_________________
ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net
Back to top
View user's profile Send private message Visit poster's website AIM Address
Ataxian



Joined: Mar 03, 2009
Posts: 11
Location: UK

PostPosted: Mon Mar 09, 2009 6:49 am    Post subject: Reply with quote  Mark this post and the followings unread

Thanks James, I have read the article and have the following code working perfectly but it only brings another question to mind that I haven't been able to solve.

Here is the working code:


Code:


(
   SynthDef("bass",
   {
      arg freq = 440, gate = 1, amp = 0.5, slideTime = 0.17, ffreq = 1100, width = 0.15,
      detune = 1.005, preamp = 4;
      var sig,
      // --------------------------------------------------
      env = Env.adsr(0.01, 0.3, 0.4, 0.1);   
      freq = Lag.kr(freq, slideTime);
      sig = Mix(VarSaw.ar([freq, freq * detune], 0, width, preamp)).distort * amp
      * EnvGen.kr(env, gate, doneAction: 2);
      sig = LPF.ar(sig, ffreq);
      // --------------------------------------------------
      Out.ar(0, sig ! 2)
   }).load(s);      
)
   
(   
   //Pdefn(\Pattern1).set(\instrument, \midinote, \dur, \legato, \amp, \detune);
   
   // Set Pattern1 environment first with initial values
   Pdefn(\Pattern1).set(\midinote, 40);
   // Need to refer to Pattern1 environment in some way so create a variable = envir
   e = Pdefn(\Pattern1).envir;
   // Define Pattern1
   Pdefn //(key,Pattern)
   (
      \Pattern1,
      {
         arg e;
         Pbind   
         (      
            \instrument, "bass",
            \midinote, e.midinote,
            \dur, Pseq([1.0,1.0,1.0,1.0], inf),      //Infinite Repeat
            \legato, Pseq([0.9, 0.3, 0.3, 0.3, 0.3], 1),
            \amp, 0.5,
            \detune, 0.005
         )
      }
   ).asStream;
   
   p = Pseq([Pdefn(\Pattern1)], inf).play;
)

// Change the midinote via the control environment
Pdefn(\Pattern1).set(\midinote, 60);



The question is this:

How can I set the midinote via the environment so it affects the next note played (next note in the sequence) rather than having to wait for the sequence to finish before the midinote value is updated.

A more on the fly approach would be most welcome.

Thank you.
Back to top
View user's profile Send private message
dewdrop_world



Joined: Aug 28, 2006
Posts: 858
Location: Guangzhou, China
Audio files: 4

PostPosted: Mon Mar 09, 2009 7:28 pm    Post subject: Reply with quote  Mark this post and the followings unread

That's JITLib stuff, which I don't use extensively. Julian Rohrhuber is the main author of JITLib, but he doesn't hang around here, only on the mailing list.

My approach to this problem is outlined here. It's a heavier weight structure than pattern proxies, but it also takes on more responsibilities.

That document is a bit old... since then, I made another syntax possible to change the parameter:

Code:
BP(\cmaj).degree = Pbrown(0, 7, 2, inf);


James

_________________
ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net
Back to top
View user's profile Send private message Visit poster's website AIM Address
Ataxian



Joined: Mar 03, 2009
Posts: 11
Location: UK

PostPosted: Mon Mar 09, 2009 7:49 pm    Post subject: Reply with quote  Mark this post and the followings unread

Link doesn't work...

Using ~out and JITLib doesn't allow for .set commands only replacement of the entire Pattern.

I could do this by resending the entire Pdefn each time one arg in the Pdefn is changed, would this be recommended?
Back to top
View user's profile Send private message
dewdrop_world



Joined: Aug 28, 2006
Posts: 858
Location: Guangzhou, China
Audio files: 4

PostPosted: Tue Mar 10, 2009 7:40 am    Post subject: Reply with quote  Mark this post and the followings unread

Ataxian wrote:
Link doesn't work...

Using ~out and JITLib doesn't allow for .set commands only replacement of the entire Pattern.

I could do this by resending the entire Pdefn each time one arg in the Pdefn is changed, would this be recommended?


The link is working for me...??

http://www.dewdrop-world.net/sc3/tutorials/forums.html?id=6

JITLib is more than NodeProxy (~out = ...). Pdef, Pdefn are all part of JITLib. I only rarely use them so I am not the best person to ask.

What I do know about Pdef etc. is... Pdefn is not meant for "event patterns" (Pbind and cousins). Pdefn should be only for "value patterns."

Code:
// these are value patterns - they generate values to use in Pbind
Pdefn(\degree, Pwhite(0, 7, inf));
Pdefn(\dur, Pwrand(#[0.25, 0.5, 0.75], #[3, 2, 1].normalizeSum, inf));

Pdef(\whitekeys, Pbind(
   \degree, Pdefn(\degree),
   \dur, Pdefn(\dur)
)).play;


Then, to change the degrees:

Code:
Pdefn(\degree, Pseries(2, Prand(#[-1, 1], inf), inf).fold(-4, 11));


I don't know where this .set is coming from. Seems more complicated than necessary.

Anyway, if you have more questions about this, ask Julian on the mailing list. I don't know all the nuances.

James

_________________
ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net
Back to top
View user's profile Send private message Visit poster's website AIM Address
Ataxian



Joined: Mar 03, 2009
Posts: 11
Location: UK

PostPosted: Tue Mar 10, 2009 6:25 pm    Post subject: Reply with quote  Mark this post and the followings unread

After posting to the mailing list Julian came up with the following (in case anyone reading this was interested):

for me it seems to change immediately.

I needed to use store rather than load.

if you write:
\midinote, Pfunc { e.midinote },

this should work out.


As for the website, I'm getting the following:

This is your custom 404 "Not found" Error page. This page is displayed whenever a file that a web browser requests is not found on your website.

If you would like to change this page, edit the file "404.html" in your "www" dir.

Important!!!!

If you use Microsoft Internet Explorer, please read this important article about "404" pages. It will save you a lot of frustration!

Force IE5 to display your 404 and not its own

You may also wish to read this article:

click here for Microsoft Knowledge Base article
Back to top
View user's profile Send private message
dewdrop_world



Joined: Aug 28, 2006
Posts: 858
Location: Guangzhou, China
Audio files: 4

PostPosted: Wed Mar 11, 2009 6:20 am    Post subject: Reply with quote  Mark this post and the followings unread

I don't know what's going on with your web browser -- I'm afraid I can't troubleshoot it because I can't reproduce it. The link works perfectly for me (attached).

Try going to my main site - http://www.dewdrop-world.net - and then navigating to SuperCollider > Intermediate Tutorials (link is in the page body, toward the top) > chucklib intro (menu bar at left).

Question Question

James


tutorial-id6.png
 Description:
 Filesize:  88.64 KB
 Viewed:  666 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

tutorial-id6.png



_________________
ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic Moderators: v-un-v
Page 1 of 1 [8 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Supercollider
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use