Quantcast

mixing presets

classic Classic list List threaded Threaded
33 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

mixing presets

Diemo Schwarz

Hi all,

as you might have noticed from some anicllary questions, I've been having lots
of fun using and hacking jamoma recently.  I've intensively worked on a preset
mapper and interpolator that can mix between several presets.  (That's why I
havent answered to the thread about MVC started by Theo, yet, but I will!).

To save me from heavy patching and shuffling data around, I implemented the
preset mix inside the hub (code attached if you're overly curious) as method
preset/mix:  "Mix list of pairs of (preset name, mix value) using a ratio (float)."

This works fine, but to be really useful, each parameter would need a weight for
the mix.  My proposal is thus to add a "mix/weight" attribute to each parameter,
defaulting to 1.

Before I go ahead implementing the weights, I'd like to ask if there are any
objections to have this functionality in the hub.  I'd be glad about any
comments and ideas.

Cheers...
                                                                ...Diemo


Here are the added functions:

static void mix_one_preset (t_preset_item *item1, int nmix, float position,
float *val, t_atom *newValue)
{   // we can assume item1 and item2 are the same type if they are the same
parameter (see above)
     if (item1->type == jps_integer) {
        *val += atom_getfloat(&item1->value_list[0]) * position;
        atom_setfloat(&newValue[0], *val);
     } else if (item1->type == jps_decimal) {
        *val += atom_getfloat(&item1->value_list[0]) * position;
        atom_setfloat(&newValue[0], *val);
     } else if (item1->type == jps_boolean) { // bool: mean thresholded to bool
        *val += atom_getlong(&item1->value);
        atom_setlong(&newValue[0], (*val / nmix >= 0.5));
     } else if (item1->type == jps_array || item1->type == gensym("list_int") ||
item1->type == gensym("list_float"))
     {
        for (int i = 0; i < item1->list_size; i++) {
            val[i] += atom_getfloat(&item1->value_list[i]) * position;
            atom_setfloat(&newValue[i], val[i]);
        }
     } else if (item1->type == jps_string) { // symbol: take max coef
        if (position > *val)
        {
            atom_setsym(&newValue[0], atom_getsym(&item1->value));
            *val = position;
        }
     }
}

void mix_presets(t_hub *x, int nmix, t_preset **p, float *position)
{
     presetItemList **itemlist = (presetItemList **) alloca(nmix *
sizeof(presetItemList *));
     presetItemListIterator *iter     = (presetItemListIterator *) alloca(nmix *
sizeof(presetItemListIterator));
     t_preset_item  *item1, *item2;
     float val[LISTSIZE];
     t_atom newValue[LISTSIZE];
     bool found = false;
     int i;

     if (nmix == 0)
        return;

     // initialise iterators (iter[0] is the master for which parameters will be
mixed)
     for (i = 0; i < nmix; i++)
     {
        itemlist[i] = p[i]->item;
         iter[i]     = itemlist[i]->begin();
     }

     for (; iter[0] != itemlist[0]->end(); ++iter[0])
     {
        item1 = *iter[0];

        for (i = 0; i < item1->list_size; i++)
            val[i] = 0; // init all elems when array or list param

        // mix first preset (todo: ensure string is taken)
        mix_one_preset(item1, nmix, position[0], val, newValue);

        for (i = 1; i < nmix; i++)
        {
            found = false;

            if (iter[i] != itemlist[i]->end())
            {
                item2 = *iter[i];

                if (item1->param_name != item2->param_name)
                {   // parameter names don't match -> find the parameter
                    for (iter[i] = itemlist[i]->begin(); iter[i] != itemlist[i]->end();
++iter[i])
                    {
                        item2 = *iter[i];
                        if (item1->param_name != item2->param_name)
                            continue;
                        else
                        {
                            found = true;
                            // if params are out of order we need reset list two to the beginning
[[why?]]
                            iter[i] = itemlist[i]->begin();
                            break;
                        }
                    }
                }
                else
                    found = true;
            }

            // couldn't find parameter, skip it
            if (!found)
            {
                object_error((t_object*) x, "can't find match for parameter %s of preset 0 in
preset %d",
                             item1->param_name->s_name, i);

                iter[i] = itemlist[i]->begin();
                continue; // go to next mix component for this parameter
            }

            mix_one_preset(item2, nmix, position[i], val, newValue);
            ++iter[i]; // advance other preset param iter
        }

        hub_symbol(x, item1->param_name, item1->list_size, &newValue[0]);
     }
}

