Creating custom objects

76 views
Skip to first unread message

Jan Vantomme

unread,
Mar 31, 2015, 2:54:33 PM3/31/15
to axolo...@googlegroups.com
I'm trying to create my first custom object, and ran into a little problem.
What I'm trying to do is create an output multiplexer as I need it for my performance instrument.

The object selector screen shows 4 different entities, but they are all the same.
All inputs/outputs are blue.

So my question is: how do I change the object so I can also create a yellow, red and green version?
My guess is that it has something to do with the SHA attribute. Just added a random SHA for now, because I don't know how to generate the correct one. 
Screen Shot 2015-03-31 at 20.46.35.png

Johannes Taelman

unread,
Mar 31, 2015, 3:28:53 PM3/31/15
to Jan Vantomme, axoloti-dev
Hi Jan,

Identical objects with only a different data type are actually separate objects with an identical name. They're often embedded in a single .axo file.
The datatypes of in- and outlets are in the XML.

frac32 : blue
bool32 : yellow
int32 : green
frac32buffer : red

Check for example "mux 2.axo"

The SHA in an object is a cryptographic hash (sha2) generated from the implementation of the object. It is copied into a document (as well as the object name). This provides a way to track the use of a certain object with the specific implementation of the object.
If a patch is opened with a reference to an object SHA that is not in the object library, axoloti will attempt to open an equally named object.

For now, you can just use a random number (or even name) in the SHA field of your own objects - as long as it is unique. It is never checked currently for correctness, but non-unique sha's are reported.

cheers,
Johannes

--
You received this message because you are subscribed to the Google Groups "axoloti-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axoloti-dev...@googlegroups.com.
To post to this group, send email to axolo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/axoloti-dev/3fa3df3e-9230-4738-802b-badfad73bd7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jan Vantomme

unread,
Mar 31, 2015, 5:05:21 PM3/31/15
to axolo...@googlegroups.com, janva...@gmail.com
Thanks! That seems to work. All blocks seem to work, except the red one.

I'm getting some kind of type conversion error, which is weird since the input and outputs are the same type.

xpatch.cpp:201:26: error: incompatible types in assignment of 'const int32_t* {aka const long int*}' to 'int32buffer {aka long int [16]}'
     default: outlet_out5 = inlet_in; break;


This is the XML code I've used, code in the CDATA is the same as in the blue, green and yellow objects:

<obj.normal id="omux 6" sha="01d657d22878164f052a21f189f0f5430e9ba411">
<sDescription>output multiplexer. Output is o1 when s &lt; 1, i[i] when....</sDescription>
<author>Jan Vantomme</author>
<license>BSD</license>
<inlets>
<frac32buffer name="in" description="input 0"/>
<int32 class="axoloti.inlets.InletInt32Pos" name="s" description="select"/>
</inlets>
<outlets>
<frac32buffer name="out0" description="output 0" SumBuffer="false"/>
<frac32buffer name="out1" description="output 1" SumBuffer="false"/>
<frac32buffer name="out2" description="output 2" SumBuffer="false"/>
<frac32buffer name="out3" description="output 3" SumBuffer="false"/>
<frac32buffer name="out4" description="output 4" SumBuffer="false"/>
<frac32buffer name="out5" description="output 5" SumBuffer="false"/>
</outlets>
<displays/>
<params/>
<attribs/>
<code.krate><![CDATA[
switch ( %s% > 0 ? %s% : 0 ) {
case 0:  %out0% = %in%; break;
case 1:  %out1% = %in%; break;
case 2:  %out2% = %in%; break;
case 3:  %out3% = %in%; break;
case 4:  %out4% = %in%; break;
case 5:  %out5% = %in%; break;
default: %out5% = %in%; break;
}
]]></code.krate>
</obj.normal>

Johannes Taelman

unread,
Mar 31, 2015, 5:17:18 PM3/31/15
to Jan Vantomme, axoloti-dev
Use the code.srate field for the red variety rather than the code.krate field.
s-rate : executed for each audio sample
k-rate : executed for each block of samples (fixed at 16 samples/block currently)

What your code is also not doing properly is assigning a value (probably zero) to the unselected outlets.

The inverse of a multiplexer is often called a demultiplexer or demux.


Jan Vantomme

unread,
Apr 1, 2015, 2:08:15 PM4/1/15
to axolo...@googlegroups.com, janva...@gmail.com
Thanks. Everything works fine now.
Reply all
Reply to author
Forward
0 new messages