BelaPlatform / supercollider

an environment and programming language for real time audio synthesis and algorithmic composition
GNU General Public License v3.0
14 stars 8 forks source link

DigitalOut ugens have problems #68

Open giuliomoro opened 6 years ago

giuliomoro commented 6 years ago

https://forum.bela.io/d/562-salt-and-supercollider/27

TheTechnobear commented 5 years ago

DigitalIn.kr(20) will "crash" server...

perhaps could check limits

s.options.numDigitalChannels = 16;

also as far as I could tell, the issues with DigitalOut remain the same :( So, Ive stuck with DigitalIO as a workaround (as details in above topic of bela.io forum)

(testing latest master branch on Salt)

giuliomoro commented 5 years ago

the issues with DigitalOut remain the same :(

yes, I did spend some time looking at it, and fixed a minor issue, but I could not reproduce the problem I think (also I did not have a scope at hand when I did that). I tried again now with as cope and I cannot find it. Could you please guide me through reproducing the error? Thanks

sensestage commented 5 years ago

Both DigitalIn and DigitalOut do perform a check at construction (the _Ctor functions of the Ugen) of the pin number, print out a warning, calculate the first (dummy) sample and then set the next_calculation to a dummy function.

Or they should... I see indeed that there is an error in DigitalIn.kr, as I did do a calculation of the first sample, but not do a SETCALC.

In /server/plugins/BelaPlugins.cpp lines 580 to 585 should be:

          // initiate first sample
          DigitalIn_next_dummy_k( unit, 1);  
          if (unit->mCalcRate == calc_FullRate) { // ugen running at audio rate;
            SETCALC(DigitalIn_next_dummy_a);
          } else {
            SETCALC(DigitalIn_next_dummy_k);
          }
sensestage commented 5 years ago

this way the DigitalIn will print out a warning and then just output 0.

giuliomoro commented 7 months ago

I think the issue now happens for larger block sizes and I can see why: the backend doesn't properly persist the digital buffer when the Context FIFO is enabled. https://forum.bela.io/d/3957-supercollider-digitalout-erratic-behaviour-on-high-bock-size Not sure what the issue was back in 2018 when large block sizes were not handled this way ... This should be fixed in the core.

Another issue with the digital ugens seems to be that digitalWrite() is used in place of digitalWriteOnce() at least once, with consequent wasted CPU time.