« Return to Thread: Re: [sc-users] scplug (was: hobnox)

Re: [sc-dev] Print

by Dan Stowell :: Rate this Message:

Reply to Author | View in Thread

Yes, but what about your "load()" function? Can you paste that please?

Dan

2008/6/19 Miguel Negrao <miguel.negrao@...>:

> Dan Stowell escreveu:
>>
>> 2008/6/19 Miguel Negrao <miguel.negrao@...>:
>>>
>>> Hi
>>>
>>> I'm making the first steps in UGen building. I need to debug my UGen, and
>>> the simplest way to do that is to just print stuff to the console. I
>>> tried
>>> using Print(...); either in the constructor or in the dsp funcition but
>>> it
>>> never prints anything. It is supposed to print to the sc console, right ?
>>> Do
>>> I need to install something else ?
>>
>> No, it should work just fine. Perhaps you could show us exactly what
>> your Print() lines looked like?
>>
>> In fact, one thing to check: are you *sure* that your constructor/dsp
>> functions are being called? Print() should definitely work. So, maybe
>> the ctor never gets called? Which ctor to use is specified during the
>> init() function, using a call like DefineSimpleUnit(FreeVerb2)
>>
>>
>>> ps: is this the correct place for this type of question, or should i use
>>> sc-users ?
>>
>> I don't know what the official decision would be... ugen-coding is
>> kind of half-way between the two, so I'd say choose for yourself...
>>
>> Dan
>>
>
> I just cloned PlayBuf code, to make it crossfade on triggers. For example
> this function should output "bang" on each trigger:
>
> void PlayCFBuf_next_ak(PlayCFBuf *unit, int inNumSamples)
> {
>        //float *ratein  = ZIN(1);
>        float trig     = ZIN0(2);
>        int32 loop     = (int32)ZIN0(4);
>
>        float fbufnum  = ZIN0(0);
>        if (fbufnum != unit->m_fbufnum) {
>                uint32 bufnum = (int)fbufnum;
>                World *world = unit->mWorld;
>                if (bufnum >= world->mNumSndBufs) bufnum = 0;
>                unit->m_fbufnum = fbufnum;
>                unit->m_buf = world->mSndBufs + bufnum;
>
>        }
>        SndBuf *buf = unit->m_buf;
>        float *bufData __attribute__((__unused__)) = buf->data;
>        uint32 bufChannels __attribute__((__unused__)) = buf->channels;
>        uint32 bufSamples __attribute__((__unused__)) = buf->samples;
>        uint32 bufFrames = buf->frames;
>        int mask __attribute__((__unused__)) = buf->mask;
>        int guardFrame __attribute__((__unused__)) = bufFrames - 2;
>
>        double cfdur   = 0.001 * ZIN0(5) * unit->mRate->mSampleRate;
>        int counter    = unit->mCounter;
>        double phase_2;
>        double level;
>        double slope;
>
>        CHECK_BUF
>        SETUP_OUT
>
>        double loopMax = (double)(loop ? bufFrames : bufFrames - 1);
>        double phase = unit->m_phase;
>        if (counter != 0)
>                { double phase_2 = unit->m_phase_2;
>                  double level   = unit->mLevel;
>              double slope   = unit->mSlope;
>                }
>    if(phase == -1.) phase = bufFrames;
>
>        if ( (trig > 0.f && unit->m_prevtrig<= 0.f) ||(phase > 4410.f )) {
>                unit->mDone = false;
>                phase_2 = phase;
>                phase = ZIN0(3);
>                counter = sc_max(1, (int)(cfdur + .5f));
>                slope  = 1.0 / counter;
>                level  = 0;
>                Print("Bang \n");
>
>        }
>        unit->m_prevtrig = trig;
>        for (int i=0; i<inNumSamples; ++i) {
>
>                LOOP_BODY_1
>
>                if (counter == 0) {
>                        LOOP_BODY_2
>                } else {
>                        LOOP_BODY_3
>                        phase_2 += ZXP(ratein);
>                }
>
>                phase++;
>
>        }
>
>        unit->m_phase = phase;
>        unit->mCounter = counter;
>        if (counter != 0)       {
>                unit->m_phase_2 = phase_2;
>                unit->mLevel = level;
>                unit->mSlope = slope;
>        }
>
>
> }
>
> The constructor:
>
> void PlayCFBuf_Ctor(PlayCFBuf *unit)
> {
>        if (INRATE(1) == calc_FullRate) {
>                if (INRATE(2) == calc_FullRate) {
>                        if (ZIN0(6) == 1)
>                                { SETCALC(PlayCFBuf_next_aa); }
>                                { SETCALC(PlayCFBuf_next_aa_noint); }
>                        Print("aa\n");
>                } else {
>                        if (ZIN0(6) == 1)
>                                { SETCALC(PlayCFBuf_next_ak); }
>                                { SETCALC(PlayCFBuf_next_ak_noint); }
>                        Print("ak\n");
>                }
>        } else {
>                if (INRATE(2) == calc_FullRate) {
>                        if (ZIN0(6) == 1)
>                                { SETCALC(PlayCFBuf_next_ka); }
>                                { SETCALC(PlayCFBuf_next_ka_noint); }
>                } else {
>                        if (ZIN0(6) == 1)
>                                { SETCALC(PlayCFBuf_next_kk); }
>                                { SETCALC(PlayCFBuf_next_kk_noint); }
>                }
>        }
>
>        unit->m_fbufnum = -1e9f;
>        unit->m_prevtrig = 0.;
>        unit->m_phase = ZIN0(3);
>        unit->mCounter = 0;
>        unit->mLevel = 0;
>
>        ClearUnitOutputs(unit, 1);
>        Print("constructor");
> }
>
> _______________________________________________
> sc-dev mailing list
>
> sc-dev@...
> archive: http://www.listarc.bham.ac.uk/lists/sc-dev/
> search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/
>



--
http://www.mcld.co.uk

_______________________________________________
sc-dev mailing list

sc-dev@...
archive: http://www.listarc.bham.ac.uk/lists/sc-dev/
search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/

 « Return to Thread: Re: [sc-users] scplug (was: hobnox)

LightInTheBox - Buy quality products at wholesale price