logo       

input error(?) on plugin: msg#00192

audio.supercollider.devel

Subject: input error(?) on plugin

hello there.

i think i might be going crazy...

so below is a super tiny plugin that just prints out the input samples that it's given to the message window. i'm just giving the Ugen a static input value of 0.0, yet it reports a value of 8.0000000 on the 5th sample and the 17th sample ... for every block...

can someone tell me whether it's my current build of sc3 that's doing this or am i fudging something in this superbasic plugin?? are you able to reproduce the same effect on your system??

help please. this is driving me nuts...

here's the code i'm using:

// THE PLUGIN //
<x-tad-smaller>
</x-tad-smaller><x-tad-smaller>/*
Adam Overton
TestInput -- Converts an incoming signal into binary, and outputs that binary series (0111000) at audio rate.
Since each single input value will put out 16-32 bits, this ugen only samples the input every N-samples, where N
is equal to the number of bits per input value. Since that may leave out many input samples, the user can specify
which input sample they would like to use, which will be useful when using more than one of these generators at a time...
*/</x-tad-smaller>
<x-tad-smaller>

</x-tad-smaller><x-tad-smaller>#include "SC_PlugIn.h"</x-tad-smaller><x-tad-smaller>

</x-tad-smaller><x-tad-smaller>// InterfaceTable contains pointers to functions in the host (server).</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>static</x-tad-smaller><x-tad-smaller> InterfaceTable *ft;

</x-tad-smaller><x-tad-smaller>// declare struct to hold unit generator state</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>struct</x-tad-smaller><x-tad-smaller> TestInput : </x-tad-smaller><x-tad-smaller>public</x-tad-smaller><x-tad-smaller> Unit
{
};

</x-tad-smaller><x-tad-smaller>// declare unit generator functions </x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>extern</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>"C"</x-tad-smaller><x-tad-smaller>
{
</x-tad-smaller><x-tad-smaller>void</x-tad-smaller><x-tad-smaller> load(InterfaceTable *inTable);
</x-tad-smaller><x-tad-smaller>void</x-tad-smaller><x-tad-smaller> TestInput_next(TestInput *unit, </x-tad-smaller><x-tad-smaller>int</x-tad-smaller><x-tad-smaller> blockSize);
</x-tad-smaller><x-tad-smaller>void</x-tad-smaller><x-tad-smaller> TestInput_Ctor(TestInput* unit);
};

</x-tad-smaller><x-tad-smaller>//////////////////////////////////////////////////////////////////</x-tad-smaller><x-tad-smaller>

</x-tad-smaller><x-tad-smaller>// Ctor is called to initialize the unit generator. </x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>// It only executes once.</x-tad-smaller><x-tad-smaller>

</x-tad-smaller><x-tad-smaller>// A Ctor usually does 3 things.</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>// 1. set the calculation function.</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>// 2. initialize the unit generator state variables.</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>// 3. calculate one sample of output.</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>void</x-tad-smaller><x-tad-smaller> TestInput_Ctor(TestInput* unit)
{

</x-tad-smaller><x-tad-smaller>// 1. set the calculation function.</x-tad-smaller><x-tad-smaller>
SETCALC(TestInput_next);

</x-tad-smaller><x-tad-smaller>// 2. initialize the unit generator state variables.</x-tad-smaller><x-tad-smaller>


</x-tad-smaller><x-tad-smaller>// 3. calculate one sample of output.</x-tad-smaller><x-tad-smaller>
TestInput_next(unit, </x-tad-smaller><x-tad-smaller>1</x-tad-smaller><x-tad-smaller>);
}

</x-tad-smaller><x-tad-smaller>//////////////////////////////////////////////////////////////////</x-tad-smaller><x-tad-smaller>

</x-tad-smaller><x-tad-smaller>// The calculation function executes once per control period </x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>// which is typically 64 samples.</x-tad-smaller><x-tad-smaller>

</x-tad-smaller><x-tad-smaller>// calculation function when the buffer has not yet been filled</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>void</x-tad-smaller><x-tad-smaller> TestInput_next(TestInput *unit, </x-tad-smaller><x-tad-smaller>int</x-tad-smaller><x-tad-smaller> blockSize)
{
</x-tad-smaller><x-tad-smaller>// get the pointer to the output buffer</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>float</x-tad-smaller><x-tad-smaller> *out = OUT(</x-tad-smaller><x-tad-smaller>0</x-tad-smaller><x-tad-smaller>);


</x-tad-smaller><x-tad-smaller>// get the pointer to the input buffer</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>float</x-tad-smaller><x-tad-smaller> *in = IN(</x-tad-smaller><x-tad-smaller>0</x-tad-smaller><x-tad-smaller>);


</x-tad-smaller><x-tad-smaller>int</x-tad-smaller><x-tad-smaller> i=</x-tad-smaller><x-tad-smaller>0</x-tad-smaller><x-tad-smaller>; i<</x-tad-smaller><x-tad-smaller>64</x-tad-smaller><x-tad-smaller>; i++) {
printf(</x-tad-smaller><x-tad-smaller>"%f\n"</x-tad-smaller><x-tad-smaller>, in[i]);
}
printf(</x-tad-smaller><x-tad-smaller>"\n"</x-tad-smaller><x-tad-smaller>); // separate blocks...

}

</x-tad-smaller><x-tad-smaller>////////////////////////////////////////////////////////////////////</x-tad-smaller><x-tad-smaller>

</x-tad-smaller><x-tad-smaller>// the load function is called by the host when the plug-in is loaded</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>void</x-tad-smaller><x-tad-smaller> load(InterfaceTable *inTable)
{
ft = inTable;

DefineSimpleUnit(TestInput);
}

</x-tad-smaller><x-tad-smaller>////////////////////////////////////////////////////////////////////</x-tad-smaller><x-tad-smaller>

////////////////////////////////////////////////////////////////////


// THE .SC FILE //
</x-tad-smaller>
<x-tad-smaller>TestInput</x-tad-smaller><x-tad-smaller> : </x-tad-smaller><x-tad-smaller>UGen</x-tad-smaller><x-tad-smaller> {
*ar { </x-tad-smaller><x-tad-smaller>arg</x-tad-smaller><x-tad-smaller> in;
^</x-tad-smaller><x-tad-smaller>'audio'</x-tad-smaller><x-tad-smaller>, in)
}


</x-tad-smaller>
<x-tad-smaller>////////////////////////////////////////////////////////////////////
// THE TEST CODE //
</x-tad-smaller>(
s=Server.local;
"test", { arg inBus=0, thresh=0.1;
var sig;

sig = TestInput.ar(0.0);

Out.ar(0, sig);
}).send(s);
)

s.sendMsg(\s_new, "test", 1000, 1, 0);
_______________________________________________
sc-dev mailing list
sc-dev-Ayv8T2snMLBt9CRQqspbbg@xxxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-dev
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise