[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] [commit?] A2K ugen




A2K should simply return the first value in each buffer. This is compatible with how it is handled implicitly for ugens that only respond at k-rate.

averaging is not a good resampling technique anyway.

On Nov 2, 2004, at 6:25 AM, Julian Rohrhuber wrote:

here is an averaging A2K ugen. I think it would be handy to have. Should I commit it?


Index: LFUGens.cpp
===================================================================
RCS file: /cvsroot/supercollider/SuperCollider3/source/plugins/LFUGens.cpp,v
retrieving revision 1.31
diff -p -b -B -r1.31 LFUGens.cpp
*** LFUGens.cpp 12 Sep 2004 07:21:23 -0000      1.31
--- LFUGens.cpp 2 Nov 2004 14:22:53 -0000
*************** struct K2A : public Unit
*** 149,154 ****
--- 149,159 ----
        float mLevel;
  };

+ struct A2K : public Unit
+ {
+
+ };
+
  struct Silent : public Unit
  {
  };
*************** extern "C"
*** 230,235 ****
--- 235,243 ----
        void K2A_next(K2A *unit, int inNumSamples);
        void K2A_Ctor(K2A* unit);

+       void A2K_next(A2K *unit, int inNumSamples);
+       void A2K_Ctor(A2K* unit);
+
        void Silent_next(Silent *unit, int inNumSamples);
        void Silent_Ctor(Silent* unit);

*************** void K2A_Ctor(K2A* unit)
*** 1098,1103 ****
--- 1106,1133 ----
        ZOUT0(0) = unit->mLevel;

  }
+
+ ////////////////////////////////////////////////////////////////////// ////////////////////////////
+
+ void A2K_next(A2K *unit, int inNumSamples)
+ {
+
+       float *in = ZIN(0);
+       float sum = 0.f;
+
+       LOOP(inNumSamples,
+               sum += ZXP(in);
+       );
+       ZOUT0(0) = sum / (float)inNumSamples;
+ }
+
+ void A2K_Ctor(A2K* unit)
+ {
+       SETCALC(A2K_next);
+       A2K_next(unit, 1);
+
+ }
+
////////////////////////////////////////////////////////////////////// ////////////////////////////

  void Silent_Ctor(Unit* unit)
*************** void load(InterfaceTable *inTable)
*** 3357,3362 ****
--- 3387,3393 ----
        DefineSimpleUnit(VarSaw);
        DefineSimpleUnit(SyncSaw);
        DefineSimpleUnit(K2A);
+       DefineSimpleUnit(A2K);
        DefineSimpleUnit(Silent);
        DefineSimpleUnit(Line);
        DefineSimpleUnit(XLine);
--








.
_______________________________________________
sc-dev mailing list
sc-dev@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-dev