[clam-devel] Full interactive python instrospection over a dummy processing definition

Xavier Serra xvr.serra at gmail.com
Wed Nov 17 08:28:10 PST 2010


Hi guys,
as you know I'm doing this extension of Network Editor and David suggested me
to let you know how it's going.

We started to create the API by developing Python modules that work with dummy
data. Once we finish this stage we will wrap this structures under an object with
the same interface as the C++ module that will call CLAM functions.

So far, we have developed the Processing part of the API in Python. I'll attach the
files here for those of you that want to try it. To see a preview of things to come, download
all the files in the same directory, launch ipython and from there do:
from Processing import Processing
p = Processing("AudioSource")
and then you have a processing created. If you type p.<tab> ipython will list for you all
the attributes that you can see or modify.

This are the functions supported:
	p = Processing("ProcessingType") #For now, only accepted parameter is AudioSource
	ports = proc._outports  # connections is an iterable
	ports = proc._inports  # connections is an iterable
	controls = proc._outcontrols  # connections is an iterable
	controls = proc._incontrols  # connections is an iterable
	proc.ConfigField = newvalue
	proc["ConfigField"] = newvalue
	proc._config["ConfigField"] = newvalue
	proc._config.ConfigField = newvalue
	proc.Output
	proc['Output']
	proc._outports['Output']
	proc._outports.Output
	proc._outports[4] # Zero based to be consistent with python indexing
	proc._outports[1:4] #To get outport from 1 to 4 excluded
	proc.Output.type  # Returns a string
	proc.Output.name
	proc.Output.index

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Configuration.py
Type: text/x-python-script
Size: 2886 bytes
Desc: not available
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20101117/acf0a0aa/attachment-0020.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Connector.py
Type: text/x-python-script
Size: 3287 bytes
Desc: not available
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20101117/acf0a0aa/attachment-0021.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Connectors.py
Type: text/x-python-script
Size: 2803 bytes
Desc: not available
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20101117/acf0a0aa/attachment-0022.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Processing.py
Type: text/x-python-script
Size: 4883 bytes
Desc: not available
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20101117/acf0a0aa/attachment-0023.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: runTest.py
Type: text/x-python-script
Size: 182 bytes
Desc: not available
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20101117/acf0a0aa/attachment-0024.bin>
-------------- next part --------------


On Nov 3, 2010, at 7:22 PM, David Garc?a Garz?n wrote:

> On Monday 25 October 2010 00:01:23 Xavier Serra wrote:
>> Hi guys,
>> the next part of my project is to integrate a console in Network Editor
>> that will allow manipulation (and creation) of networks interactively
>> through commands. Before starting to code the console I need to decide how
>> will the API be so I'm sending here a first proposal to see what you guys
>> think (this is mostly for David, but anyone is welcome to say his thing)
>> 
>> Another cool thing we talked about was tab completion, like bash and
>> ipython. I tried to show how this function worked in the API example but
>> it complicated the whole thing, so I removed it.
>> 
>> Bye!
> 
> Follows the resulting python interface after a meeting with Xavi, Natanael and 
> me. I included last minute not agreed changes for discusion, namely: 
> port/control.peers, proc.configured flag, the '>' connection among 
> processings, and the interfaces with "implicit network??".
> 
> - General controls
> 	# with an implicit network would be free functions.
> 	network.load("filename.clamnetwork")
> 	network.import("<Network> .... </Network>")
> 	network.save()
> 	network.save("filename")
> 
> - Transport
> 	# with an implicit network would be free functions.
> 	network.play()
> 	network.stop()
> 	network.pause()
> 	network.isStopped()
> 	network.isPlaying()
> 	network.isReady()
> 	network.whyIsNotReady # TOREVIEW
> 
> - Processings
> 	proc = network.add("ProcessingType")
> 	proc = network.add("name", "ProcessingType")
> 	proc = add("ProcessingType") # implicit network
> 	proc = add("name", "ProcessingType") # implicit network
> 	network.remove("name")
> 	remove(proc) # implicit network alternative
> 	proc.remove() # alternative
> 	ports = proc._outports  # connections is an iterable
> 	ports = proc._inports  # connections is an iterable
> 	controls = proc._outcontrols  # connections is an iterable
> 	controls = proc._incontrols  # connections is an iterable
> 	proc.rename("newname")
> 	proc2 = proc.clone()
> 	proc2 = proc.clone("name2")
> 
> - Processing Configuration
> 	# Changes on proc._config has no effect on the processing 
> 	# until 'reconfigure' is called
> 	config = Config("ProcessingType")
> 	proc.ConfigField = newvalue
> 	proc["ConfigField"] = newvalue
> 	proc._config["ConfigField"] = newvalue
> 	proc._config.ConfigField = newvalue
> 	# analog for getters
> 	proc.updateConfig(
> 		ConfigField = value1,
> 		ConfigField2 = value2,
> 	)
> 	proc.config=config
> 	proc.reconfigure()
> 	proc.configured
> 
> - Obtaining ports/controls
> 	proc.Output
> 	proc['Output']
> 	proc._outports['Output']
> 	proc._outports.Output
> 	proc._outports[4] # Zero based to be consistent with python indexing
> 	proc.Output.type  # not sure what to return
> 	proc.Output.name
> 	proc.Output.index
> 	proc.Output.peers # returns a list of connected peers
> 
> - Connecting
> 	proc._outports.connect(proc2) # Connects all feasible ports
> 	proc._outcontrols.connect(proc2) # Connects all feasible controls
> 	proc > proc2        # shorthand for ._outports.connect
> 	proc.Output.connect(proc2.Input)
> 	proc.Output > proc2.Input      # shorthand for .connect
> 
> - Disconnect controls/ports
> 	proc.Output.disconnect(proc2.Input)
> 	proc.Output.disconnect() # any connected
> 	proc.Input.disconnect() # any connected
> 	for port in proc._inports : port.disconnect()
> 
> _______________________________________________
> clam-devel mailing list
> clam-devel at lists.clam-project.org
> http://lists.clam-project.org/listinfo.cgi/clam-devel-clam-project.org



More information about the clam-devel mailing list