Re: [sc-users] scplug (was: hobnox)

View: New views
20 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

Parent Message unknown Re: [sc-users] scplug (was: hobnox)

by Dan Stowell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Stefan -

(Moved to dev list btw, hope that's OK)

I would really like to be able to understand this code so I can maybe
play with it in meaningful ways. I can't currently compile it (can't
install mozilla-dev ATM) but could you help with some pointers please?
Like:

 - The np*.cpp files - there are 3 of these, what do they each do? I'm
sure they connect to the NPAPI, but I wonder what their 3 different
roles are. (In fact, the same goes for the other c++ files...)
 - The readme says "currently Linux only" - what's the reason for
that? Just a makefile thing, or...?
 - Is OSC used for communication between browser and plugin? I'm a bit
confused - the supercollider.js looks like it's got objects for
handling OSC but I can't see where the JS for actually
generating/receiving the OSC would be.

Hopefully the questions aren't too heavy. Um well we'll see...

Dan


2008/5/15 stefan kersten <sk@...>:

> On 15.05.2008, at 17:13, Dan Stowell wrote:
>> Check it:
>> http://space.k-hornz.de/software/scplug
>>
>> Not sure how active it is at the moment. I rilly rilly wish I had time
>> and knowledge to contribute to it, because I too am infatuated with
>> the idea of scsynth web-browser plugin. It would be amazing in many,
>> many ways.
>
> at the moment it's unfortunately not as active as i'd like it to be.
> actually the plugin is not really sophisticated, just a few screens of
> code. adapting it to the qt cross browser plugin framework should be
> relatively straightforward, but i haven't had the time to have a closer
> look at that yet. any kind of contribution appreciated of course!
>
> <sk>
>
> _______________________________________________
> sc-users mailing list
> sc-users@...
> http://lists.create.ucsb.edu/mailman/listinfo/sc-users
>



--
http://www.mcld.co.uk
_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: [sc-users] scplug (was: hobnox)

by stefan kersten-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi dan,

On 15.05.2008, at 22:46, Dan Stowell wrote:
> I would really like to be able to understand this code so I can maybe
> play with it in meaningful ways. I can't currently compile it (can't
> install mozilla-dev ATM) but could you help with some pointers please?

i sat down today and started porting to the qtbrowserplugin framework,
so hopefully in a few days it's functional (again). with the qt stuff it
should run and compile on all three platforms SC runs on and be usable
in all major browsers -- except for IE, which is only supported by the
commercial version of qt.

> - The np*.cpp files - there are 3 of these, what do they each do? I'm
> sure they connect to the NPAPI, but I wonder what their 3 different
> roles are. (In fact, the same goes for the other c++ files...)

those files were copied from an example plugin and most of the code is
boilerplate for providing a c++ layer to the low-level c interface. the
real thing is in SC_NPPlugin.(h|cpp)

> - The readme says "currently Linux only" - what's the reason for
> that? Just a makefile thing, or...?

obtaining a mozilla build setup (especially with the IDL compiler etc)
on anything else than debian seems to be a pita, this is going to be
much smoother with qtbrowserplugin.

> - Is OSC used for communication between browser and plugin? I'm a bit
> confused - the supercollider.js looks like it's got objects for
> handling OSC but I can't see where the JS for actually
> generating/receiving the OSC would be.

the plugin links to the internal server and communication is via OSC
through a message fifo. the JS code calls the sendMessage and sendBundle
plugin methods, which marshal the argument JS objects to OSC packets and
push them onto the fifo. reply messages from the synth are also pulled
from a message queue -- unfortunately this queue has to be polled from a
JS timer currently, hopefully there'll be a way in the future to
directly call back into the JS interpreter.

thanks for your interest! as soon as the switch to qt is done we'll have
a more solid basis for further development. i'll keep you posted ...

<sk>

_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: [sc-users] scplug (was: hobnox)

by stefan kersten-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 16.05.2008, at 01:49, stefan kersten wrote:
> i sat down today and started porting to the qtbrowserplugin framework,
> so hopefully in a few days it's functional (again).

small update: the qt port is mostly done, although there are some open
ends remaining. in particular OSC messaging doesn't work yet, because
the qt/js bridge doesn't handle argument lists. on osx with qt 4.2.2
safari crashes when reloading the page.

