accessing other inlets within code

Mar 4, 2013 at 12:18pm

accessing other inlets within code

Hi there

I am developing a code to make a comb filter within maxmsp using java. However I have stumbled upon a problem. Here is my code
public class IntelliTest extends MSPPerformer{
float []_circBuffer = sr; //defined in dsp setup method
int _delayTime = getInlet();
int _readIndex1 = 0;
int _writeIndex = _delayTime;

float _feedBack = 0.0f;
float _feedForward = 0.0f;
float _blend = 0.0f;

//constructor
IntelliTest(){
declareInlets(new int[]{SIGNAL, DataTypes.FLOAT,DataTypes.FLOAT,DataTypes.FLOAT,DataTypes.INT,SIGNAL});
declareOutlets(new int[]{SIGNAL});
}

// user set delaytime
public void inlet (int i) {
if(i >= 0 && i < _circBuffer.length){
_delayTime = i; // need to convert to samples
}
else{
post(“Delay cannot be negative or exceed the buffer size”);
}
}

// user set feedback
public void inlet (float f){
if(f > 0 && f < 0.99){
_feedBack = f;
}
else{
post(“Feedback cannot be negative or exceed 0.99″); //need to establish processing of other float inlets
}
}

}

As you can see I have missed out part of the code as I can’t work out how to establish the other inlets within the code. For example I can access the delay time via float..but can’t access any of the other inlets as I don’t know how to number them. Do I use atoms?

Any help would be appreciated.

Wkdside

#66853
Mar 4, 2013 at 10:18pm

you need to tell the object to check which inlet has been used, this code is for 6 inlets (0,1,2,3,4,5) so for your float inlets you need to have the code like so ….

public void inlet(float f)
{
int floatInlet;
floatInlet = getInlet(); // this tells your inlet to check what inlet the signals are coming from

if (floatInlet == 1){ // this says if the info is coming in on inlet 1 then do such and such with the info
do something
}
if (floatInlet == 2){ // this says if the info is coming in on inlet 2 then do such and such with the info
do something else
}
etc….

good luck with the comb filter.

ps. you might wanna change Daves delay post comments. :-P

#240644
Mar 5, 2013 at 11:41am

As an aside, I’ve yet to be convinced that this technique (explicit callback to determine the inlet used) is thread-safe. It depends, I suppose, whether getInlet() contains a link to the thread which made the initial call to inlet(), but there’s no mention of this in any of the documentation. So, you might want to think about using a pak upstream to pack messages into one inlet with a prefix string to distinguish them.

#240645

You must be logged in to reply to this topic.