Re: [linux-audio-dev] LADSPA Specs ?

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] LADSPA Specs ?
From: Taybin Rutkin (trutkin_AT_physics.clarku.edu)
Date: Tue May 07 2002 - 16:10:00 EEST


On Tue, 7 May 2002 xavier.moulet_AT_free.fr wrote:

> Idem for presets : this subject has been discussed a lot, but how do we store
> them and where, finally ?

Where? That was never really decided. I think the idea was to have one
under $LADSPA_PATH/presets and that others could be added as well. I
don't know of any programs that do this now.

How? This is from Ardour. It uses the libXML++ library. It's pretty
clear if you look at any existing preset file.

XMLNode *
Plugin::get_state()
{
        XMLNode *root = new XMLNode(state_node_name);
        XMLNode *child;
        gchar buf[16];
                        
        for (guint i = 0; i < port_count(); i++){
                if (LADSPA_IS_PORT_CONTROL(port_descriptors()[i])){
                        child = new XMLNode("port");
                        snprintf(buf, sizeof(buf), "%u", i);
                        child->add_property("port-number", string(buf));
                        snprintf(buf, sizeof(buf), "%+f",
control_data[i]);
                        child->add_property("value", string(buf));
                        root->add_child(child);
                }
        }
        
        return root;
}

int
Plugin::set_state(const XMLNode *node)
{
        XMLNodeList nodes;
        XMLProperty *prop;
        XMLNodeConstIterator iter;
        XMLNode *child;
        const char *port;
        const char *data;
        
        if(node->name() != state_node_name) {
                error << "Bad node send to Plugin::set_state" << endmsg;
                return -1;
        }

        nodes = node->children ("port");

        for(iter = nodes.begin(); iter != nodes.end(); iter++){
                child = *iter;
                prop = child->property("number");
                if(prop){
                        port = prop->value().c_str();
                }else{
                        warning << "LADSPA: bad port number"
                                << endmsg;
                        continue;
                }
                prop = child->property("value");
                if(prop){
                        data = prop->value().c_str();
                }else{
                        warning << "LADSPA: bad port value"
                                << endmsg;
                        continue;
                }
                control_data[atoi(port)] = atof(data);
        }

        return 0;
}


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Thu May 09 2002 - 14:00:40 EEST