void hub_preset_mix (t_hub *x, t_symbol *msg, long argc, t_atom *argv)
{
        int nmix = argc / 2, i;
        t_preset **plist  = (t_preset **) alloca(nmix * sizeof(t_preset *));
        float     *mixval = (float *) alloca(nmix * sizeof(float));
        presetList *presetll = x->preset;
        t_symbol *pname;
       
        if (argc != nmix * 2) {
                object_error((t_object*)x, "%s module: preset mix requires a list of pairs of
(preset name, mix value)", x->attr_name);
                return;
        }

        for (i = 0; i < nmix; i++)
        {
            pname  = atom_getsym(argv + i*2);
            mixval[i] = atom_getfloat(argv + i*2 + 1);
            plist[i] = find_preset(presetll, pname);

            if (!plist[i]) {
                object_error((t_object*)x, "can't find preset %s", pname);
                return;
            }
        }
       
         mix_presets(x, nmix, plist, mixval);
}

--
Diemo Schwarz, PhD -- http://diemo.concatenative.net
Real-Time Music Interaction Team -- http://imtr.ircam.fr
IRCAM - Centre Pompidou -- 1, place Igor-Stravinsky, 75004 Paris, France
Phone +33-1-4478-4879 -- Fax +33-1-4478-1540



------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel

jcom.hub.presets.cpp (43K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

Trond Lossius
Administrator
Hi Diemo,

this indeed sounds interesting. I'm thinking that when designing this, it would be useful to be able to mix between more than just two presets. This way we could cater for e.g. the Hipnoscope gui for 2d manouvering of a set of presets, or combine it with MnM for many to many maoppings.

Would the stuff you are suggesting now be extendable or should we do a bit more thinking before implementing so that we could add support for this as well in the same process?

Aaarghh, I fear that I am being tricked into accepting one more jcom.parameter attribute here...

;-)


Cheers,
Trond



On Sep 23, 2010, at 6:58 PM, Diemo Schwarz wrote:

>
> Hi all,
>
> as you might have noticed from some anicllary questions, I've been having lots of fun using and hacking jamoma recently.  I've intensively worked on a preset mapper and interpolator that can mix between several presets.  (That's why I havent answered to the thread about MVC started by Theo, yet, but I will!).
>
> To save me from heavy patching and shuffling data around, I implemented the preset mix inside the hub (code attached if you're overly curious) as method
> preset/mix:  "Mix list of pairs of (preset name, mix value) using a ratio (float)."
>
> This works fine, but to be really useful, each parameter would need a weight for the mix.  My proposal is thus to add a "mix/weight" attribute to each parameter, defaulting to 1.
>
> Before I go ahead implementing the weights, I'd like to ask if there are any objections to have this functionality in the hub.  I'd be glad about any comments and ideas.
>
> Cheers...
> ...Diemo
>
>
> Here are the added functions:
>
> static void mix_one_preset (t_preset_item *item1, int nmix, float position, float *val, t_atom *newValue)
> {   // we can assume item1 and item2 are the same type if they are the same parameter (see above)
>    if (item1->type == jps_integer) {
> *val += atom_getfloat(&item1->value_list[0]) * position;
> atom_setfloat(&newValue[0], *val);
>    } else if (item1->type == jps_decimal) {
> *val += atom_getfloat(&item1->value_list[0]) * position;
> atom_setfloat(&newValue[0], *val);
>    } else if (item1->type == jps_boolean) { // bool: mean thresholded to bool
> *val += atom_getlong(&item1->value);
> atom_setlong(&newValue[0], (*val / nmix >= 0.5));
>    } else if (item1->type == jps_array || item1->type == gensym("list_int") || item1->type == gensym("list_float"))
>    {
> for (int i = 0; i < item1->list_size; i++) {
>    val[i] += atom_getfloat(&item1->value_list[i]) * position;
>    atom_setfloat(&newValue[i], val[i]);
> }
>    } else if (item1->type == jps_string) { // symbol: take max coef
> if (position > *val)
> {
>    atom_setsym(&newValue[0], atom_getsym(&item1->value));
>    *val = position;
> }
>    }
> }
>
> void mix_presets(t_hub *x, int nmix, t_preset **p, float *position)
> {
>    presetItemList **itemlist = (presetItemList **) alloca(nmix * sizeof(presetItemList *));
>    presetItemListIterator *iter     = (presetItemListIterator *) alloca(nmix * sizeof(presetItemListIterator));
>    t_preset_item  *item1, *item2;
>    float val[LISTSIZE];
>    t_atom newValue[LISTSIZE];
>    bool found = false;
>    int i;
>
>    if (nmix == 0)
> return;
>
>    // initialise iterators (iter[0] is the master for which parameters will be mixed)
>    for (i = 0; i < nmix; i++)
>    {
> itemlist[i] = p[i]->item;
>        iter[i]     = itemlist[i]->begin();
>    }
>
>    for (; iter[0] != itemlist[0]->end(); ++iter[0])
>    {
> item1 = *iter[0];
>
> for (i = 0; i < item1->list_size; i++)
>    val[i] = 0; // init all elems when array or list param
>
> // mix first preset (todo: ensure string is taken)
> mix_one_preset(item1, nmix, position[0], val, newValue);
>
> for (i = 1; i < nmix; i++)
> {
>    found = false;
>
>    if (iter[i] != itemlist[i]->end())
>    {
> item2 = *iter[i];
>
> if (item1->param_name != item2->param_name)
> {   // parameter names don't match -> find the parameter
>    for (iter[i] = itemlist[i]->begin(); iter[i] != itemlist[i]->end(); ++iter[i])
>    {
> item2 = *iter[i];
> if (item1->param_name != item2->param_name)
>    continue;
> else
> {
>    found = true;
>    // if params are out of order we need reset list two to the beginning [[why?]]
>    iter[i] = itemlist[i]->begin();
>    break;
> }
>    }
> }
> else
>    found = true;
>    }
>
>    // couldn't find parameter, skip it
>    if (!found)
>    {
> object_error((t_object*) x, "can't find match for parameter %s of preset 0 in preset %d",
>     item1->param_name->s_name, i);
>
> iter[i] = itemlist[i]->begin();
> continue; // go to next mix component for this parameter
>    }
>
>    mix_one_preset(item2, nmix, position[i], val, newValue);
>    ++iter[i]; // advance other preset param iter
> }
>
> hub_symbol(x, item1->param_name, item1->list_size, &newValue[0]);
>    }
> }
>
> void hub_preset_mix (t_hub *x, t_symbol *msg, long argc, t_atom *argv)
> {
> int nmix = argc / 2, i;
> t_preset **plist  = (t_preset **) alloca(nmix * sizeof(t_preset *));
> float     *mixval = (float *) alloca(nmix * sizeof(float));
> presetList *presetll = x->preset;
> t_symbol *pname;
>
> if (argc != nmix * 2) {
> object_error((t_object*)x, "%s module: preset mix requires a list of pairs of (preset name, mix value)", x->attr_name);
> return;
> }
>
> for (i = 0; i < nmix; i++)
> {
>    pname  = atom_getsym(argv + i*2);
>    mixval[i] = atom_getfloat(argv + i*2 + 1);
>    plist[i] = find_preset(presetll, pname);
>
>    if (!plist[i]) {
> object_error((t_object*)x, "can't find preset %s", pname);
> return;
>    }
> }
>
>        mix_presets(x, nmix, plist, mixval);
> }
>
> --
> Diemo Schwarz, PhD -- http://diemo.concatenative.net
> Real-Time Music Interaction Team -- http://imtr.ircam.fr
> IRCAM - Centre Pompidou -- 1, place Igor-Stravinsky, 75004 Paris, France
> Phone +33-1-4478-4879 -- Fax +33-1-4478-1540
>
>
> <jcom.hub.presets.cpp>------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev_______________________________________________
> Jamoma-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jamoma-devel


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

bltzr
In reply to this post by Diemo Schwarz
that sounds like a great contribution !

On 23 Sep 2010, at 18:58, Diemo Schwarz wrote:

>
> Hi all,
>
> as you might have noticed from some anicllary questions, I've been having lots of fun using and hacking jamoma recently.  I've intensively worked on a preset mapper and interpolator that can mix between several presets.  (That's why I havent answered to the thread about MVC started by Theo, yet, but I will!).
>
> To save me from heavy patching and shuffling data around, I implemented the preset mix inside the hub (code attached if you're overly curious) as method
> preset/mix:  "Mix list of pairs of (preset name, mix value) using a ratio (float)."
>
> This works fine, but to be really useful, each parameter would need a weight for the mix.  My proposal is thus to add a "mix/weight" attribute to each parameter, defaulting to 1.
>
> Before I go ahead implementing the weights, I'd like to ask if there are any objections to have this functionality in the hub.  I'd be glad about any comments and ideas.
>
> Cheers...
> ...Diemo
>
>
> Here are the added functions:
>
> static void mix_one_preset (t_preset_item *item1, int nmix, float position, float *val, t_atom *newValue)
> {   // we can assume item1 and item2 are the same type if they are the same parameter (see above)
>    if (item1->type == jps_integer) {
> *val += atom_getfloat(&item1->value_list[0]) * position;
> atom_setfloat(&newValue[0], *val);
>    } else if (item1->type == jps_decimal) {
> *val += atom_getfloat(&item1->value_list[0]) * position;
> atom_setfloat(&newValue[0], *val);
>    } else if (item1->type == jps_boolean) { // bool: mean thresholded to bool
> *val += atom_getlong(&item1->value);
> atom_setlong(&newValue[0], (*val / nmix >= 0.5));
>    } else if (item1->type == jps_array || item1->type == gensym("list_int") || item1->type == gensym("list_float"))
>    {
> for (int i = 0; i < item1->list_size; i++) {
>    val[i] += atom_getfloat(&item1->value_list[i]) * position;
>    atom_setfloat(&newValue[i], val[i]);
> }
>    } else if (item1->type == jps_string) { // symbol: take max coef
> if (position > *val)
> {
>    atom_setsym(&newValue[0], atom_getsym(&item1->value));
>    *val = position;
> }
>    }
> }
>
> void mix_presets(t_hub *x, int nmix, t_preset **p, float *position)
> {
>    presetItemList **itemlist = (presetItemList **) alloca(nmix * sizeof(presetItemList *));
>    presetItemListIterator *iter     = (presetItemListIterator *) alloca(nmix * sizeof(presetItemListIterator));
>    t_preset_item  *item1, *item2;
>    float val[LISTSIZE];
>    t_atom newValue[LISTSIZE];
>    bool found = false;
>    int i;
>
>    if (nmix == 0)
> return;
>
>    // initialise iterators (iter[0] is the master for which parameters will be mixed)
>    for (i = 0; i < nmix; i++)
>    {
> itemlist[i] = p[i]->item;
>        iter[i]     = itemlist[i]->begin();
>    }
>
>    for (; iter[0] != itemlist[0]->end(); ++iter[0])
>    {
> item1 = *iter[0];
>
> for (i = 0; i < item1->list_size; i++)
>    val[i] = 0; // init all elems when array or list param
>
> // mix first preset (todo: ensure string is taken)
> mix_one_preset(item1, nmix, position[0], val, newValue);
>
> for (i = 1; i < nmix; i++)
> {
>    found = false;
>
>    if (iter[i] != itemlist[i]->end())
>    {
> item2 = *iter[i];
>
> if (item1->param_name != item2->param_name)
> {   // parameter names don't match -> find the parameter
>    for (iter[i] = itemlist[i]->begin(); iter[i] != itemlist[i]->end(); ++iter[i])
>    {
> item2 = *iter[i];
> if (item1->param_name != item2->param_name)
>    continue;
> else
> {
>    found = true;
>    // if params are out of order we need reset list two to the beginning [[why?]]
>    iter[i] = itemlist[i]->begin();
>    break;
> }
>    }
> }
> else
>    found = true;
>    }
>
>    // couldn't find parameter, skip it
>    if (!found)
>    {
> object_error((t_object*) x, "can't find match for parameter %s of preset 0 in preset %d",
>     item1->param_name->s_name, i);
>
> iter[i] = itemlist[i]->begin();
> continue; // go to next mix component for this parameter
>    }
>
>    mix_one_preset(item2, nmix, position[i], val, newValue);
>    ++iter[i]; // advance other preset param iter
> }
>
> hub_symbol(x, item1->param_name, item1->list_size, &newValue[0]);
>    }
> }
>
> void hub_preset_mix (t_hub *x, t_symbol *msg, long argc, t_atom *argv)
> {
> int nmix = argc / 2, i;
> t_preset **plist  = (t_preset **) alloca(nmix * sizeof(t_preset *));
> float     *mixval = (float *) alloca(nmix * sizeof(float));
> presetList *presetll = x->preset;
> t_symbol *pname;
>
> if (argc != nmix * 2) {
> object_error((t_object*)x, "%s module: preset mix requires a list of pairs of (preset name, mix value)", x->attr_name);
> return;
> }
>
> for (i = 0; i < nmix; i++)
> {
>    pname  = atom_getsym(argv + i*2);
>    mixval[i] = atom_getfloat(argv + i*2 + 1);
>    plist[i] = find_preset(presetll, pname);
>
>    if (!plist[i]) {
> object_error((t_object*)x, "can't find preset %s", pname);
> return;
>    }
> }
>
>        mix_presets(x, nmix, plist, mixval);
> }
>
> --
> Diemo Schwarz, PhD -- http://diemo.concatenative.net
> Real-Time Music Interaction Team -- http://imtr.ircam.fr
> IRCAM - Centre Pompidou -- 1, place Igor-Stravinsky, 75004 Paris, France
> Phone +33-1-4478-4879 -- Fax +33-1-4478-1540
>
>
> <jcom.hub.presets.cpp>------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev_______________________________________________
> Jamoma-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jamoma-devel

Pascal Baltazar
[hidden email]
http://zkrx.org





------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

bltzr
In reply to this post by Trond Lossius

On 23 Sep 2010, at 19:32, Trond Lossius wrote:

>  it would be useful to be able to mix between more than just two presets


isn't that what this does ?

though, I'm not sure I understand how the mix value works in this perspective...

p

Pascal Baltazar
[hidden email]
http://zkrx.org





------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

Nils Peters
On 10-09-23 2:21 PM, Pascal Baltazar wrote:
>
> On 23 Sep 2010, at 19:32, Trond Lossius wrote:
>
>>   it would be useful to be able to mix between more than just two presets
>
>
> isn't that what this does ?
>
> though, I'm not sure I understand how the mix value works in this perspective...



I recall that Tim developed jcom.snapshot together with his tap.jit.ali%
interpolation engine that can be used to do this kind of things very
elegant.
Can't find this email though....

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

Timothy Place-2
In reply to this post by Trond Lossius
The Hipnoscope idea is a good analogy, but I always envisioned that a
bit differently.

While I think that the preset/interpolate etc. on a single-module
basis is worthwhile, I don't really work like that.  I typically want
to interpolate more globally (across multiple modules).

So for the Hipnoscope module (which I think I made but I'm not sure
where I have it) it works more like the mapper modules -- it takes its
own snapshots of the module states and then interpolates between them
without having to 'meddle' with the internals of the modules at all.

Having said that, I get the impression that what is proposed here is
different.  The Hipnoscope (tap.jit.ali / jcom.snapshot thing) is
weighting the presets, not weighting the parameters.

best,
  Tim


On Thu, Sep 23, 2010 at 12:32 PM, Trond Lossius <[hidden email]> wrote:

> Hi Diemo,
>
> this indeed sounds interesting. I'm thinking that when designing this, it would be useful to be able to mix between more than just two presets. This way we could cater for e.g. the Hipnoscope gui for 2d manouvering of a set of presets, or combine it with MnM for many to many maoppings.
>
> Would the stuff you are suggesting now be extendable or should we do a bit more thinking before implementing so that we could add support for this as well in the same process?
>
> Aaarghh, I fear that I am being tricked into accepting one more jcom.parameter attribute here...
>
> ;-)
>
>
> Cheers,
> Trond
>
>
>
> On Sep 23, 2010, at 6:58 PM, Diemo Schwarz wrote:
>
>>
>> Hi all,
>>
>> as you might have noticed from some anicllary questions, I've been having lots of fun using and hacking jamoma recently.  I've intensively worked on a preset mapper and interpolator that can mix between several presets.  (That's why I havent answered to the thread about MVC started by Theo, yet, but I will!).
>>
>> To save me from heavy patching and shuffling data around, I implemented the preset mix inside the hub (code attached if you're overly curious) as method
>> preset/mix:  "Mix list of pairs of (preset name, mix value) using a ratio (float)."
>>
>> This works fine, but to be really useful, each parameter would need a weight for the mix.  My proposal is thus to add a "mix/weight" attribute to each parameter, defaulting to 1.
>>
>> Before I go ahead implementing the weights, I'd like to ask if there are any objections to have this functionality in the hub.  I'd be glad about any comments and ideas.
>>
>> Cheers...
>>                                                               ...Diemo
>>
>>
>> Here are the added functions:
>>
>> static void mix_one_preset (t_preset_item *item1, int nmix, float position, float *val, t_atom *newValue)
>> {   // we can assume item1 and item2 are the same type if they are the same parameter (see above)
>>    if (item1->type == jps_integer) {
>>       *val += atom_getfloat(&item1->value_list[0]) * position;
>>       atom_setfloat(&newValue[0], *val);
>>    } else if (item1->type == jps_decimal) {
>>       *val += atom_getfloat(&item1->value_list[0]) * position;
>>       atom_setfloat(&newValue[0], *val);
>>    } else if (item1->type == jps_boolean) {   // bool: mean thresholded to bool
>>       *val += atom_getlong(&item1->value);
>>       atom_setlong(&newValue[0], (*val / nmix >= 0.5));
>>    } else if (item1->type == jps_array || item1->type == gensym("list_int") || item1->type == gensym("list_float"))
>>    {
>>       for (int i = 0; i < item1->list_size; i++) {
>>           val[i] += atom_getfloat(&item1->value_list[i]) * position;
>>           atom_setfloat(&newValue[i], val[i]);
>>       }
>>    } else if (item1->type == jps_string) {    // symbol: take max coef
>>       if (position > *val)
>>       {
>>           atom_setsym(&newValue[0], atom_getsym(&item1->value));
>>           *val = position;
>>       }
>>    }
>> }
>>
>> void mix_presets(t_hub *x, int nmix, t_preset **p, float *position)
>> {
>>    presetItemList      **itemlist = (presetItemList **) alloca(nmix * sizeof(presetItemList *));
>>    presetItemListIterator *iter     = (presetItemListIterator *) alloca(nmix * sizeof(presetItemListIterator));
>>    t_preset_item        *item1, *item2;
>>    float val[LISTSIZE];
>>    t_atom newValue[LISTSIZE];
>>    bool found = false;
>>    int i;
>>
>>    if (nmix == 0)
>>       return;
>>
>>    // initialise iterators (iter[0] is the master for which parameters will be mixed)
>>    for (i = 0; i < nmix; i++)
>>    {
>>       itemlist[i] = p[i]->item;
>>        iter[i]     = itemlist[i]->begin();
>>    }
>>
>>    for (; iter[0] != itemlist[0]->end(); ++iter[0])
>>    {
>>       item1 = *iter[0];
>>
>>       for (i = 0; i < item1->list_size; i++)
>>           val[i] = 0; // init all elems when array or list param
>>
>>       // mix first preset (todo: ensure string is taken)
>>       mix_one_preset(item1, nmix, position[0], val, newValue);
>>
>>       for (i = 1; i < nmix; i++)
>>       {
>>           found = false;
>>
>>           if (iter[i] != itemlist[i]->end())
>>           {
>>               item2 = *iter[i];
>>
>>               if (item1->param_name != item2->param_name)
>>               {   // parameter names don't match -> find the parameter
>>                   for (iter[i] = itemlist[i]->begin(); iter[i] != itemlist[i]->end(); ++iter[i])
>>                   {
>>                       item2 = *iter[i];
>>                       if (item1->param_name != item2->param_name)
>>                           continue;
>>                       else
>>                       {
>>                           found = true;
>>                           // if params are out of order we need reset list two to the beginning [[why?]]
>>                           iter[i] = itemlist[i]->begin();
>>                           break;
>>                       }
>>                   }
>>               }
>>               else
>>                   found = true;
>>           }
>>
>>           // couldn't find parameter, skip it
>>           if (!found)
>>           {
>>               object_error((t_object*) x, "can't find match for parameter %s of preset 0 in preset %d",
>>                            item1->param_name->s_name, i);
>>
>>               iter[i] = itemlist[i]->begin();
>>               continue;       // go to next mix component for this parameter
>>           }
>>
>>           mix_one_preset(item2, nmix, position[i], val, newValue);
>>           ++iter[i];  // advance other preset param iter
>>       }
>>
>>       hub_symbol(x, item1->param_name, item1->list_size, &newValue[0]);
>>    }
>> }
>>
>> void hub_preset_mix (t_hub *x, t_symbol *msg, long argc, t_atom *argv)
>> {
>>       int nmix = argc / 2, i;
>>       t_preset **plist  = (t_preset **) alloca(nmix * sizeof(t_preset *));
>>       float     *mixval = (float *) alloca(nmix * sizeof(float));
>>       presetList *presetll = x->preset;
>>       t_symbol *pname;
>>
>>       if (argc != nmix * 2) {
>>               object_error((t_object*)x, "%s module: preset mix requires a list of pairs of (preset name, mix value)", x->attr_name);
>>               return;
>>       }
>>
>>       for (i = 0; i < nmix; i++)
>>       {
>>           pname  = atom_getsym(argv + i*2);
>>           mixval[i] = atom_getfloat(argv + i*2 + 1);
>>           plist[i] = find_preset(presetll, pname);
>>
>>           if (!plist[i]) {
>>               object_error((t_object*)x, "can't find preset %s", pname);
>>               return;
>>           }
>>       }
>>
>>        mix_presets(x, nmix, plist, mixval);
>> }
>>
>> --
>> Diemo Schwarz, PhD -- http://diemo.concatenative.net
>> Real-Time Music Interaction Team -- http://imtr.ircam.fr
>> IRCAM - Centre Pompidou -- 1, place Igor-Stravinsky, 75004 Paris, France
>> Phone +33-1-4478-4879 -- Fax +33-1-4478-1540
>>
>>
>> <jcom.hub.presets.cpp>------------------------------------------------------------------------------
>> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
>> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
>> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
>> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
>> http://p.sf.net/sfu/nokia-dev2dev_______________________________________________
>> Jamoma-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/jamoma-devel
>
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> Jamoma-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jamoma-devel
>

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

bltzr

On 23 Sep 2010, at 20:40, Timothy Place wrote:

> Having said that, I get the impression that what is proposed here is
> different.  The Hipnoscope (tap.jit.ali / jcom.snapshot thing) is
> weighting the presets, not weighting the parameters.

Right, from having seen this system in action in CataRT, I also have this impression.

Though, the "mixing between different presets" thing sounds very similar, and it would be great to have weights there too...

p


Pascal Baltazar
[hidden email]
http://zkrx.org





------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
jln
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

jln
Administrator
In reply to this post by Diemo Schwarz
Hi Diemo and all,

This sounds great. I also guess you mean interpolating between more than two presets, right ? If not, then I am not sure what is the difference between your proposition and the current /preset/interpolate message.

Concerning the mix/weight attribute I wonder a bit whether this should be a jcom.parameter attribute or more a message to jcom.hub. At first thought, given that the weight is only specific to the /preset/mix message I would feel that it should belong to jcom.hub. Could we have a message to jcom.hub to define a list of weight for the various parameters ('/preset/weights param1 0.5 param2 0.5')? Or maybe /preset/mix could expect arguments  a bit like pattrstorage's recallmulti ? I am not sure this would be better, I am just thinking out loud.

I know that Theo made a preset object to deal with... well, presets (nodelib branch). I am not sure if he implemented such a feature yet but maybe does he have an idea ?

Best,
Julien


Le 23 sept. 2010 à 18:58, Diemo Schwarz a écrit :

>
> Hi all,
>
> as you might have noticed from some anicllary questions, I've been having lots of fun using and hacking jamoma recently.  I've intensively worked on a preset mapper and interpolator that can mix between several presets.  (That's why I havent answered to the thread about MVC started by Theo, yet, but I will!).
>
> To save me from heavy patching and shuffling data around, I implemented the preset mix inside the hub (code attached if you're overly curious) as method
> preset/mix:  "Mix list of pairs of (preset name, mix value) using a ratio (float)."
>
> This works fine, but to be really useful, each parameter would need a weight for the mix.  My proposal is thus to add a "mix/weight" attribute to each parameter, defaulting to 1.
>
> Before I go ahead implementing the weights, I'd like to ask if there are any objections to have this functionality in the hub.  I'd be glad about any comments and ideas.
>
> Cheers...
> ...Diemo
>
>
> Here are the added functions:
>
> static void mix_one_preset (t_preset_item *item1, int nmix, float position, float *val, t_atom *newValue)
> {   // we can assume item1 and item2 are the same type if they are the same parameter (see above)
>    if (item1->type == jps_integer) {
> *val += atom_getfloat(&item1->value_list[0]) * position;
> atom_setfloat(&newValue[0], *val);
>    } else if (item1->type == jps_decimal) {
> *val += atom_getfloat(&item1->value_list[0]) * position;
> atom_setfloat(&newValue[0], *val);
>    } else if (item1->type == jps_boolean) { // bool: mean thresholded to bool
> *val += atom_getlong(&item1->value);
> atom_setlong(&newValue[0], (*val / nmix >= 0.5));
>    } else if (item1->type == jps_array || item1->type == gensym("list_int") || item1->type == gensym("list_float"))
>    {
> for (int i = 0; i < item1->list_size; i++) {
>    val[i] += atom_getfloat(&item1->value_list[i]) * position;
>    atom_setfloat(&newValue[i], val[i]);
> }
>    } else if (item1->type == jps_string) { // symbol: take max coef
> if (position > *val)
> {
>    atom_setsym(&newValue[0], atom_getsym(&item1->value));
>    *val = position;
> }
>    }
> }
>
> void mix_presets(t_hub *x, int nmix, t_preset **p, float *position)
> {
>    presetItemList **itemlist = (presetItemList **) alloca(nmix * sizeof(presetItemList *));
>    presetItemListIterator *iter     = (presetItemListIterator *) alloca(nmix * sizeof(presetItemListIterator));
>    t_preset_item  *item1, *item2;
>    float val[LISTSIZE];
>    t_atom newValue[LISTSIZE];
>    bool found = false;
>    int i;
>
>    if (nmix == 0)
> return;
>
>    // initialise iterators (iter[0] is the master for which parameters will be mixed)
>    for (i = 0; i < nmix; i++)
>    {
> itemlist[i] = p[i]->item;
>        iter[i]     = itemlist[i]->begin();
>    }
>
>    for (; iter[0] != itemlist[0]->end(); ++iter[0])
>    {
> item1 = *iter[0];
>
> for (i = 0; i < item1->list_size; i++)
>    val[i] = 0; // init all elems when array or list param
>
> // mix first preset (todo: ensure string is taken)
> mix_one_preset(item1, nmix, position[0], val, newValue);
>
> for (i = 1; i < nmix; i++)
> {
>    found = false;
>
>    if (iter[i] != itemlist[i]->end())
>    {
> item2 = *iter[i];
>
> if (item1->param_name != item2->param_name)
> {   // parameter names don't match -> find the parameter
>    for (iter[i] = itemlist[i]->begin(); iter[i] != itemlist[i]->end(); ++iter[i])
>    {
> item2 = *iter[i];
> if (item1->param_name != item2->param_name)
>    continue;
> else
> {
>    found = true;
>    // if params are out of order we need reset list two to the beginning [[why?]]
>    iter[i] = itemlist[i]->begin();
>    break;
> }
>    }
> }
> else
>    found = true;
>    }
>
>    // couldn't find parameter, skip it
>    if (!found)
>    {
> object_error((t_object*) x, "can't find match for parameter %s of preset 0 in preset %d",
>     item1->param_name->s_name, i);
>
> iter[i] = itemlist[i]->begin();
> continue; // go to next mix component for this parameter
>    }
>
>    mix_one_preset(item2, nmix, position[i], val, newValue);
>    ++iter[i]; // advance other preset param iter
> }
>
> hub_symbol(x, item1->param_name, item1->list_size, &newValue[0]);
>    }
> }
>
> void hub_preset_mix (t_hub *x, t_symbol *msg, long argc, t_atom *argv)
> {
> int nmix = argc / 2, i;
> t_preset **plist  = (t_preset **) alloca(nmix * sizeof(t_preset *));
> float     *mixval = (float *) alloca(nmix * sizeof(float));
> presetList *presetll = x->preset;
> t_symbol *pname;
>
> if (argc != nmix * 2) {
> object_error((t_object*)x, "%s module: preset mix requires a list of pairs of (preset name, mix value)", x->attr_name);
> return;
> }
>
> for (i = 0; i < nmix; i++)
> {
>    pname  = atom_getsym(argv + i*2);
>    mixval[i] = atom_getfloat(argv + i*2 + 1);
>    plist[i] = find_preset(presetll, pname);
>
>    if (!plist[i]) {
> object_error((t_object*)x, "can't find preset %s", pname);
> return;
>    }
> }
>
>        mix_presets(x, nmix, plist, mixval);
> }
>
> --
> Diemo Schwarz, PhD -- http://diemo.concatenative.net
> Real-Time Music Interaction Team -- http://imtr.ircam.fr
> IRCAM - Centre Pompidou -- 1, place Igor-Stravinsky, 75004 Paris, France
> Phone +33-1-4478-4879 -- Fax +33-1-4478-1540
>
>
> <jcom.hub.presets.cpp>------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev_______________________________________________
> Jamoma-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jamoma-devel


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

Diemo Schwarz

Hi, thanks for the discussion so far!  Of course I should have given more
details (obvious only to me, having turned this idea around in my head for weeks):

a preset mix x is a linear combination of the j = 1..m parameter values v_ij of
i = 1..n presets t_i, gouverned by two sets of weights, the parameter weights
*given individually for each preset and each parameter*, w_ij, and the mix
factors per preset f_i.  For result parameter value x_j:

   x_j = \sum_i f_i * w'_ij * p_ij

where w'_ij are the weights of parameter j normalised to sum to one, i.e. \sum_i
w_ij = 1, except if the sum is 0.
The mix factors f_i are not normalised internally.

In my current application, the w_ij are either 0 or 1, allowing to exclude
certain parameters of certain presets from the mix, but of course it could be
generalised to any float between 0 and 1.

My use case for this is an interpolator that sets a "background" preset with all
parameters, and then mixes in only certain parameters from other presets (think
descriptors for CBCS).

Regarding the alternative implementations, if one would want to avoid a new
attribute for the parameter, then one could pose the convention that if
parameter foo/mixweight exists, it is the weight for parameter foo, but that
would involve a lot of searches through the list of parameters in a preset.

In order to do the mix outside of the hub, I'd need to access (and keep up to
date) all preset's parameters, and I didn't find a way to get at them without
actually recalling a preset.

Cheers...
                                                                ...Diemo



On 23.09.10 21:08, Julien Rabin wrote:

> Hi Diemo and all,
>
> This sounds great. I also guess you mean interpolating between more than two
> presets, right ? If not, then I am not sure what is the difference between
> your proposition and the current /preset/interpolate message.
>
> Concerning the mix/weight attribute I wonder a bit whether this should be a
> jcom.parameter attribute or more a message to jcom.hub. At first thought,
> given that the weight is only specific to the /preset/mix message I would
> feel that it should belong to jcom.hub. Could we have a message to jcom.hub
> to define a list of weight for the various parameters ('/preset/weights
> param1 0.5 param2 0.5')? Or maybe /preset/mix could expect arguments  a bit
> like pattrstorage's recallmulti ? I am not sure this would be better, I am
> just thinking out loud.
>
> I know that Theo made a preset object to deal with... well, presets (nodelib
> branch). I am not sure if he implemented such a feature yet but maybe does he
> have an idea ?
>
> Best, Julien
>
>
> Le 23 sept. 2010 à 18:58, Diemo Schwarz a écrit :
>
>>
>> Hi all,
>>
>> as you might have noticed from some anicllary questions, I've been having
>> lots of fun using and hacking jamoma recently.  I've intensively worked on
>> a preset mapper and interpolator that can mix between several presets.
>> (That's why I havent answered to the thread about MVC started by Theo, yet,
>> but I will!).
>>
>> To save me from heavy patching and shuffling data around, I implemented the
>> preset mix inside the hub (code attached if you're overly curious) as
>> method preset/mix:  "Mix list of pairs of (preset name, mix value) using a
>> ratio (float)."
>>
>> This works fine, but to be really useful, each parameter would need a
>> weight for the mix.  My proposal is thus to add a "mix/weight" attribute to
>> each parameter, defaulting to 1.
>>
>> Before I go ahead implementing the weights, I'd like to ask if there are
>> any objections to have this functionality in the hub.  I'd be glad about
>> any comments and ideas.
>>
>> Cheers... ...Diemo
>>
>>
>> Here are the added functions:
>>
>> static void mix_one_preset (t_preset_item *item1, int nmix, float position,
>> float *val, t_atom *newValue) {   // we can assume item1 and item2 are the
>> same type if they are the same parameter (see above) if (item1->type ==
>> jps_integer) { *val += atom_getfloat(&item1->value_list[0]) * position;
>> atom_setfloat(&newValue[0], *val); } else if (item1->type == jps_decimal)
>> { *val += atom_getfloat(&item1->value_list[0]) * position;
>> atom_setfloat(&newValue[0], *val); } else if (item1->type == jps_boolean) {
>> // bool: mean thresholded to bool *val += atom_getlong(&item1->value);
>> atom_setlong(&newValue[0], (*val / nmix>= 0.5)); } else if (item1->type ==
>> jps_array || item1->type == gensym("list_int") || item1->type ==
>> gensym("list_float")) { for (int i = 0; i<  item1->list_size; i++) { val[i]
>> += atom_getfloat(&item1->value_list[i]) * position;
>> atom_setfloat(&newValue[i], val[i]); } } else if (item1->type ==
>> jps_string) { // symbol: take max coef if (position>  *val) {
>> atom_setsym(&newValue[0], atom_getsym(&item1->value)); *val = position; }
>> } }
>>
>> void mix_presets(t_hub *x, int nmix, t_preset **p, float *position) {
>> presetItemList **itemlist = (presetItemList **) alloca(nmix *
>> sizeof(presetItemList *)); presetItemListIterator *iter     =
>> (presetItemListIterator *) alloca(nmix * sizeof(presetItemListIterator));
>> t_preset_item  *item1, *item2; float val[LISTSIZE]; t_atom
>> newValue[LISTSIZE]; bool found = false; int i;
>>
>> if (nmix == 0) return;
>>
>> // initialise iterators (iter[0] is the master for which parameters will be
>> mixed) for (i = 0; i<  nmix; i++) { itemlist[i] = p[i]->item; iter[i]     =
>> itemlist[i]->begin(); }
>>
>> for (; iter[0] != itemlist[0]->end(); ++iter[0]) { item1 = *iter[0];
>>
>> for (i = 0; i<  item1->list_size; i++) val[i] = 0; // init all elems when
>> array or list param
>>
>> // mix first preset (todo: ensure string is taken) mix_one_preset(item1,
>> nmix, position[0], val, newValue);
>>
>> for (i = 1; i<  nmix; i++) { found = false;
>>
>> if (iter[i] != itemlist[i]->end()) { item2 = *iter[i];
>>
>> if (item1->param_name != item2->param_name) {   // parameter names don't
>> match ->  find the parameter for (iter[i] = itemlist[i]->begin(); iter[i]
>> != itemlist[i]->end(); ++iter[i]) { item2 = *iter[i]; if (item1->param_name
>> != item2->param_name) continue; else { found = true; // if params are out
>> of order we need reset list two to the beginning [[why?]] iter[i] =
>> itemlist[i]->begin(); break; } } } else found = true; }
>>
>> // couldn't find parameter, skip it if (!found) { object_error((t_object*)
>> x, "can't find match for parameter %s of preset 0 in preset %d",
>> item1->param_name->s_name, i);
>>
>> iter[i] = itemlist[i]->begin(); continue; // go to next mix component for
>> this parameter }
>>
>> mix_one_preset(item2, nmix, position[i], val, newValue); ++iter[i]; //
>> advance other preset param iter }
>>
>> hub_symbol(x, item1->param_name, item1->list_size,&newValue[0]); } }
>>
>> void hub_preset_mix (t_hub *x, t_symbol *msg, long argc, t_atom *argv) {
>> int nmix = argc / 2, i; t_preset **plist  = (t_preset **) alloca(nmix *
>> sizeof(t_preset *)); float     *mixval = (float *) alloca(nmix *
>> sizeof(float)); presetList *presetll = x->preset; t_symbol *pname;  if
>> (argc != nmix * 2) { object_error((t_object*)x, "%s module: preset mix
>> requires a list of pairs of (preset name, mix value)", x->attr_name);
>> return; }
>>
>> for (i = 0; i<  nmix; i++) { pname  = atom_getsym(argv + i*2); mixval[i] =
>> atom_getfloat(argv + i*2 + 1); plist[i] = find_preset(presetll, pname);
>>
>> if (!plist[i]) { object_error((t_object*)x, "can't find preset %s",
>> pname); return; } }  mix_presets(x, nmix, plist, mixval); }
>>
>> -- Diemo Schwarz, PhD -- http://diemo.concatenative.net Real-Time Music
>> Interaction Team -- http://imtr.ircam.fr IRCAM - Centre Pompidou -- 1,
>> place Igor-Stravinsky, 75004 Paris, France Phone +33-1-4478-4879 -- Fax
>> +33-1-4478-1540
>>
>>
>> <jcom.hub.presets.cpp>------------------------------------------------------------------------------

--
Diemo Schwarz, PhD -- http://diemo.concatenative.net
Real-Time Music Interaction Team -- http://imtr.ircam.fr
IRCAM - Centre Pompidou -- 1, place Igor-Stravinsky, 75004 Paris, France
Phone +33-1-4478-4879 -- Fax +33-1-4478-1540

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

bltzr

On 24 Sep 2010, at 12:24, Diemo Schwarz wrote:

> In order to do the mix outside of the hub, I'd need to access (and keep up to
> date) all preset's parameters, and I didn't find a way to get at them without
> actually recalling a preset.

have you tried to look into jmod.cueManager ?

Pascal Baltazar
[hidden email]
http://zkrx.org





------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

Théo de la Hogue
In reply to this post by Diemo Schwarz
Hi Diemo,
very interesting thread.

I'll try to make a little overview of the TTPreset and
TTPresetManager classes I did on the to-test-pom branch
in order to be sure that the current implementation feets your needs.

A TTPreset is a hash table of Items (an internal class which keeps a  
pointer
to a TTObject and all his selected attributes values). Here it could  
be possible
to add a float member weight to the Item class instead of add a weight  
attribute
to each TTObject we want the state. All TTobject states stored inside  
a TTPreset
will be selected using list.

Of course the main TTObject we want the state would be the TTData  
class (e.g. jcom.parameter/message/return)
but we could also imagine to get the state of a TTMapper class (e.g.  
jcom.map).... it is possible but is it usefull ?

A TTPreset instance is managed by a TTPresetManager class which stores  
all TTPresets in a linked list.
This class is currently wrapped in a new jcom.preset external which  
could added to your model in order to
managed locally his presets. But it would be also possible to use it  
as the jcom.cuemanager if you put it
on the top level patch of your Jamoma patch. (Notice that if you add a  
jcom.preset external to your model
this would automatically adds all /preset/store, /preset/recall, ...  
messages ;-)

It should not be hard to introduce the algorithm you proposed inside  
the TTPresetManager class
and to interpolate TTValue instead of t_atom. The main part is how to  
make a selection allowing users
to include or exclude some TTObjects depending on the value of their  
attributes (e.g. keep only TTData
with @service == parameter).

Notice that the TTPresetManager class directly recalls value to  
TTObject using the NodeLib framework
but it is possible to dump a preset out of the jcom.preset without  
recalling it so maybe this could allows
us to have an interface in order to select/unselect things and maybe  
deals with weights ...

To conclude this overview the TTPresetManager could be handled by  
TTXmlHandler to write or read a .xml file.
The TTXmlHandler calls the writeAsXml or readFromXml methods of the  
TTPresetManager (which calls recursively
the same methods on each TTPresets). This means we would be able to  
store our presets as Xml or as Text line format
or what ever and it would be able to store the state of any TTObject  
inside a file if this TTObject has implemented a writeAsXml
and readFromXml methods.

Finally I'm asking if it would not be better to implement this  
directly inside TTPresetManager class instead of the the jcom.hub
(which would disapear in the future). But I guess you need this  
features quickly so...

Best,
TO


Le 24 sept. 10 à 12:24, Diemo Schwarz a écrit :

>
> Hi, thanks for the discussion so far!  Of course I should have given  
> more
> details (obvious only to me, having turned this idea around in my  
> head for weeks):
>
> a preset mix x is a linear combination of the j = 1..m parameter  
> values v_ij of
> i = 1..n presets t_i, gouverned by two sets of weights, the  
> parameter weights
> *given individually for each preset and each parameter*, w_ij, and  
> the mix
> factors per preset f_i.  For result parameter value x_j:
>
>   x_j = \sum_i f_i * w'_ij * p_ij
>
> where w'_ij are the weights of parameter j normalised to sum to one,  
> i.e. \sum_i
> w_ij = 1, except if the sum is 0.
> The mix factors f_i are not normalised internally.
>
> In my current application, the w_ij are either 0 or 1, allowing to  
> exclude
> certain parameters of certain presets from the mix, but of course it  
> could be
> generalised to any float between 0 and 1.
>
> My use case for this is an interpolator that sets a "background"  
> preset with all
> parameters, and then mixes in only certain parameters from other  
> presets (think
> descriptors for CBCS).
>
> Regarding the alternative implementations, if one would want to  
> avoid a new
> attribute for the parameter, then one could pose the convention that  
> if
> parameter foo/mixweight exists, it is the weight for parameter foo,  
> but that
> would involve a lot of searches through the list of parameters in a  
> preset.
>
> In order to do the mix outside of the hub, I'd need to access (and  
> keep up to
> date) all preset's parameters, and I didn't find a way to get at  
> them without
> actually recalling a preset.
>
> Cheers...
> ...Diemo
>
>
>
> On 23.09.10 21:08, Julien Rabin wrote:
>> Hi Diemo and all,
>>
>> This sounds great. I also guess you mean interpolating between more  
>> than two
>> presets, right ? If not, then I am not sure what is the difference  
>> between
>> your proposition and the current /preset/interpolate message.
>>
>> Concerning the mix/weight attribute I wonder a bit whether this  
>> should be a
>> jcom.parameter attribute or more a message to jcom.hub. At first  
>> thought,
>> given that the weight is only specific to the /preset/mix message I  
>> would
>> feel that it should belong to jcom.hub. Could we have a message to  
>> jcom.hub
>> to define a list of weight for the various parameters ('/preset/
>> weights
>> param1 0.5 param2 0.5')? Or maybe /preset/mix could expect  
>> arguments  a bit
>> like pattrstorage's recallmulti ? I am not sure this would be  
>> better, I am
>> just thinking out loud.
>>
>> I know that Theo made a preset object to deal with... well, presets  
>> (nodelib
>> branch). I am not sure if he implemented such a feature yet but  
>> maybe does he
>> have an idea ?
>>
>> Best, Julien
>>
>>
>> Le 23 sept. 2010 à 18:58, Diemo Schwarz a écrit :
>>
>>>
>>> Hi all,
>>>
>>> as you might have noticed from some anicllary questions, I've been  
>>> having
>>> lots of fun using and hacking jamoma recently.  I've intensively  
>>> worked on
>>> a preset mapper and interpolator that can mix between several  
>>> presets.
>>> (That's why I havent answered to the thread about MVC started by  
>>> Theo, yet,
>>> but I will!).
>>>
>>> To save me from heavy patching and shuffling data around, I  
>>> implemented the
>>> preset mix inside the hub (code attached if you're overly curious)  
>>> as
>>> method preset/mix:  "Mix list of pairs of (preset name, mix value)  
>>> using a
>>> ratio (float)."
>>>
>>> This works fine, but to be really useful, each parameter would  
>>> need a
>>> weight for the mix.  My proposal is thus to add a "mix/weight"  
>>> attribute to
>>> each parameter, defaulting to 1.
>>>
>>> Before I go ahead implementing the weights, I'd like to ask if  
>>> there are
>>> any objections to have this functionality in the hub.  I'd be glad  
>>> about
>>> any comments and ideas.
>>>
>>> Cheers... ...Diemo
>>>
>>>
>>> Here are the added functions:
>>>
>>> static void mix_one_preset (t_preset_item *item1, int nmix, float  
>>> position,
>>> float *val, t_atom *newValue) {   // we can assume item1 and item2  
>>> are the
>>> same type if they are the same parameter (see above) if (item1-
>>> >type ==
>>> jps_integer) { *val += atom_getfloat(&item1->value_list[0]) *  
>>> position;
>>> atom_setfloat(&newValue[0], *val); } else if (item1->type ==  
>>> jps_decimal)
>>> { *val += atom_getfloat(&item1->value_list[0]) * position;
>>> atom_setfloat(&newValue[0], *val); } else if (item1->type ==  
>>> jps_boolean) {
>>> // bool: mean thresholded to bool *val += atom_getlong(&item1-
>>> >value);
>>> atom_setlong(&newValue[0], (*val / nmix>= 0.5)); } else if (item1-
>>> >type ==
>>> jps_array || item1->type == gensym("list_int") || item1->type ==
>>> gensym("list_float")) { for (int i = 0; i<  item1->list_size; i++)  
>>> { val[i]
>>> += atom_getfloat(&item1->value_list[i]) * position;
>>> atom_setfloat(&newValue[i], val[i]); } } else if (item1->type ==
>>> jps_string) { // symbol: take max coef if (position>  *val) {
>>> atom_setsym(&newValue[0], atom_getsym(&item1->value)); *val =  
>>> position; }
>>> } }
>>>
>>> void mix_presets(t_hub *x, int nmix, t_preset **p, float  
>>> *position) {
>>> presetItemList **itemlist = (presetItemList **) alloca(nmix *
>>> sizeof(presetItemList *)); presetItemListIterator *iter     =
>>> (presetItemListIterator *) alloca(nmix *  
>>> sizeof(presetItemListIterator));
>>> t_preset_item  *item1, *item2; float val[LISTSIZE]; t_atom
>>> newValue[LISTSIZE]; bool found = false; int i;
>>>
>>> if (nmix == 0) return;
>>>
>>> // initialise iterators (iter[0] is the master for which  
>>> parameters will be
>>> mixed) for (i = 0; i<  nmix; i++) { itemlist[i] = p[i]->item;  
>>> iter[i]     =
>>> itemlist[i]->begin(); }
>>>
>>> for (; iter[0] != itemlist[0]->end(); ++iter[0]) { item1 = *iter[0];
>>>
>>> for (i = 0; i<  item1->list_size; i++) val[i] = 0; // init all  
>>> elems when
>>> array or list param
>>>
>>> // mix first preset (todo: ensure string is taken)  
>>> mix_one_preset(item1,
>>> nmix, position[0], val, newValue);
>>>
>>> for (i = 1; i<  nmix; i++) { found = false;
>>>
>>> if (iter[i] != itemlist[i]->end()) { item2 = *iter[i];
>>>
>>> if (item1->param_name != item2->param_name) {   // parameter names  
>>> don't
>>> match ->  find the parameter for (iter[i] = itemlist[i]->begin();  
>>> iter[i]
>>> != itemlist[i]->end(); ++iter[i]) { item2 = *iter[i]; if (item1-
>>> >param_name
>>> != item2->param_name) continue; else { found = true; // if params  
>>> are out
>>> of order we need reset list two to the beginning [[why?]] iter[i] =
>>> itemlist[i]->begin(); break; } } } else found = true; }
>>>
>>> // couldn't find parameter, skip it if (!found)  
>>> { object_error((t_object*)
>>> x, "can't find match for parameter %s of preset 0 in preset %d",
>>> item1->param_name->s_name, i);
>>>
>>> iter[i] = itemlist[i]->begin(); continue; // go to next mix  
>>> component for
>>> this parameter }
>>>
>>> mix_one_preset(item2, nmix, position[i], val, newValue); +
>>> +iter[i]; //
>>> advance other preset param iter }
>>>
>>> hub_symbol(x, item1->param_name, item1->list_size,&newValue[0]); } }
>>>
>>> void hub_preset_mix (t_hub *x, t_symbol *msg, long argc, t_atom  
>>> *argv) {
>>> int nmix = argc / 2, i; t_preset **plist  = (t_preset **)  
>>> alloca(nmix *
>>> sizeof(t_preset *)); float     *mixval = (float *) alloca(nmix *
>>> sizeof(float)); presetList *presetll = x->preset; t_symbol  
>>> *pname;  if
>>> (argc != nmix * 2) { object_error((t_object*)x, "%s module: preset  
>>> mix
>>> requires a list of pairs of (preset name, mix value)", x-
>>> >attr_name);
>>> return; }
>>>
>>> for (i = 0; i<  nmix; i++) { pname  = atom_getsym(argv + i*2);  
>>> mixval[i] =
>>> atom_getfloat(argv + i*2 + 1); plist[i] = find_preset(presetll,  
>>> pname);
>>>
>>> if (!plist[i]) { object_error((t_object*)x, "can't find preset %s",
>>> pname); return; } }  mix_presets(x, nmix, plist, mixval); }
>>>
>>> -- Diemo Schwarz, PhD -- http://diemo.concatenative.net Real-Time  
>>> Music
>>> Interaction Team -- http://imtr.ircam.fr IRCAM - Centre Pompidou  
>>> -- 1,
>>> place Igor-Stravinsky, 75004 Paris, France Phone +33-1-4478-4879  
>>> -- Fax
>>> +33-1-4478-1540
>>>
>>>
>>> <
>>> jcom
>>> .hub
>>> .presets
>>> .cpp
>>> >
>>> ------------------------------------------------------------------------------
>
> --
> Diemo Schwarz, PhD -- http://diemo.concatenative.net
> Real-Time Music Interaction Team -- http://imtr.ircam.fr
> IRCAM - Centre Pompidou -- 1, place Igor-Stravinsky, 75004 Paris,  
> France
> Phone +33-1-4478-4879 -- Fax +33-1-4478-1540
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America  
> contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and  
> Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in  
> marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi  
> Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> Jamoma-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jamoma-devel


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

Diemo Schwarz

Hello,

I finished implementing and testing the per-parameter-per-preset weights.  I had
to add the mix/weight attribute also to t_preset_item and declare it in
jamoma.xsd for the preset xml files.

If there are no objections I'll push the changes later.

Théo de la Hogue wrote:
 > Finally I'm asking if it would not be better to implement this
 > directly inside TTPresetManager class instead of the the jcom.hub
 > (which would disapear in the future). But I guess you need this
 > features quickly so...

First of all, thanks a lot to Theo for the thorough explanation of the future
architecture.  Indeed, I need this feature right now for an ANR project, but I
will happily re-implement this at the right place in 0.6.

Cheers...
                                                                ...Diemo


On 24.09.10 18:26, Théo de la Hogue wrote:

> Hi Diemo,
> very interesting thread.
>
> I'll try to make a little overview of the TTPreset and
> TTPresetManager classes I did on the to-test-pom branch
> in order to be sure that the current implementation feets your needs.
>
> A TTPreset is a hash table of Items (an internal class which keeps a
> pointer
> to a TTObject and all his selected attributes values). Here it could
> be possible
> to add a float member weight to the Item class instead of add a weight
> attribute
> to each TTObject we want the state. All TTobject states stored inside
> a TTPreset
> will be selected using list.
>
> Of course the main TTObject we want the state would be the TTData
> class (e.g. jcom.parameter/message/return)
> but we could also imagine to get the state of a TTMapper class (e.g.
> jcom.map).... it is possible but is it usefull ?
>
> A TTPreset instance is managed by a TTPresetManager class which stores
> all TTPresets in a linked list.
> This class is currently wrapped in a new jcom.preset external which
> could added to your model in order to
> managed locally his presets. But it would be also possible to use it
> as the jcom.cuemanager if you put it
> on the top level patch of your Jamoma patch. (Notice that if you add a
> jcom.preset external to your model
> this would automatically adds all /preset/store, /preset/recall, ...
> messages ;-)
>
> It should not be hard to introduce the algorithm you proposed inside
> the TTPresetManager class
> and to interpolate TTValue instead of t_atom. The main part is how to
> make a selection allowing users
> to include or exclude some TTObjects depending on the value of their
> attributes (e.g. keep only TTData
> with @service == parameter).
>
> Notice that the TTPresetManager class directly recalls value to
> TTObject using the NodeLib framework
> but it is possible to dump a preset out of the jcom.preset without
> recalling it so maybe this could allows
> us to have an interface in order to select/unselect things and maybe
> deals with weights ...
>
> To conclude this overview the TTPresetManager could be handled by
> TTXmlHandler to write or read a .xml file.
> The TTXmlHandler calls the writeAsXml or readFromXml methods of the
> TTPresetManager (which calls recursively
> the same methods on each TTPresets). This means we would be able to
> store our presets as Xml or as Text line format
> or what ever and it would be able to store the state of any TTObject
> inside a file if this TTObject has implemented a writeAsXml
> and readFromXml methods.
>
> Finally I'm asking if it would not be better to implement this
> directly inside TTPresetManager class instead of the the jcom.hub
> (which would disapear in the future). But I guess you need this
> features quickly so...
>
> Best,
> TO
>
>
> Le 24 sept. 10 à 12:24, Diemo Schwarz a écrit :
>
>>
>> Hi, thanks for the discussion so far!  Of course I should have given
>> more
>> details (obvious only to me, having turned this idea around in my
>> head for weeks):
>>
>> a preset mix x is a linear combination of the j = 1..m parameter
>> values v_ij of
>> i = 1..n presets t_i, gouverned by two sets of weights, the
>> parameter weights
>> *given individually for each preset and each parameter*, w_ij, and
>> the mix
>> factors per preset f_i.  For result parameter value x_j:
>>
>>    x_j = \sum_i f_i * w'_ij * p_ij
>>
>> where w'_ij are the weights of parameter j normalised to sum to one,
>> i.e. \sum_i
>> w_ij = 1, except if the sum is 0.
>> The mix factors f_i are not normalised internally.
>>
>> In my current application, the w_ij are either 0 or 1, allowing to
>> exclude
>> certain parameters of certain presets from the mix, but of course it
>> could be
>> generalised to any float between 0 and 1.
>>
>> My use case for this is an interpolator that sets a "background"
>> preset with all
>> parameters, and then mixes in only certain parameters from other
>> presets (think
>> descriptors for CBCS).
>>
>> Regarding the alternative implementations, if one would want to
>> avoid a new
>> attribute for the parameter, then one could pose the convention that
>> if
>> parameter foo/mixweight exists, it is the weight for parameter foo,
>> but that
>> would involve a lot of searches through the list of parameters in a
>> preset.
>>
>> In order to do the mix outside of the hub, I'd need to access (and
>> keep up to
>> date) all preset's parameters, and I didn't find a way to get at
>> them without
>> actually recalling a preset.
>>
>> Cheers...
>> ...Diemo
>>
>>
>>
>> On 23.09.10 21:08, Julien Rabin wrote:
>>> Hi Diemo and all,
>>>
>>> This sounds great. I also guess you mean interpolating between more
>>> than two
>>> presets, right ? If not, then I am not sure what is the difference
>>> between
>>> your proposition and the current /preset/interpolate message.
>>>
>>> Concerning the mix/weight attribute I wonder a bit whether this
>>> should be a
>>> jcom.parameter attribute or more a message to jcom.hub. At first
>>> thought,
>>> given that the weight is only specific to the /preset/mix message I
>>> would
>>> feel that it should belong to jcom.hub. Could we have a message to
>>> jcom.hub
>>> to define a list of weight for the various parameters ('/preset/
>>> weights
>>> param1 0.5 param2 0.5')? Or maybe /preset/mix could expect
>>> arguments  a bit
>>> like pattrstorage's recallmulti ? I am not sure this would be
>>> better, I am
>>> just thinking out loud.
>>>
>>> I know that Theo made a preset object to deal with... well, presets
>>> (nodelib
>>> branch). I am not sure if he implemented such a feature yet but
>>> maybe does he
>>> have an idea ?
>>>
>>> Best, Julien
>>>
>>>
>>> Le 23 sept. 2010 à 18:58, Diemo Schwarz a écrit :
>>>
>>>>
>>>> Hi all,
>>>>
>>>> as you might have noticed from some anicllary questions, I've been
>>>> having
>>>> lots of fun using and hacking jamoma recently.  I've intensively
>>>> worked on
>>>> a preset mapper and interpolator that can mix between several
>>>> presets.
>>>> (That's why I havent answered to the thread about MVC started by
>>>> Theo, yet,
>>>> but I will!).
>>>>
>>>> To save me from heavy patching and shuffling data around, I
>>>> implemented the
>>>> preset mix inside the hub (code attached if you're overly curious)
>>>> as
>>>> method preset/mix:  "Mix list of pairs of (preset name, mix value)
>>>> using a
>>>> ratio (float)."
>>>>
>>>> This works fine, but to be really useful, each parameter would
>>>> need a
>>>> weight for the mix.  My proposal is thus to add a "mix/weight"
>>>> attribute to
>>>> each parameter, defaulting to 1.
>>>>
>>>> Before I go ahead implementing the weights, I'd like to ask if
>>>> there are
>>>> any objections to have this functionality in the hub.  I'd be glad
>>>> about
>>>> any comments and ideas.
>>>>
>>>> Cheers... ...Diemo
>>>>
>>>>
>>>> Here are the added functions:

Diemo Schwarz, PhD -- http://diemo.concatenative.net
Real-Time Music Interaction Team -- http://imtr.ircam.fr
IRCAM - Centre Pompidou -- 1, place Igor-Stravinsky, 75004 Paris, France
Phone +33-1-4478-4879 -- Fax +33-1-4478-1540

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

adrian.g
Administrator
Hi Diemo,

I just wanted to thank you for implementing this in Jamoma!! Really useful stuff.

I've been playing around with it and made a little control module for easy interpolation between a matrix of presets (with up to four presets mixed at the time). It can get preset names from a module to which it is connected (with some message routing in between) and automatically assign them to a grid on an XY pad.

jmod.presetmixmixpad

jmod.presetmixpad.zip


Btw. what do you thin of implementing an option to refer to presets according to their number? It would make mixing multiple modules much easier (since we wouldn't have to ask for and store the preset names).

Another thing, do you know if it's possible to edit selected presets from within Max without actually having to load them and change current parameter values in the module (like its possible with pattrstorage with its client and storagewindow)?

Thanks for all!

Adrian
jln
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

jln
Administrator
Hi Adrian and all,

Wow! Is this some king of thelepathy or something ? I was just reading again this thread after realizing that I did not take the time to give a look at this, when you posted your message. Needless to say your module cannot come with a better timing! :-) Thanks for sharing.

Best,
Julien

Le 24 oct. 2010 à 18:55, adrian.g a écrit :

>
> Hi Diemo,
>
> I just wanted to thank you for implementing this in Jamoma!! Really useful
> stuff.
>
> I've been playing around with it and made a little control module for easy
> interpolation between a matrix of presets (with up to four presets mixed at
> the time). It can get preset names from a module to which it is connected
> (with some message routing in between) and automatically assign them to a
> grid on an XY pad.
>
> http://jamoma-forums-mailing-lists.3076123.n2.nabble.com/file/n5668098/%5Bpad%5D_%28presentation%29.jpg 
>
> http://jamoma-forums-mailing-lists.3076123.n2.nabble.com/file/n5668098/jmod.presetmixpad.zip
> jmod.presetmixpad.zip
>
>
> Btw. what do you thin of implementing an option to refer to presets
> according to their number? It would make mixing multiple modules much easier
> (since we wouldn't have to ask for and store the preset names).
>
> Another thing, do you know if it's possible to edit selected presets from
> within Max without actually having to load them and change current parameter
> values in the module (like its possible with pattrstorage with its client
> and storagewindow)?
>
> Thanks for all!
>
> Adrian
> --
> View this message in context: http://jamoma-forums-mailing-lists.3076123.n2.nabble.com/mixing-presets-tp5563868p5668098.html
> Sent from the Jamoma Development mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> Jamoma-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jamoma-devel


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

Nils Peters
In reply to this post by adrian.g
Hi Adrian,

that's a great module!
Thanks for all the work.

I just started to play around with it and I think I've found a bug in
the implementation of the /preset/mix

It seems that /preset/mix doesn't consider the @repetition/allow flag of
a parameter.
For instance, if /delay/max is already set to 10000, every interpolation
of a preset that also has "/delay/max 10000" included will still send
this OSC message to the embedded jalg.
Diemo, is there a way to prevent this?

cheers,

Nils

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

Diemo Schwarz

Hello Adrian, Julien, Nils,

great that you found the mix function useful, you made my day!

I implemented preset/mix following exactly the template of the
preset/interpolate function, so all shortcomings are there by design  =-)

On 24.10.10 18:55, adrian.g wrote:
> Btw. what do you thin of implementing an option to refer to presets
> according to their number? It would make mixing multiple modules much easier
> (since we wouldn't have to ask for and store the preset names).

Yes, this is easy, as it is done this way for preset/recall: an int atom looks
for the number, a symbol for the name.  I just pushed that.

> Another thing, do you know if it's possible to edit selected presets from
> within Max without actually having to load them and change current parameter
> values in the module (like its possible with pattrstorage with its client
> and storagewindow)?

I'm curious about this, too, and also the other way round: how to get a
parameter value from a preset directly, without having to recall it.

On 25.10.10 14:38, Nils Peters wrote:
> It seems that /preset/mix doesn't consider the @repetition/allow flag of
> a parameter.
> For instance, if /delay/max is already set to 10000, every interpolation
> of a preset that also has "/delay/max 10000" included will still send
> this OSC message to the embedded jalg.
> Diemo, is there a way to prevent this?

Again, this works just like preset/interpolate and also preset/recall, calling
hub_symbol.  I suspect the value repetition could have something to do with
numerical precision:
If you do "preset/interpolate 1 2 $1" with a float box, the /delay/max wiggles
between 9999 and 10000!

Maybe this needs to be handled on the parameter side, comparing values after
casting to the parameter's type.

Cheers...
                                                                ...Diemo


--
Diemo Schwarz, PhD -- http://diemo.concatenative.net
Real-Time Music Interaction Team -- http://imtr.ircam.fr
IRCAM - Centre Pompidou -- 1, place Igor-Stravinsky, 75004 Paris, France
Phone +33-1-4478-4879 -- Fax +33-1-4478-1540

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

Diemo Schwarz

I checked further and found that sending delay/max 10000. *always* triggers
output of the parameter!

To fix this, I changed param_list_compare in jcom.parameter.cpp to check
combinations of numeric types, and not claim the lists are different.

I hope that's ok and has no other side-effects...
                                                                ...Diemo

On 25.10.10 16:11, Diemo Schwarz wrote:

> On 25.10.10 14:38, Nils Peters wrote:
>> It seems that /preset/mix doesn't consider the @repetition/allow flag of
>> a parameter.
>> For instance, if /delay/max is already set to 10000, every interpolation
>> of a preset that also has "/delay/max 10000" included will still send
>> this OSC message to the embedded jalg.
>> Diemo, is there a way to prevent this?
>
> Again, this works just like preset/interpolate and also preset/recall, calling
> hub_symbol.  I suspect the value repetition could have something to do with
> numerical precision:
> If you do "preset/interpolate 1 2 $1" with a float box, the /delay/max wiggles
> between 9999 and 10000!
>
> Maybe this needs to be handled on the parameter side, comparing values after
> casting to the parameter's type.
>
> Cheers...
> ...Diemo
>
>

--
Diemo Schwarz, PhD -- http://diemo.concatenative.net
Real-Time Music Interaction Team -- http://imtr.ircam.fr
IRCAM - Centre Pompidou -- 1, place Igor-Stravinsky, 75004 Paris, France
Phone +33-1-4478-4879 -- Fax +33-1-4478-1540

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

Timothy Place-2
Hi Diemo,

I don't think I understand.  If the types of two atoms are different,
aren't the two atoms then different?  Or maybe I just need some coffee
because its still early in my time zone.

Sorry if I'm just easily confused.

best,
  Tim



On Mon, Oct 25, 2010 at 9:34 AM, Diemo Schwarz <[hidden email]> wrote:

>
> I checked further and found that sending delay/max 10000. *always* triggers
> output of the parameter!
>
> To fix this, I changed param_list_compare in jcom.parameter.cpp to check
> combinations of numeric types, and not claim the lists are different.
>
> I hope that's ok and has no other side-effects...
>                                                                ...Diemo
>
> On 25.10.10 16:11, Diemo Schwarz wrote:
>> On 25.10.10 14:38, Nils Peters wrote:
>>> It seems that /preset/mix doesn't consider the @repetition/allow flag of
>>> a parameter.
>>> For instance, if /delay/max is already set to 10000, every interpolation
>>> of a preset that also has "/delay/max 10000" included will still send
>>> this OSC message to the embedded jalg.
>>> Diemo, is there a way to prevent this?
>>
>> Again, this works just like preset/interpolate and also preset/recall, calling
>> hub_symbol.  I suspect the value repetition could have something to do with
>> numerical precision:
>> If you do "preset/interpolate 1 2 $1" with a float box, the /delay/max wiggles
>> between 9999 and 10000!
>>
>> Maybe this needs to be handled on the parameter side, comparing values after
>> casting to the parameter's type.
>>
>> Cheers...
>>                                                               ...Diemo
>>
>>
>
> --
> Diemo Schwarz, PhD -- http://diemo.concatenative.net
> Real-Time Music Interaction Team -- http://imtr.ircam.fr
> IRCAM - Centre Pompidou -- 1, place Igor-Stravinsky, 75004 Paris, France
> Phone +33-1-4478-4879 -- Fax +33-1-4478-1540
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> Jamoma-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jamoma-devel
>

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

Diemo Schwarz

Hi Tim,

good morning!

On 25.10.10 16:41, Timothy Place wrote:
> Hi Diemo,
>
> I don't think I understand.  If the types of two atoms are different,
> aren't the two atoms then different?  Or maybe I just need some coffee
> because its still early in my time zone.

It's just the int/float case that wasn't handled in param_list_compare, where
one can compare the values for equality (in the (rather confined) limits of
32bit float representation of course).
The result of preset/interpolate and preset/mix is float even for int parameters.

But maybe there is a fundamental design principle in Jamoma I'm not aware of, of
keeping int and float strictly separate?

In FTM we try to treat int and float always the same, as few things are more
confusing and frustrating in Max than features that work only with int.

(That said, I just programmed the preset lookup for symbol and int only...)

Hope the coffee was good, cheers...
                                                                ...Diemo


> On Mon, Oct 25, 2010 at 9:34 AM, Diemo Schwarz<[hidden email]>  wrote:
>>
>> I checked further and found that sending delay/max 10000. *always* triggers
>> output of the parameter!
>>
>> To fix this, I changed param_list_compare in jcom.parameter.cpp to check
>> combinations of numeric types, and not claim the lists are different.
>>
>> I hope that's ok and has no other side-effects...
>>                                                                 ...Diemo
>>
>> On 25.10.10 16:11, Diemo Schwarz wrote:
>>> On 25.10.10 14:38, Nils Peters wrote:
>>>> It seems that /preset/mix doesn't consider the @repetition/allow flag of
>>>> a parameter.
>>>> For instance, if /delay/max is already set to 10000, every interpolation
>>>> of a preset that also has "/delay/max 10000" included will still send
>>>> this OSC message to the embedded jalg.
>>>> Diemo, is there a way to prevent this?
>>>
>>> Again, this works just like preset/interpolate and also preset/recall, calling
>>> hub_symbol.  I suspect the value repetition could have something to do with
>>> numerical precision:
>>> If you do "preset/interpolate 1 2 $1" with a float box, the /delay/max wiggles
>>> between 9999 and 10000!
>>>
>>> Maybe this needs to be handled on the parameter side, comparing values after
>>> casting to the parameter's type.
>>>
>>> Cheers...
>>>                                                                ...Diemo

--
Diemo Schwarz, PhD -- http://diemo.concatenative.net
Real-Time Music Interaction Team -- http://imtr.ircam.fr
IRCAM - Centre Pompidou -- 1, place Igor-Stravinsky, 75004 Paris, France
Phone +33-1-4478-4879 -- Fax +33-1-4478-1540

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mixing presets

Timothy Place-2
Thanks for the explanation, Diemo.

What I had in mind when originally writing that code was where the
same message is sent over and over again (like a metro hitting it).
In this case the list won't change.  What you mention sounds sensible.

On the other hand, it gives me the shivers because its possible that
we are relying on the int vs float comparison somewhere and we don't
realize it.  Hopefully that's not the case...

The other thing that concerns me is the possible performance
ramifications, since this code is hit many many many times with
control data flying around.  Once again, though, the majority of the
cases are not lists, so its probably not a huge deal.  I just aware
that in this particular area of Jamoma, small changes can have large
performance implications.

Anyway, thanks again for the explanation, and I think this is all fine!

best,
  Tim


On Mon, Oct 25, 2010 at 10:36 AM, Diemo Schwarz <[hidden email]> wrote:

>
> Hi Tim,
>
> good morning!
>
> On 25.10.10 16:41, Timothy Place wrote:
>> Hi Diemo,
>>
>> I don't think I understand.  If the types of two atoms are different,
>> aren't the two atoms then different?  Or maybe I just need some coffee
>> because its still early in my time zone.
>
> It's just the int/float case that wasn't handled in param_list_compare, where
> one can compare the values for equality (in the (rather confined) limits of
> 32bit float representation of course).
> The result of preset/interpolate and preset/mix is float even for int parameters.
>
> But maybe there is a fundamental design principle in Jamoma I'm not aware of, of
> keeping int and float strictly separate?
>
> In FTM we try to treat int and float always the same, as few things are more
> confusing and frustrating in Max than features that work only with int.
>
> (That said, I just programmed the preset lookup for symbol and int only...)
>
> Hope the coffee was good, cheers...
>                                                                ...Diemo
>
>
>> On Mon, Oct 25, 2010 at 9:34 AM, Diemo Schwarz<[hidden email]>  wrote:
>>>
>>> I checked further and found that sending delay/max 10000. *always* triggers
>>> output of the parameter!
>>>
>>> To fix this, I changed param_list_compare in jcom.parameter.cpp to check
>>> combinations of numeric types, and not claim the lists are different.
>>>
>>> I hope that's ok and has no other side-effects...
>>>                                                                 ...Diemo
>>>
>>> On 25.10.10 16:11, Diemo Schwarz wrote:
>>>> On 25.10.10 14:38, Nils Peters wrote:
>>>>> It seems that /preset/mix doesn't consider the @repetition/allow flag of
>>>>> a parameter.
>>>>> For instance, if /delay/max is already set to 10000, every interpolation
>>>>> of a preset that also has "/delay/max 10000" included will still send
>>>>> this OSC message to the embedded jalg.
>>>>> Diemo, is there a way to prevent this?
>>>>
>>>> Again, this works just like preset/interpolate and also preset/recall, calling
>>>> hub_symbol.  I suspect the value repetition could have something to do with
>>>> numerical precision:
>>>> If you do "preset/interpolate 1 2 $1" with a float box, the /delay/max wiggles
>>>> between 9999 and 10000!
>>>>
>>>> Maybe this needs to be handled on the parameter side, comparing values after
>>>> casting to the parameter's type.
>>>>
>>>> Cheers...
>>>>                                                                ...Diemo
>
> --
> Diemo Schwarz, PhD -- http://diemo.concatenative.net
> Real-Time Music Interaction Team -- http://imtr.ircam.fr
> IRCAM - Centre Pompidou -- 1, place Igor-Stravinsky, 75004 Paris, France
> Phone +33-1-4478-4879 -- Fax +33-1-4478-1540
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> Jamoma-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jamoma-devel
>

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Jamoma-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jamoma-devel
12
Loading...