the project is now named `scplug':

http://darcs.k-hornz.de/cgi-bin/darcsweb.cgi?r=scplug;a=summary

<sk>

_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

[sc-dev] Re: [Sc-devel] [sc-users] scplug (was: hobnox)

by Dan Stowell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It's been a while. It took me ages to get darcs installed (bloomin
obscure haskell-based software...), but now I've got it, so I'm back
with questions about building scplug!

Here's what I did:

(1) edited scplug.pro so that SC_SOURCE_DIR matches my system
(2) "qmake" - no errors, all fine I guess...
(3) "make" - got this error:

/Developer/Tools/Rez scplug.r -o scplug.rsrc -useDF
g++ -c -pipe -Os -Wall -W -fPIC -DSC_DARWIN -DQT_NO_DEBUG -DQT_PLUGIN
-DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
-I/opt/local/share/qt4-mac/mkspecs/macx-g++ -I.
-I/opt/local/Library/Frameworks/QtCore.framework/Versions/4/Headers
-I/opt/local/include/qt4-mac/QtCore
-I/opt/local/Library/Frameworks/QtGui.framework/Versions/4/Headers
-I/opt/local/include/qt4-mac/QtGui -I/opt/local/include/qt4-mac
-I../../../SuperCollider3/Headers/common
-I../../../SuperCollider3/Headers/server
-I../../../SuperCollider3/Headers/plugin_interface
-Ivendor/qtbrowserplugin/src -I. -I. -F/opt/local/Library/Frameworks
-o QtOSC.o src/QtOSC.cpp
../../../SuperCollider3/Headers/plugin_interface/SC_Types.h:39: error:
conflicting declaration 'typedef unsigned int ulong'
/opt/local/Library/Frameworks/QtCore.framework/Headers/qglobal.h:797:
error: 'ulong' has a previous declaration as 'typedef long unsigned
int ulong'
make: *** [QtOSC.o] Error 1

Any suggestions? (I'm using QT version 4.4.0 on a PPC Mac PowerBook,
OSX 10.4.11)

Thanks
Dan


2008/5/20 stefan kersten <sk@...>:

> On 16.05.2008, at 01:49, stefan kersten wrote:
>> i sat down today and started porting to the qtbrowserplugin framework,
>> so hopefully in a few days it's functional (again).
>
> small update: the qt port is mostly done, although there are some open
> ends remaining. in particular OSC messaging doesn't work yet, because
> the qt/js bridge doesn't handle argument lists. on osx with qt 4.2.2
> safari crashes when reloading the page.
>
> the project is now named `scplug':
>
> http://darcs.k-hornz.de/cgi-bin/darcsweb.cgi?r=scplug;a=summary
>
> <sk>
>
> _______________________________________________
> Sc-devel mailing list
> Sc-devel@...
> http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>



--
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/

[sc-dev] Print

by Miguel Negrao-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 ?

thanks

Miguel Negrão

ps: is this the correct place for this type of question, or should i use
sc-users ?

_______________________________________________
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/

Re: [sc-dev] Print

by Dan Stowell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

--
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/

Re: [sc-dev] Print

by Miguel Negrao-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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/

Re: [sc-dev] Re: [Sc-devel] [sc-users] scplug (was: hobnox)

by stefan kersten-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 19.06.2008, at 22:32, Dan Stowell wrote:
> It's been a while. It took me ages to get darcs installed (bloomin
> obscure haskell-based software...)

yay! didn't the binary packages [1] work for you? i installed darcs  
via macports, but if you're on ppc i agree it can be a pita ...

> (3) "make" - got this error:
[...]
> ../../../SuperCollider3/Headers/plugin_interface/SC_Types.h:39: error:
> conflicting declaration 'typedef unsigned int ulong'
> /opt/local/Library/Frameworks/QtCore.framework/Headers/qglobal.h:797:
> error: 'ulong' has a previous declaration as 'typedef long unsigned
> int ulong'

oops, i forgot i made some changes to SC that are necessary for  
compiling scplug. i'll review them as soon as i can and commit them.  
in the meantime you can try the patch i've attached.

<sk>

[1] http://wiki.darcs.net/DarcsWiki/ 
CategoryBinaries#head-25c8108e9d719be30a8cc6bcc86ce243a78b8c25






sc3_scplug.patch (4K) Download Attachment

Re: [sc-dev] Print

by nescivi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thursday 19 June 2008 17:19:04 Miguel Negrao wrote:

> 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 ?
>
> thanks
>
> Miguel Negrão
>
> ps: is this the correct place for this type of question, or should i use
> sc-users ?

you should start a new thread though, instead of hijacking another...
(use "new message" instead of "reply to")

sincerely,
marije

_______________________________________________
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/

Re: [sc-dev] Print

by Josh Parmenter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Are you sure that bit of code is actually executing? Try putting the  
Print in the regular function, and see if it works.

Are you sure that the next_ak function is actually running? Check the  
rates on the input of your UGen from the SC side.

best,

Josh

On Jun 19, 2008, at 2:50 PM, Miguel Negrao wrote:

> 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/

******************************************
/* Joshua D. Parmenter
http://www.realizedsound.net/josh/

“Every composer – at all times and in all cases – gives his own  
interpretation of how modern society is structured: whether actively  
or passively, consciously or unconsciously, he makes choices in this  
regard. He may be conservative or he may subject himself to continual  
renewal; or he may strive for a revolutionary, historical or social  
palingenesis." - Luigi Nono
*/


_______________________________________________
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/

Re: [sc-dev] Print

by Dan Stowell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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/

Re: [sc-dev] Print

by Miguel Negrao-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

void load(InterfaceTable *inTable)
{
        ft = inTable;

#define DefineBufInfoUnit(name) \
        (*ft->fDefineUnit)(#name, sizeof(BufInfoUnit),
(UnitCtorFunc)&name##_Ctor, 0, 0);

        DefineSimpleUnit(PlayCFBuf);
       
}

Dan Stowell escreveu:

> 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/
>>
>
>
>


_______________________________________________
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/

Re: [sc-dev] Print

by Dan Stowell :: Rate this Message: