예제 #1
0
파일: libevent.cpp 프로젝트: jmlvanre/mesos
void handle_delay(int, short, void* arg)
{
    Delay* delay = reinterpret_cast<Delay*>(arg);
    delay->function();
    event_free(delay->timer);
    delete delay;
}
END_TEST

START_TEST ( test_Delay )
{
  Delay* d = new Delay(2, 4);
  
  fail_unless (d->hasRequiredAttributes());

  delete d;
}
예제 #3
0
	// re-initialize all member variables;
	inline void reset(double __sr, int __vs) { 
		__exception = 0;
		vectorsize = __vs;
		samplerate = __sr;
		m_y_1 = 0;
		m_history_2 = 0;
		m_history_3 = 0;
		m_history_4 = 0;
		m_history_5 = 0;
		m_history_6 = 0;
		m_history_7 = 0;
		m_history_8 = 0;
		m_history_9 = 0;
		m_y_10 = 0;
		m_delay_11.reset("m_delay_11", 96000);
		m_delay_12.reset("m_delay_12", 96000);
		m_resonance_13 = 0;
		m_cutoff_14 = 2250;
		m_window_15 = 100;
		m_mix_16 = 0.5;
		m_blur_17 = 0.25;
		m_ratio_18 = 0.5;
		m_window_19 = 100;
		m_ratio_20 = 2;
		samples_to_seconds = (1 / samplerate);
		m_phasor_21.reset(0);
		m_delta_22.reset(0);
		m_sah_23.reset(0);
		m_sah_24.reset(0);
		m_delta_25.reset(0);
		m_sah_26.reset(0);
		m_sah_27.reset(0);
		m_delta_28.reset(0);
		m_sah_29.reset(0);
		m_sah_30.reset(0);
		m_delta_31.reset(0);
		m_sah_32.reset(0);
		m_sah_33.reset(0);
		m_phasor_34.reset(0);
		m_delta_35.reset(0);
		m_sah_36.reset(0);
		m_sah_37.reset(0);
		m_delta_38.reset(0);
		m_sah_39.reset(0);
		m_sah_40.reset(0);
		m_delta_41.reset(0);
		m_sah_42.reset(0);
		m_sah_43.reset(0);
		m_delta_44.reset(0);
		m_sah_45.reset(0);
		m_sah_46.reset(0);
		genlib_reset_complete(this);
		
	};
END_TEST

START_TEST ( test_Delay )
{
  Delay* d = new Delay(2, 4);
  
  fail_unless (!(d->hasRequiredElements()));

  d->setMath(SBML_parseFormula("a+b"));

  fail_unless (d->hasRequiredElements());

  delete d;
}
예제 #5
0
Reverb::Reverb() :
m_Time(0),
m_Feedback(0.2),
m_Randomness(0.01),
m_Bypass(true)
{
	// set up the delay vec
	for (int i=0; i<NUM_DELAYS; i++)
	{
		Delay *pDelay = new Delay;
		pDelay->SetLeftDelay(RandFloat(MIN_DELAYTIME,MAX_DELAYTIME));
		pDelay->SetRightDelay(RandFloat(MIN_DELAYTIME,MAX_DELAYTIME));
		pDelay->SetBypass(false);
		m_DelayVec.push_back(pDelay);
	}
}
END_TEST


START_TEST ( test_Event_parent_NULL )
{
    SBMLDocument *d = new SBMLDocument(2, 4);
    Model *m = d->createModel();
    Event *c = m->createEvent();
    EventAssignment *ea = c->createEventAssignment();
    Trigger *t = new Trigger(2, 4);
    t->setMath(new ASTNode());
    Delay *dy = new Delay(2, 4);
    dy->setMath(new ASTNode());
    c->setTrigger(t);
    c->setDelay(dy);

    fail_unless(c->getAncestorOfType(SBML_MODEL) == m);
    fail_unless(c->getTrigger()->getParentSBMLObject() == c);
    fail_unless (c->getDelay()->getSBMLDocument() == d);
    fail_unless(ea->getAncestorOfType(SBML_EVENT) == c);

    Event *c1 = c->clone();
    delete d;

    fail_unless(c1->getAncestorOfType(SBML_MODEL) == NULL);
    fail_unless(c1->getParentSBMLObject() == NULL);
    fail_unless (c1->getSBMLDocument() == NULL);

    fail_unless(c1->getEventAssignment(0)->getAncestorOfType(SBML_MODEL) == NULL);
    fail_unless(c1->getEventAssignment(0)->getAncestorOfType(SBML_EVENT) == c1);
    fail_unless(c1->getEventAssignment(0)->getParentSBMLObject() != NULL);
    fail_unless(c1->getEventAssignment(0)->getSBMLDocument() == NULL);

    fail_unless(c1->getTrigger()->getAncestorOfType(SBML_MODEL) == NULL);
    fail_unless(c1->getTrigger()->getAncestorOfType(SBML_EVENT) == c1);
    fail_unless(c1->getTrigger()->getParentSBMLObject() != NULL);
    fail_unless(c1->getTrigger()->getSBMLDocument() == NULL);

    fail_unless(c1->getDelay()->getAncestorOfType(SBML_MODEL) == NULL);
    fail_unless(c1->getDelay()->getAncestorOfType(SBML_EVENT) == c1);
    fail_unless(c1->getDelay()->getParentSBMLObject() != NULL);
    fail_unless(c1->getDelay()->getSBMLDocument() == NULL);

    delete c1;
}
예제 #7
0
	// the signal processing routine;
	inline int perform(t_sample ** __ins, t_sample ** __outs, int __n) { 
		vectorsize = __n;
		const t_sample * __in1 = __ins[0];
		t_sample * __out1 = __outs[0];
		if (__exception) { 
			return __exception;
			
		} else if (( (__in1 == 0) || (__out1 == 0) )) { 
			__exception = GENLIB_ERR_NULL_BUFFER;
			return __exception;
			
		};
		double expr_226 = safediv(((m_tone_4 * 2) * 3.1415926535898), 48000);
		double sin_217 = sin(expr_226);
		double clamp_218 = ((sin_217 <= 1e-05) ? 1e-05 : ((sin_217 >= 0.99999) ? 0.99999 : sin_217));
		// the main sample loop;
		while ((__n--)) { 
			const double in1 = (*(__in1++));
			double mix_229 = (m_y_2 + (clamp_218 * (in1 - m_y_2)));
			double mix_215 = mix_229;
			m_cycle_7.freq(m_rate_6);
			double cycle_221 = m_cycle_7(__sinedata);
			double cycleindex_222 = m_cycle_7.phase();
			double add_220 = (cycle_221 + 1);
			double mul_219 = (add_220 * 0.5);
			double mul_223 = (m_depth_5 * mul_219);
			double mstosamps_214 = (mul_223 * (samplerate * 0.001));
			double mix_230 = (mstosamps_214 + (0.999 * (m_smth_1 - mstosamps_214)));
			double mix_213 = mix_230;
			double tap_225 = m_delay_3.read_linear(mix_213);
			double out1 = tap_225;
			double y0_next_227 = mix_215;
			double smth_next_228 = mix_213;
			m_delay_3.write(mix_215);
			m_y_2 = y0_next_227;
			m_smth_1 = smth_next_228;
			m_delay_3.step();
			// assign results to output buffer;
			(*(__out1++)) = out1;
			
		};
		return __exception;
		
	};
int ModuleController::delay(const char   *path, 
							const char   *types, 
							lo_arg       **argv, 
							int          argc,
							void         *data, 
							void         *user_data)
{
	ModuleController *mc = (ModuleController *)user_data;
    
    char p[64] = "/ModuleManager/EF/Delay/Tile";
    strcat(p, &argv[1]->s);
    
    if (argv[0]->i) {//argv[0] = 1:モジュール生成 0:モジュール解放
        for (std::list<Delay*>::iterator iter = mc->delayList.begin(); iter != mc->delayList.end(); iter++) {
            Delay *delay = (*iter);
            if (strcmp(p,delay->OSCAddr)==0) {
                if (delay->tID == atoi(&argv[1]->s)) {
                    printf("err: Creating Delay\n");
                    return 0;
                }
            }
        }
        
        Delay *delay = new Delay(mc->st, p);
        delay->setTID(atoi(&argv[1]->s));
        delay->mColor = 6;
        delay->sendSetMdtkn();
        mc->delayList.push_back(delay);
        printf("create Delay\n");
		
    }else {
        for (std::list<Delay*>::iterator iter = mc->delayList.begin(); iter != mc->delayList.end(); iter++) {
            Delay* delay = (*iter);
            if (strcmp(p,delay->OSCAddr)==0) {
                delete delay;
                mc->delayList.remove(delay);
                printf("delete Delay\n");
            }
        }
    }
    return 0;
}
예제 #9
0
파일: echo.cpp 프로젝트: LancePutnam/Gamma
	MyApp(){
		// Allocate 200 ms in the delay line
		delay.maxDelay(0.2);

		tmr.period(4);
		tmr.phaseMax();

		// Configure a short cosine grain
		src.set(1000, 0.8, 0.04, 0.25);

		// Set up low-pass filter
		lpf.type(gam::LOW_PASS);
		lpf.freq(2000);
	}
예제 #10
0
	// re-initialize all member variables;
	inline void reset(double __sr, int __vs) { 
		__exception = 0;
		vectorsize = __vs;
		samplerate = __sr;
		m_smth_1 = 0;
		m_y_2 = 0;
		m_delay_3.reset("m_delay_3", 44100);
		m_tone_4 = 6000;
		m_depth_5 = 1;
		m_rate_6 = 5;
		m_cycle_7.reset(samplerate, 0);
		genlib_reset_complete(this);
		
	};
예제 #11
0
int Submodel::convertTimeAndExtentWith(const ASTNode* tcf, const ASTNode* xcf, const ASTNode* klmod)
{
  if (tcf==NULL && xcf==NULL) return LIBSBML_OPERATION_SUCCESS;
  Model* model = getInstantiation();
  if (model==NULL) {
    //getInstantiation sets its own error messages.
    return LIBSBML_OPERATION_FAILED;
  }
  ASTNode tcftimes(AST_TIMES);
  ASTNode tcfdiv(AST_DIVIDE);
  if (tcf != NULL) {
    tcftimes.addChild(tcf->deepCopy());
    tcfdiv.addChild(tcf->deepCopy());
  }
  ASTNode rxndivide(AST_DIVIDE);
  if (klmod != NULL) {
    ASTNode rxnref(AST_NAME);
    rxndivide.addChild(rxnref.deepCopy());
    rxndivide.addChild(klmod->deepCopy());
  }
  List* allElements = model->getAllElements();
  for (ListIterator iter = allElements->begin(); iter != allElements->end(); ++iter)
  {
    SBase* element = static_cast<SBase*>(*iter);
    assert(element != NULL);
    ASTNode* ast1 = NULL;
    ASTNode* ast2 = NULL;
    Constraint* constraint = NULL;
    Delay* delay = NULL;
    EventAssignment* ea = NULL;
    InitialAssignment* ia = NULL;
    KineticLaw* kl = NULL;
    Priority* priority = NULL;
    RateRule* rrule = NULL;
    Rule* rule = NULL;
    Submodel* submodel = NULL;
    Trigger* trigger = NULL;
    string cf = "";
    //Reaction math will be converted below, in the bits with the kinetic law.  But because of that, we need to handle references *to* the reaction:  even if it has no kinetic law, the units have changed, and this needs to be reflected by the flattening routine.
    if (rxndivide.getNumChildren() != 0 && element->getTypeCode()==SBML_REACTION && element->isSetId()) {
      rxndivide.getChild(0)->setName(element->getId().c_str());
      for (ListIterator iter = allElements->begin(); iter != allElements->end(); ++iter)
      {
        SBase* subelement = static_cast<SBase*>(*iter);
        subelement->replaceSIDWithFunction(element->getId(), &rxndivide);
      }
    }

    //Submodels need their timeConversionFactor and extentConversionFactor attributes converted.  We're moving top-down, so all we need to do here is fix the conversion factor attributes themselves, pointing them to new parameters if need be.
    if ((tcf !=NULL || xcf != NULL) && element->getTypeCode()==SBML_COMP_SUBMODEL) {
      submodel = static_cast<Submodel*>(element);
      if (tcf != NULL) {
        if (submodel->isSetTimeConversionFactor()) {
          createNewConversionFactor(cf, tcf, submodel->getTimeConversionFactor(), model);
          submodel->setTimeConversionFactor(cf);
        }
        else {
          submodel->setTimeConversionFactor(tcf->getName());
        }
      }
      if (xcf != NULL) {
        if (submodel->isSetExtentConversionFactor()) {
          createNewConversionFactor(cf, xcf, submodel->getExtentConversionFactor(), model);
          submodel->setExtentConversionFactor(cf);
        }
        else {
          submodel->setExtentConversionFactor(xcf->getName());
        }
      }
    }
    if (tcf==NULL) {
      if (klmod !=NULL && element->getTypeCode()==SBML_KINETIC_LAW) {
        kl = static_cast<KineticLaw*>(element);
        if (kl->isSetMath()) {
          ast1 = new ASTNode(AST_TIMES);
          ast1->addChild(klmod->deepCopy());
          ast1->addChild(kl->getMath()->deepCopy());
          kl->setMath(ast1);
          delete ast1;
        }
      }
    }
    else {
      // All math 'time' and 'delay' csymbols must still be converted.
      // Also, several constructs are modified directly.
      switch(element->getTypeCode()) {
        //This would be a WHOLE LOT SIMPLER if there was a 'hasMath' class in libsbml.  But even so, it would have to
        // handle the kinetic laws, rate rules, and delays separately.
      case SBML_KINETIC_LAW:
        //Kinetic laws are multiplied by 'klmod'.
        kl = static_cast<KineticLaw*>(element);
        ast1 = kl->getMath()->deepCopy();
        convertCSymbols(ast1, &tcfdiv, &tcftimes);
        if (klmod !=NULL) {
          kl = static_cast<KineticLaw*>(element);
          if (kl->isSetMath()) {
            ast2 = new ASTNode(AST_TIMES);
            ast2->addChild(klmod->deepCopy());
            ast2->addChild(ast1);
            kl->setMath(ast2);
            delete ast2;
          }
        }
        else {
          kl->setMath(ast1);
          delete ast1;
        }
        break;
      case SBML_DELAY:
        //Delays are multiplied by the time conversion factor.
        delay = static_cast<Delay*>(element);
        if (delay->isSetMath()) {
          ast1 = delay->getMath()->deepCopy();
          convertCSymbols(ast1, &tcfdiv, &tcftimes);
          tcftimes.addChild(ast1);
          delay->setMath(&tcftimes);
          tcftimes.removeChild(1);
          delete ast1;
        }
        break;
      case SBML_RATE_RULE:
        //Rate rules are divided by the time conversion factor.
        rrule = static_cast<RateRule*>(element);
        if (rrule->isSetMath()) {
          ast1 = rrule->getMath()->deepCopy();
          tcfdiv.insertChild(0, ast1);
          rrule->setMath(&tcfdiv);
          tcfdiv.removeChild(0);
          delete ast1;
        }
        //Fall through to:
      case SBML_ASSIGNMENT_RULE:
      case SBML_ALGEBRAIC_RULE:
        //Rules in general need csymbols converted.
        rule = static_cast<Rule*>(element);
        if (rule->isSetMath()) {
          ast1 = rule->getMath()->deepCopy();
          convertCSymbols(ast1, &tcfdiv, &tcftimes);
          rule->setMath(ast1);
          delete ast1;
        }
        break;
      case SBML_EVENT_ASSIGNMENT:
        //Event assignments need csymbols converted.
        ea = static_cast<EventAssignment*>(element);
        if (ea->isSetMath()) {
          ast1 = ea->getMath()->deepCopy();
          convertCSymbols(ast1, &tcfdiv, &tcftimes);
          ea->setMath(ast1);
          delete ast1;
        }
        break;
      case SBML_INITIAL_ASSIGNMENT:
        //Initial assignments need csymbols converted.
        ia = static_cast<InitialAssignment*>(element);
        if (ia->isSetMath()) {
          ast1 = ia->getMath()->deepCopy();
          convertCSymbols(ast1, &tcfdiv, &tcftimes);
          ia->setMath(ast1);
          delete ast1;
        }
        break;
      case SBML_CONSTRAINT:
        //Constraints need csymbols converted.
        constraint = static_cast<Constraint*>(element);
        if (constraint->isSetMath()) {
          ast1 = constraint->getMath()->deepCopy();
          convertCSymbols(ast1, &tcfdiv, &tcftimes);
          constraint->setMath(ast1);
          delete ast1;
        }
        break;
      case SBML_PRIORITY:
        //Priorities need csymbols converted.
        priority = static_cast<Priority*>(element);
        if (priority->isSetMath()) {
          ast1 = priority->getMath()->deepCopy();
          convertCSymbols(ast1, &tcfdiv, &tcftimes);
          priority->setMath(ast1);
          delete ast1;
        }
        break;
      case SBML_TRIGGER:
        //Triggers need csymbols converted.
        trigger = static_cast<Trigger*>(element);
        if (trigger->isSetMath()) {
          ast1 = trigger->getMath()->deepCopy();
          convertCSymbols(ast1, &tcfdiv, &tcftimes);
          trigger->setMath(ast1);
          delete ast1;
        }
        break;
      default:
        //Do nothing!  If we wanted to call a plugin routine, this would be the place.  The only other alternative is to #ifdef some code in here that deals with the math-containing package objects explicitly.  Which might be the best option, all told.
        break;
      }
    }
  }

  delete allElements;

  return LIBSBML_OPERATION_SUCCESS;
}
예제 #12
0
	// the signal processing routine;
	inline int perform(t_sample ** __ins, t_sample ** __outs, int __n) { 
		vectorsize = __n;
		const t_sample * __in1 = __ins[0];
		const t_sample * __in2 = __ins[1];
		t_sample * __out1 = __outs[0];
		t_sample * __out2 = __outs[1];
		if (__exception) { 
			return __exception;
			
		} else if (( (__in1 == 0) || (__in2 == 0) || (__out1 == 0) || (__out2 == 0) )) { 
			__exception = GENLIB_ERR_NULL_BUFFER;
			return __exception;
			
		};
		t_sample rsub_999 = (1 - m_bandwidth_22);
		t_sample expr_1051 = safepow(0.001, safediv(1, (m_revtime_19 * 44100)));
		t_sample expr_1052 = safediv((m_roomsize_20 * 44100), 340);
		t_sample mul_988 = (expr_1052 * 0.63245);
		t_sample expr_1043 = (-safepow(expr_1051, mul_988));
		t_sample mul_990 = (expr_1052 * 0.81649);
		t_sample expr_1045 = (-safepow(expr_1051, mul_990));
		t_sample mul_989 = (expr_1052 * 0.7071);
		t_sample expr_1044 = (-safepow(expr_1051, mul_989));
		t_sample mul_991 = (expr_1052 * 1);
		t_sample expr_1050 = (-safepow(expr_1051, mul_991));
		t_sample mul_985 = (expr_1052 * 0.000527);
		int int_984 = int(mul_985);
		t_sample mul_925 = (m_spread_21 * -0.380445);
		t_sample add_924 = (mul_925 + 931);
		t_sample rsub_921 = (1341 - add_924);
		t_sample mul_934 = (int_984 * rsub_921);
		t_sample mul_953 = (m_spread_21 * 0.376623);
		t_sample add_952 = (mul_953 + 931);
		t_sample rsub_949 = (1341 - add_952);
		t_sample mul_960 = (int_984 * rsub_949);
		t_sample add_914 = (expr_1052 + 5);
		t_sample expr_1046 = safepow(expr_1051, add_914);
		t_sample mul_920 = (expr_1052 * 0.41);
		t_sample add_917 = (mul_920 + 5);
		t_sample expr_1049 = safepow(expr_1051, add_917);
		t_sample mul_919 = (expr_1052 * 0.3);
		t_sample add_916 = (mul_919 + 5);
		t_sample expr_1048 = safepow(expr_1051, add_916);
		t_sample mul_918 = (expr_1052 * 0.155);
		t_sample add_915 = (mul_918 + 5);
		t_sample expr_1047 = safepow(expr_1051, add_915);
		t_sample mul_927 = (m_spread_21 * -0.568366);
		t_sample add_923 = (mul_927 + 369);
		t_sample rsub_922 = (add_924 - add_923);
		t_sample mul_941 = (int_984 * rsub_922);
		t_sample mul_983 = (expr_1052 * 0.110732);
		t_sample mul_969 = (m_spread_21 * 0.125541);
		t_sample add_951 = (mul_969 + 369);
		t_sample rsub_950 = (add_952 - add_951);
		t_sample mul_967 = (int_984 * rsub_950);
		t_sample add_926 = (mul_927 + 159);
		t_sample mul_948 = (int_984 * add_926);
		t_sample add_968 = (mul_969 + 159);
		t_sample mul_976 = (int_984 * add_968);
		// the main sample loop;
		while ((__n--)) { 
			const t_sample in1 = (*(__in1++));
			const t_sample in2 = (*(__in2++));
			t_sample mul_846 = (in2 * m_dry_24);
			t_sample mul_858 = (in1 * m_dry_24);
			t_sample mul_848 = ((in1 + in2) * 0.707);
			t_sample mix_1070 = (mul_848 + (rsub_999 * (m_history_5 - mul_848)));
			t_sample mix_998 = mix_1070;
			t_sample tap_888 = m_delay_17.read_linear(mul_988);
			t_sample mul_884 = (tap_888 * expr_1043);
			t_sample mix_1071 = (mul_884 + (m_damping_18 * (m_history_4 - mul_884)));
			t_sample mix_886 = mix_1071;
			t_sample tap_900 = m_delay_16.read_linear(mul_990);
			t_sample mul_896 = (tap_900 * expr_1045);
			t_sample mix_1072 = (mul_896 + (m_damping_18 * (m_history_3 - mul_896)));
			t_sample mix_898 = mix_1072;
			t_sample tap_894 = m_delay_15.read_linear(mul_989);
			t_sample mul_890 = (tap_894 * expr_1044);
			t_sample mix_1073 = (mul_890 + (m_damping_18 * (m_history_2 - mul_890)));
			t_sample mix_892 = mix_1073;
			t_sample tap_996 = m_delay_14.read_linear(mul_991);
			t_sample mul_987 = (tap_996 * expr_1050);
			t_sample mix_1074 = (mul_987 + (m_damping_18 * (m_history_1 - mul_987)));
			t_sample mix_994 = mix_1074;
			t_sample tap_933 = m_delay_13.read_linear(mul_934);
			t_sample mul_931 = (tap_933 * 0.625);
			t_sample tap_959 = m_delay_12.read_linear(mul_960);
			t_sample mul_957 = (tap_959 * 0.625);
			t_sample add_878 = (mix_994 + mix_898);
			t_sample add_876 = (mix_892 + mix_886);
			t_sample add_871 = (add_878 + add_876);
			t_sample mul_854 = (add_871 * 0.5);
			t_sample sub_875 = (add_878 - add_876);
			t_sample mul_857 = (sub_875 * 0.5);
			t_sample sub_877 = (mix_994 - mix_898);
			t_sample sub_874 = (mix_892 - mix_886);
			t_sample sub_873 = (sub_877 - sub_874);
			t_sample mul_856 = (sub_873 * 0.5);
			t_sample add_872 = (sub_877 + sub_874);
			t_sample rsub_870 = (0 - add_872);
			t_sample mul_855 = (rsub_870 * 0.5);
			t_sample tap_902 = m_delay_11.read_linear(add_917);
			t_sample tap_903 = m_delay_11.read_linear(add_916);
			t_sample tap_904 = m_delay_11.read_linear(add_915);
			t_sample tap_905 = m_delay_11.read_linear(add_914);
			t_sample mul_906 = (tap_905 * expr_1046);
			t_sample add_879 = (mul_854 + mul_906);
			t_sample mul_910 = (tap_903 * expr_1048);
			t_sample add_881 = (mul_856 + mul_910);
			t_sample mul_912 = (tap_902 * expr_1049);
			t_sample add_882 = (mul_857 + mul_912);
			t_sample mul_908 = (tap_904 * expr_1047);
			t_sample add_880 = (mul_855 + mul_908);
			t_sample tap_940 = m_delay_10.read_linear(mul_941);
			t_sample mul_938 = (tap_940 * 0.625);
			t_sample tap_982 = m_delay_9.read_linear(mul_983);
			t_sample tap_966 = m_delay_8.read_linear(mul_967);
			t_sample mul_964 = (tap_966 * 0.625);
			t_sample tap_947 = m_delay_7.read_linear(mul_948);
			t_sample mul_945 = (tap_947 * 0.75);
			t_sample mul_980 = (tap_982 * 0.75);
			t_sample sub_979 = (mix_998 - mul_980);
			t_sample mul_978 = (sub_979 * 0.75);
			t_sample add_977 = (mul_978 + tap_982);
			t_sample tap_975 = m_delay_6.read_linear(mul_976);
			t_sample mul_973 = (tap_975 * 0.75);
			t_sample mul_869 = (mul_857 * m_tail_23);
			t_sample mul_867 = (mul_855 * m_tail_23);
			t_sample add_853 = (mul_869 + mul_867);
			t_sample mul_868 = (mul_856 * m_tail_23);
			t_sample mul_866 = (mul_854 * m_tail_23);
			t_sample add_852 = (mul_868 + mul_866);
			t_sample sub_861 = (add_853 - add_852);
			t_sample mul_865 = (mul_912 * m_early_25);
			t_sample mul_863 = (mul_908 * m_early_25);
			t_sample add_851 = (mul_865 + mul_863);
			t_sample mul_864 = (mul_910 * m_early_25);
			t_sample mul_862 = (mul_906 * m_early_25);
			t_sample add_850 = (mul_864 + mul_862);
			t_sample sub_860 = (add_851 - add_850);
			t_sample add_847 = (sub_861 + sub_860);
			t_sample add_849 = (add_847 + in2);
			t_sample sub_944 = (add_849 - mul_945);
			t_sample mul_943 = (sub_944 * 0.75);
			t_sample add_942 = (mul_943 + tap_947);
			t_sample sub_937 = (add_942 - mul_938);
			t_sample mul_936 = (sub_937 * 0.625);
			t_sample add_935 = (mul_936 + tap_940);
			t_sample sub_930 = (add_935 - mul_931);
			t_sample mul_929 = (sub_930 * 0.625);
			t_sample add_928 = (mul_929 + tap_933);
			t_sample out2 = (mul_846 + add_928);
			t_sample add_859 = (add_847 + in1);
			t_sample sub_972 = (add_859 - mul_973);
			t_sample mul_971 = (sub_972 * 0.75);
			t_sample add_970 = (mul_971 + tap_975);
			t_sample sub_963 = (add_970 - mul_964);
			t_sample mul_962 = (sub_963 * 0.625);
			t_sample add_961 = (mul_962 + tap_966);
			t_sample sub_956 = (add_961 - mul_957);
			t_sample mul_955 = (sub_956 * 0.625);
			t_sample add_954 = (mul_955 + tap_959);
			t_sample out1 = (mul_858 + add_954);
			t_sample history_997_next_1065 = mix_998;
			t_sample history_885_next_1066 = mix_886;
			t_sample history_897_next_1067 = mix_898;
			t_sample history_891_next_1068 = mix_892;
			t_sample history_993_next_1069 = mix_994;
			m_delay_17.write(add_879);
			m_delay_16.write(add_881);
			m_delay_15.write(add_880);
			m_delay_14.write(add_882);
			m_delay_13.write(sub_930);
			m_delay_12.write(sub_956);
			m_delay_11.write(add_977);
			m_delay_10.write(sub_937);
			m_delay_9.write(sub_979);
			m_delay_8.write(sub_963);
			m_delay_7.write(sub_944);
			m_delay_6.write(sub_972);
			m_history_5 = history_997_next_1065;
			m_history_4 = history_885_next_1066;
			m_history_3 = history_897_next_1067;
			m_history_2 = history_891_next_1068;
			m_history_1 = history_993_next_1069;
			m_delay_6.step();
			m_delay_7.step();
			m_delay_8.step();
			m_delay_9.step();
			m_delay_10.step();
			m_delay_11.step();
			m_delay_12.step();
			m_delay_13.step();
			m_delay_14.step();
			m_delay_15.step();
			m_delay_16.step();
			m_delay_17.step();
			// assign results to output buffer;
			(*(__out1++)) = out1;
			(*(__out2++)) = out2;
			
		};
		return __exception;
		
	};
예제 #13
0
	// the signal processing routine;
	inline int perform(t_sample ** __ins, t_sample ** __outs, int __n) { 
		vectorsize = __n;
		const t_sample * __in1 = __ins[0];
		t_sample * __out1 = __outs[0];
		if (__exception) { 
			return __exception;
			
		} else if (( (__in1 == 0) || (__out1 == 0) )) { 
			__exception = GENLIB_ERR_NULL_BUFFER;
			return __exception;
			
		};
		double mul_2327 = (m_resonance_13 * 0.125);
		double exp_2328 = exp(mul_2327);
		double mul_2326 = (exp_2328 * 0.882497);
		double mul_2322 = (mul_2326 * mul_2326);
		double expr_2437 = safediv(((m_cutoff_14 * 2) * 3.1415926535898), 44100);
		double cos_2325 = cos(expr_2437);
		double mul_2324 = (cos_2325 * mul_2326);
		double mul_2323 = (mul_2324 * -2);
		double add_2321 = ((mul_2323 + mul_2322) + 1);
		double mstosamps_2393 = (m_window_15 * (samplerate * 0.001));
		double mstosamps_2309 = (m_window_19 * (samplerate * 0.001));
		double rsub_2296 = (1 - m_ratio_20);
		double mul_2295 = (rsub_2296 * 1000);
		double div_2294 = safediv(mul_2295, m_window_19);
		samples_to_seconds = (1 / samplerate);
		double rsub_2380 = (1 - m_ratio_18);
		double mul_2379 = (rsub_2380 * 1000);
		double div_2378 = safediv(mul_2379, m_window_15);
		// the main sample loop;
		while ((__n--)) { 
			const double in1 = (*(__in1++));
			double noise_2247 = noise();
			double abs_2264 = fabs(noise_2247);
			double mul_2270 = (abs_2264 * m_blur_17);
			double noise_2246 = noise();
			double abs_2263 = fabs(noise_2246);
			double mul_2267 = (abs_2263 * m_blur_17);
			double noise_2330 = noise();
			double abs_2348 = fabs(noise_2330);
			double mul_2354 = (abs_2348 * m_blur_17);
			double noise_2332 = noise();
			double abs_2350 = fabs(noise_2332);
			double mul_2360 = (abs_2350 * m_blur_17);
			double noise_2249 = noise();
			double abs_2266 = fabs(noise_2249);
			double mul_2276 = (abs_2266 * m_blur_17);
			double noise_2248 = noise();
			double abs_2265 = fabs(noise_2248);
			double mul_2273 = (abs_2265 * m_blur_17);
			double noise_2331 = noise();
			double abs_2349 = fabs(noise_2331);
			double mul_2357 = (abs_2349 * m_blur_17);
			double noise_2329 = noise();
			double abs_2347 = fabs(noise_2329);
			double mul_2351 = (abs_2347 * m_blur_17);
			double mul_2318 = (mul_2322 * m_y_10);
			double mul_2319 = (mul_2323 * m_y_1);
			double phasor_2315 = m_phasor_21(div_2294, samples_to_seconds);
			double add_2293 = ((phasor_2315 + m_history_9) + 0.5);
			double mod_2292 = safemod(add_2293, 1);
			double delta_2272 = m_delta_22(mod_2292);
			double sah_2252 = m_sah_23(mul_2270, delta_2272, 0);
			double sah_2271 = m_sah_24(mstosamps_2309, delta_2272, 0);
			double mul_2260 = (sah_2271 * mod_2292);
			double sub_2291 = (mod_2292 - 0.5);
			double mul_2290 = (sub_2291 * 3.1415926535898);
			double cos_2289 = cos(mul_2290);
			double mul_2279 = (cos_2289 * cos_2289);
			double add_2287 = ((phasor_2315 + m_history_8) + 0.75);
			double mod_2286 = safemod(add_2287, 1);
			double delta_2269 = m_delta_25(mod_2286);
			double sah_2250 = m_sah_26(mul_2267, delta_2269, 0);
			double sah_2268 = m_sah_27(mstosamps_2309, delta_2269, 0);
			double mul_2259 = (sah_2268 * mod_2286);
			double sub_2285 = (mod_2286 - 0.5);
			double mul_2284 = (sub_2285 * 3.1415926535898);
			double cos_2283 = cos(mul_2284);
			double mul_2278 = (cos_2283 * cos_2283);
			double add_2314 = ((phasor_2315 + m_history_7) + 0);
			double mod_2313 = safemod(add_2314, 1);
			double delta_2257 = m_delta_28(mod_2313);
			double sah_2256 = m_sah_29(mul_2276, delta_2257, 0);
			double sah_2277 = m_sah_30(mstosamps_2309, delta_2257, 0);
			double mul_2262 = (sah_2277 * mod_2313);
			double sub_2312 = (mod_2313 - 0.5);
			double mul_2311 = (sub_2312 * 3.1415926535898);
			double cos_2310 = cos(mul_2311);
			double mul_2281 = (cos_2310 * cos_2310);
			double add_2308 = ((phasor_2315 + m_history_6) + 0.25);
			double mod_2307 = safemod(add_2308, 1);
			double delta_2275 = m_delta_31(mod_2307);
			double sah_2254 = m_sah_32(mul_2273, delta_2275, 0);
			double sah_2274 = m_sah_33(mstosamps_2309, delta_2275, 0);
			double mul_2261 = (sah_2274 * mod_2307);
			double tap_2300 = m_delay_12.read_linear(mul_2262);
			double tap_2301 = m_delay_12.read_linear(mul_2261);
			double tap_2302 = m_delay_12.read_linear(mul_2260);
			double tap_2303 = m_delay_12.read_linear(mul_2259);
			double mul_2282 = (tap_2303 * mul_2278);
			double mul_2288 = (tap_2302 * mul_2279);
			double mul_2298 = (tap_2300 * mul_2281);
			double sub_2306 = (mod_2307 - 0.5);
			double mul_2305 = (sub_2306 * 3.1415926535898);
			double cos_2304 = cos(mul_2305);
			double mul_2280 = (cos_2304 * cos_2304);
			double mul_2297 = (tap_2301 * mul_2280);
			double phasor_2399 = m_phasor_34(div_2378, samples_to_seconds);
			double add_2377 = ((m_history_5 + phasor_2399) + 0.5);
			double mod_2376 = safemod(add_2377, 1);
			double delta_2356 = m_delta_35(mod_2376);
			double sah_2335 = m_sah_36(mul_2354, delta_2356, 0);
			double sah_2355 = m_sah_37(mstosamps_2393, delta_2356, 0);
			double mul_2344 = (sah_2355 * mod_2376);
			double sub_2375 = (mod_2376 - 0.5);
			double mul_2374 = (sub_2375 * 3.1415926535898);
			double cos_2373 = cos(mul_2374);
			double mul_2363 = (cos_2373 * cos_2373);
			double add_2398 = ((m_history_4 + phasor_2399) + 0);
			double mod_2397 = safemod(add_2398, 1);
			double delta_2340 = m_delta_38(mod_2397);
			double sah_2339 = m_sah_39(mul_2360, delta_2340, 0);
			double sah_2361 = m_sah_40(mstosamps_2393, delta_2340, 0);
			double mul_2346 = (sah_2361 * mod_2397);
			double sub_2396 = (mod_2397 - 0.5);
			double mul_2395 = (sub_2396 * 3.1415926535898);
			double cos_2394 = cos(mul_2395);
			double mul_2365 = (cos_2394 * cos_2394);
			double add_2392 = ((m_history_3 + phasor_2399) + 0.25);
			double mod_2391 = safemod(add_2392, 1);
			double delta_2359 = m_delta_41(mod_2391);
			double sah_2337 = m_sah_42(mul_2357, delta_2359, 0);
			double sah_2358 = m_sah_43(mstosamps_2393, delta_2359, 0);
			double mul_2345 = (sah_2358 * mod_2391);
			double sub_2390 = (mod_2391 - 0.5);
			double mul_2389 = (sub_2390 * 3.1415926535898);
			double cos_2388 = cos(mul_2389);
			double mul_2364 = (cos_2388 * cos_2388);
			double add_2371 = ((m_history_2 + phasor_2399) + 0.75);
			double mod_2370 = safemod(add_2371, 1);
			double delta_2353 = m_delta_44(mod_2370);
			double sah_2333 = m_sah_45(mul_2351, delta_2353, 0);
			double sah_2352 = m_sah_46(mstosamps_2393, delta_2353, 0);
			double mul_2343 = (sah_2352 * mod_2370);
			double tap_2384 = m_delay_11.read_linear(mul_2346);
			double tap_2385 = m_delay_11.read_linear(mul_2345);
			double tap_2386 = m_delay_11.read_linear(mul_2344);
			double tap_2387 = m_delay_11.read_linear(mul_2343);
			double mul_2382 = (tap_2384 * mul_2365);
			double mul_2381 = (tap_2385 * mul_2364);
			double mul_2372 = (tap_2386 * mul_2363);
			double sub_2369 = (mod_2370 - 0.5);
			double mul_2368 = (sub_2369 * 3.1415926535898);
			double cos_2367 = cos(mul_2368);
			double mul_2362 = (cos_2367 * cos_2367);
			double mul_2366 = (tap_2387 * mul_2362);
			double mul_2320 = ((((((((mul_2298 + mul_2297) + mul_2288) + mul_2282) + mul_2366) + mul_2372) + mul_2381) + mul_2382) * add_2321);
			double sub_2317 = (mul_2320 - (mul_2319 + mul_2318));
			double mix_2450 = (in1 + (m_mix_16 * (sub_2317 - in1)));
			double out1 = mix_2450;
			double y2_next_2440 = m_y_1;
			double history_2253_next_2441 = sah_2252;
			double history_2251_next_2442 = sah_2250;
			double history_2258_next_2443 = sah_2256;
			double history_2255_next_2444 = sah_2254;
			double history_2336_next_2445 = sah_2335;
			double history_2341_next_2446 = sah_2339;
			double history_2338_next_2447 = sah_2337;
			double history_2334_next_2448 = sah_2333;
			double y1_next_2449 = sub_2317;
			m_delay_12.write(in1);
			m_delay_11.write(in1);
			m_y_10 = y2_next_2440;
			m_history_9 = history_2253_next_2441;
			m_history_8 = history_2251_next_2442;
			m_history_7 = history_2258_next_2443;
			m_history_6 = history_2255_next_2444;
			m_history_5 = history_2336_next_2445;
			m_history_4 = history_2341_next_2446;
			m_history_3 = history_2338_next_2447;
			m_history_2 = history_2334_next_2448;
			m_y_1 = y1_next_2449;
			m_delay_11.step();
			m_delay_12.step();
			// assign results to output buffer;
			(*(__out1++)) = out1;
			
		};
		return __exception;
		
	};
예제 #14
0
	// re-initialize all member variables;
	inline void reset(t_sample __sr, int __vs) {
		__exception = 0;
		vectorsize = __vs;
		samplerate = __sr;
		m_history_1 = 0;
		m_history_2 = 0;
		m_history_3 = 0;
		m_history_4 = 0;
		m_history_5 = 0;
		m_delay_6.reset("m_delay_6", 5000);
		m_delay_7.reset("m_delay_7", 7000);
		m_delay_8.reset("m_delay_8", 15000);
		m_delay_9.reset("m_delay_9", 6000);
		m_delay_10.reset("m_delay_10", 16000);
		m_delay_11.reset("m_delay_11", 48000);
		m_delay_12.reset("m_delay_12", 10000);
		m_delay_13.reset("m_delay_13", 12000);
		m_delay_14.reset("m_delay_14", 48000);
		m_delay_15.reset("m_delay_15", 48000);
		m_delay_16.reset("m_delay_16", 48000);
		m_delay_17.reset("m_delay_17", 48000);
		m_damping_18 = 0.7;
		m_revtime_19 = 11;
		m_roomsize_20 = 75;
		m_spread_21 = 23;
		m_bandwidth_22 = 0.5;
		m_tail_23 = 0.25;
		m_dry_24 = 1;
		m_early_25 = 0.25;
		genlib_reset_complete(this);
		
	};
예제 #15
0
파일: helm_engine.cpp 프로젝트: hztirf/helm
  void HelmEngine::init() {
    static const Value* minutes_per_second = new Value(1.0 / 60.0);

#ifdef FE_DFL_DISABLE_SSE_DENORMS_ENV
    fesetenv(FE_DFL_DISABLE_SSE_DENORMS_ENV);
#endif

    Processor* beats_per_minute = createMonoModControl("beats_per_minute", false);
    Multiply* beats_per_second = new Multiply();
    beats_per_second->plug(beats_per_minute, 0);
    beats_per_second->plug(minutes_per_second, 1);
    addProcessor(beats_per_second);

    // Voice Handler.
    Processor* polyphony = createMonoModControl("polyphony", true);

    voice_handler_ = new HelmVoiceHandler(beats_per_second);
    addSubmodule(voice_handler_);
    voice_handler_->setPolyphony(32);
    voice_handler_->plug(polyphony, VoiceHandler::kPolyphony);

    // Monophonic LFO 1.
    Processor* lfo_1_waveform = createMonoModControl("mono_lfo_1_waveform", true);
    Processor* lfo_1_free_frequency = createMonoModControl("mono_lfo_1_frequency", true, false);
    Processor* lfo_1_free_amplitude = createMonoModControl("mono_lfo_1_amplitude", true);
    Processor* lfo_1_frequency = createTempoSyncSwitch("mono_lfo_1", lfo_1_free_frequency,
                                                       beats_per_second, false);

    lfo_1_ = new HelmLfo();
    lfo_1_->plug(lfo_1_waveform, HelmLfo::kWaveform);
    lfo_1_->plug(lfo_1_frequency, HelmLfo::kFrequency);

    Multiply* scaled_lfo_1 = new Multiply();
    scaled_lfo_1->setControlRate();
    scaled_lfo_1->plug(lfo_1_, 0);
    scaled_lfo_1->plug(lfo_1_free_amplitude, 1);

    addProcessor(lfo_1_);
    addProcessor(scaled_lfo_1);
    mod_sources_["mono_lfo_1"] = scaled_lfo_1->output();
    mod_sources_["mono_lfo_1_phase"] = lfo_1_->output(Oscillator::kPhase);

    // Monophonic LFO 2.
    Processor* lfo_2_waveform = createMonoModControl("mono_lfo_2_waveform", true);
    Processor* lfo_2_free_frequency = createMonoModControl("mono_lfo_2_frequency", true, false);
    Processor* lfo_2_free_amplitude = createMonoModControl("mono_lfo_2_amplitude", true);
    Processor* lfo_2_frequency = createTempoSyncSwitch("mono_lfo_2", lfo_2_free_frequency,
                                                       beats_per_second, false);

    lfo_2_ = new HelmLfo();
    lfo_2_->plug(lfo_2_waveform, HelmLfo::kWaveform);
    lfo_2_->plug(lfo_2_frequency, HelmLfo::kFrequency);

    Multiply* scaled_lfo_2 = new Multiply();
    scaled_lfo_2->setControlRate();
    scaled_lfo_2->plug(lfo_2_, 0);
    scaled_lfo_2->plug(lfo_2_free_amplitude, 1);

    addProcessor(lfo_2_);
    addProcessor(scaled_lfo_2);
    mod_sources_["mono_lfo_2"] = scaled_lfo_2->output();
    mod_sources_["mono_lfo_2_phase"] = lfo_2_->output(Oscillator::kPhase);

    // Step Sequencer.
    Processor* num_steps = createMonoModControl("num_steps", true);
    Processor* step_smoothing = createMonoModControl("step_smoothing", true);
    Processor* step_free_frequency = createMonoModControl("step_frequency", false, false);
    Processor* step_frequency = createTempoSyncSwitch("step_sequencer", step_free_frequency,
                                                      beats_per_second, false);

    step_sequencer_ = new StepGenerator(MAX_STEPS);
    step_sequencer_->plug(num_steps, StepGenerator::kNumSteps);
    step_sequencer_->plug(step_frequency, StepGenerator::kFrequency);

    for (int i = 0; i < MAX_STEPS; ++i) {
      std::stringstream stream;
      stream << i;
      std::string num = stream.str();
      if (num.length() == 1)
        num = "0" + num;
      Processor* step = createBaseControl(std::string("step_seq_") + num);
      step_sequencer_->plug(step, StepGenerator::kSteps + i);
    }

    SmoothFilter* smoothed_step_sequencer = new SmoothFilter();
    smoothed_step_sequencer->plug(step_sequencer_, SmoothFilter::kTarget);
    smoothed_step_sequencer->plug(step_smoothing, SmoothFilter::kHalfLife);

    addProcessor(step_sequencer_);
    addProcessor(smoothed_step_sequencer);

    mod_sources_["step_sequencer"] = smoothed_step_sequencer->output();
    mod_sources_["step_sequencer_step"] = step_sequencer_->output(StepGenerator::kStep);

    // Arpeggiator.
    Processor* arp_free_frequency = createMonoModControl("arp_frequency", true, false);
    Processor* arp_frequency = createTempoSyncSwitch("arp", arp_free_frequency,
                                                     beats_per_second, false);
    Processor* arp_octaves = createMonoModControl("arp_octaves", true);
    Processor* arp_pattern = createMonoModControl("arp_pattern", true);
    Processor* arp_gate = createMonoModControl("arp_gate", true);
    arp_on_ = createBaseControl("arp_on");
    arpeggiator_ = new Arpeggiator(voice_handler_);
    arpeggiator_->plug(arp_frequency, Arpeggiator::kFrequency);
    arpeggiator_->plug(arp_octaves, Arpeggiator::kOctaves);
    arpeggiator_->plug(arp_pattern, Arpeggiator::kPattern);
    arpeggiator_->plug(arp_gate, Arpeggiator::kGate);

    addProcessor(arpeggiator_);
    addProcessor(voice_handler_);

    // Delay effect.
    Processor* delay_free_frequency = createMonoModControl("delay_frequency", false, false);
    Processor* delay_frequency = createTempoSyncSwitch("delay", delay_free_frequency,
                                                       beats_per_second, false);
    Processor* delay_feedback = createMonoModControl("delay_feedback", false, true);
    Processor* delay_wet = createMonoModControl("delay_dry_wet", false, true);
    Value* delay_on = createBaseControl("delay_on");

    Clamp* delay_feedback_clamped = new Clamp(-1, 1);
    delay_feedback_clamped->plug(delay_feedback);

    SmoothFilter* delay_frequency_smoothed = new SmoothFilter();
    delay_frequency_smoothed->plug(delay_frequency, SmoothFilter::kTarget);
    delay_frequency_smoothed->plug(&utils::value_half, SmoothFilter::kHalfLife);
    FrequencyToSamples* delay_samples = new FrequencyToSamples();
    delay_samples->plug(delay_frequency_smoothed);

    Delay* delay = new Delay(MAX_DELAY_SAMPLES);
    delay->plug(voice_handler_, Delay::kAudio);
    delay->plug(delay_samples, Delay::kSampleDelay);
    delay->plug(delay_feedback_clamped, Delay::kFeedback);
    delay->plug(delay_wet, Delay::kWet);

    BypassRouter* delay_container = new BypassRouter();
    delay_container->plug(delay_on, BypassRouter::kOn);
    delay_container->plug(voice_handler_, BypassRouter::kAudio);
    delay_container->addProcessor(delay_feedback_clamped);
    delay_container->addProcessor(delay_frequency_smoothed);
    delay_container->addProcessor(delay_samples);
    delay_container->addProcessor(delay);
    delay_container->registerOutput(delay->output());

    addProcessor(delay_container);

    // Reverb Effect.
    Processor* reverb_feedback = createMonoModControl("reverb_feedback", false, true);
    Processor* reverb_damping = createMonoModControl("reverb_damping", false, true);
    Processor* reverb_wet = createMonoModControl("reverb_dry_wet", false, true);
    Value* reverb_on = createBaseControl("reverb_on");

    Clamp* reverb_feedback_clamped = new Clamp(-1, 1);
    reverb_feedback_clamped->plug(reverb_feedback);

    Reverb* reverb = new Reverb();
    reverb->plug(delay, Reverb::kAudio);
    reverb->plug(reverb_feedback_clamped, Reverb::kFeedback);
    reverb->plug(reverb_damping, Reverb::kDamping);
    reverb->plug(reverb_wet, Reverb::kWet);

    BypassRouter* reverb_container = new BypassRouter();
    reverb_container->plug(reverb_on, BypassRouter::kOn);
    reverb_container->plug(delay, BypassRouter::kAudio);
    reverb_container->addProcessor(reverb);
    reverb_container->addProcessor(reverb_feedback_clamped);
    reverb_container->registerOutput(reverb->output(0));
    reverb_container->registerOutput(reverb->output(1));

    addProcessor(reverb_container);

    // Soft Clipping.
    Distortion* distorted_clamp_left = new Distortion();
    Value* distortion_type = new Value(Distortion::kTanh);
    Value* distortion_threshold = new Value(0.9);
    distorted_clamp_left->plug(reverb_container->output(0), Distortion::kAudio);
    distorted_clamp_left->plug(distortion_type, Distortion::kType);
    distorted_clamp_left->plug(distortion_threshold, Distortion::kThreshold);

    Distortion* distorted_clamp_right = new Distortion();
    distorted_clamp_right->plug(reverb_container->output(1), Distortion::kAudio);
    distorted_clamp_right->plug(distortion_type, Distortion::kType);
    distorted_clamp_right->plug(distortion_threshold, Distortion::kThreshold);

    // Volume.
    Processor* volume = createMonoModControl("volume", false, true);
    Multiply* scaled_audio_left = new Multiply();
    scaled_audio_left->plug(distorted_clamp_left, 0);
    scaled_audio_left->plug(volume, 1);

    Multiply* scaled_audio_right = new Multiply();
    scaled_audio_right->plug(distorted_clamp_right, 0);
    scaled_audio_right->plug(volume, 1);

    addProcessor(distorted_clamp_left);
    addProcessor(distorted_clamp_right);
    addProcessor(scaled_audio_left);
    addProcessor(scaled_audio_right);
    registerOutput(scaled_audio_left->output());
    registerOutput(scaled_audio_right->output());

    HelmModule::init();
  }
예제 #16
0
{
	Delay<float, ipl::Trunc, Domain1> delay(4);
	//assert(delay.size() == 4);

	delay.zero();

	// Test normal filtering (delaying) operation
	assert(0 == delay(1));
	assert(0 == delay(2));
	assert(0 == delay(3));
	assert(0 == delay(4));
	assert(1 == delay(5));
	assert(2 == delay(6));

	assert(6 == delay.read(1));
	assert(5 == delay.read(2));
	assert(4 == delay.read(3));
	assert(3 == delay.read(4));
}
예제 #17
0
void Module::CreateSBMLModel()
{
  Model* sbmlmod = m_sbml.createModel();
  sbmlmod->setId(m_modulename);
  sbmlmod->setName(m_modulename);
  sbmlmod->setNotes("<body xmlns=\"http://www.w3.org/1999/xhtml\"><p> Originally created by libAntimony " VERSION_STRING " (using libSBML " LIBSBML_DOTTED_VERSION ") </p></body>");
  char cc = g_registry.GetCC();
  //User-defined functions
  for (size_t uf=0; uf<g_registry.GetNumUserFunctions(); uf++) {
    const UserFunction* userfunction = g_registry.GetNthUserFunction(uf);
    assert(userfunction != NULL);
    FunctionDefinition* fd = sbmlmod->createFunctionDefinition();
    fd->setId(userfunction->GetModuleName());
    ASTNode* math = parseStringToASTNode(userfunction->ToSBMLString());
    fd->setMath(math);
    delete math;
  }
  //Compartments
  Compartment* defaultCompartment = sbmlmod->createCompartment();
  defaultCompartment->setId(DEFAULTCOMP);
  defaultCompartment->setConstant(true);
  defaultCompartment->setSize(1);
  defaultCompartment->setSBOTerm(410); //The 'implicit compartment'
  size_t numcomps = GetNumVariablesOfType(allCompartments);
  for (size_t comp=0; comp<numcomps; comp++) {
    const Variable* compartment = GetNthVariableOfType(allCompartments, comp);
    Compartment* sbmlcomp = sbmlmod->createCompartment();
    sbmlcomp->setId(compartment->GetNameDelimitedBy(cc));
    if (compartment->GetDisplayName() != "") {
      sbmlcomp->setName(compartment->GetDisplayName());
    }
    sbmlcomp->setConstant(compartment->GetIsConst());
    formula_type ftype = compartment->GetFormulaType();
    assert (ftype == formulaINITIAL || ftype==formulaASSIGNMENT || ftype==formulaRATE);
    if (ftype != formulaINITIAL) {
      sbmlcomp->setConstant(false);
    }
    const Formula* formula = compartment->GetFormula();
    if (formula->IsDouble()) {
      sbmlcomp->setSize(atof(formula->ToSBMLString().c_str()));
    }
    SetAssignmentFor(sbmlmod, compartment);
  }

  //Species
  size_t numspecies = GetNumVariablesOfType(allSpecies);
  for (size_t spec=0; spec < numspecies; spec++) {
    const Variable* species = GetNthVariableOfType(allSpecies, spec);
    Species* sbmlspecies = sbmlmod->createSpecies();
    sbmlspecies->setId(species->GetNameDelimitedBy(cc));
    if (species->GetDisplayName() != "") {
      sbmlspecies->setName(species->GetDisplayName());
    }
    sbmlspecies->setConstant(false); //There's no need to try to distinguish between const and var for species.
    if (species->GetIsConst()) {
      sbmlspecies->setBoundaryCondition(true);
    }
    else {
      sbmlspecies->setBoundaryCondition(false);
    }
    const Variable* compartment = species->GetCompartment();
    if (compartment == NULL) {
      sbmlspecies->setCompartment(defaultCompartment->getId());
    }
    else {
      sbmlspecies->setCompartment(compartment->GetNameDelimitedBy(cc));
    }
    const Formula* formula = species->GetFormula();
    if (formula->IsDouble()) {
      sbmlspecies->setInitialConcentration(atof(formula->ToSBMLString().c_str()));
    }
    else if (formula->IsAmountIn(species->GetCompartment())) {
      sbmlspecies->setInitialAmount(formula->ToAmount());
    }
    SetAssignmentFor(sbmlmod, species);
  }

  //Formulas
  size_t numforms = GetNumVariablesOfType(allFormulas);
  for (size_t form=0; form < numforms; form++) {
    const Variable* formvar = GetNthVariableOfType(allFormulas, form);
    const Formula*  formula = formvar->GetFormula();
    Parameter* param = sbmlmod->createParameter();
    param->setId(formvar->GetNameDelimitedBy(cc));
    if (formvar->GetDisplayName() != "") {
      param->setName(formvar->GetDisplayName());
    }
    param->setConstant(formvar->GetIsConst());
    if (formula->IsDouble()) {
      param->setValue(atof(formula->ToSBMLString().c_str()));
    }
    SetAssignmentFor(sbmlmod, formvar);
    formula_type ftype = formvar->GetFormulaType();
    assert (ftype == formulaINITIAL || ftype==formulaASSIGNMENT || ftype==formulaRATE);
    if (ftype != formulaINITIAL) {
      param->setConstant(false);
    }
  }

  //Reactions
  size_t numrxns = GetNumVariablesOfType(allReactions);
  for (size_t rxn=0; rxn < numrxns; rxn++) {
    const Variable* rxnvar = GetNthVariableOfType(allReactions, rxn);
    const AntimonyReaction* reaction = rxnvar->GetReaction();
    if (reaction->IsEmpty()) {
      continue; //Reactions that involve no species are illegal in SBML.
    }
    Reaction* sbmlrxn = sbmlmod->createReaction();
    sbmlrxn->setId(rxnvar->GetNameDelimitedBy(cc));
    if (rxnvar->GetDisplayName() != "") {
      sbmlrxn->setName(rxnvar->GetDisplayName());
    }
    if (reaction->GetType() == rdBecomes) {
      sbmlrxn->setReversible(true);
    }
    else {
      assert(reaction->GetType() == rdBecomesIrreversibly);
      sbmlrxn->setReversible(false);
    }
    const Formula* formula = reaction->GetFormula();
    string formstring = formula->ToSBMLString(rxnvar->GetStrandVars());
    if (!formula->IsEmpty()) {
      KineticLaw* kl = sbmlmod->createKineticLaw();
      ASTNode* math = parseStringToASTNode(formstring);
      kl->setMath(math);
      delete math;
    }
    const ReactantList* left = reaction->GetLeft();
    for (size_t lnum=0; lnum<left->Size(); lnum++) {
      const Variable* nthleft = left->GetNthReactant(lnum);
      double nthstoich = left->GetStoichiometryFor(lnum);
      SpeciesReference* sr = sbmlmod->createReactant();
      sr->setSpecies(nthleft->GetNameDelimitedBy(cc));
      sr->setStoichiometry(nthstoich);
    }
    const ReactantList* right = reaction->GetRight();
    for (size_t rnum=0; rnum<right->Size(); rnum++) {
      const Variable* nthright = right->GetNthReactant(rnum);
      double nthstoich = right->GetStoichiometryFor(rnum);
      SpeciesReference* sr = sbmlmod->createProduct();
      sr->setSpecies(nthright->GetNameDelimitedBy(cc));
      sr->setStoichiometry(nthstoich);
    }
    //Find 'modifiers' and add them.
    vector<const Variable*> subvars = formula->GetVariablesFrom(formstring, m_modulename);
    for (size_t v=0; v<subvars.size(); v++) {
      if (subvars[v] != NULL && subvars[v]->GetType() == varSpeciesUndef) {
        if (left->GetStoichiometryFor(subvars[v]) == 0 &&
            right->GetStoichiometryFor(subvars[v]) == 0) {
          ModifierSpeciesReference* msr = sbmlmod->createModifier();
          msr->setSpecies(subvars[v]->GetNameDelimitedBy(cc));
        }
      }
    }
  }

  //Events
  size_t numevents = GetNumVariablesOfType(allEvents);
  for (size_t ev=0; ev < numevents; ev++) {
    const Variable* eventvar = GetNthVariableOfType(allEvents, ev);
    const AntimonyEvent* event = eventvar->GetEvent();
    Event* sbmlevent = sbmlmod->createEvent();
    sbmlevent->setId(eventvar->GetNameDelimitedBy(cc));
    if (eventvar->GetDisplayName() != "") {
      sbmlevent->setName(eventvar->GetDisplayName());
    }
    Trigger* trig = sbmlevent->createTrigger();
    ASTNode* ASTtrig = parseStringToASTNode(event->GetTrigger()->ToSBMLString());
    trig->setMath(ASTtrig);
    delete ASTtrig;
    const Formula* delay = event->GetDelay();
    if (!delay->IsEmpty()) {
      ASTtrig = parseStringToASTNode(delay->ToSBMLString());
      Delay* sbmldelay = sbmlevent->createDelay();
      sbmldelay->setMath(ASTtrig);
      delete ASTtrig;
    }
      
    long numasnts = static_cast<long>(event->GetNumAssignments());
    for (long asnt=numasnts-1; asnt>=0; asnt--) {
      //events are stored in reverse order.  Don't ask...
      EventAssignment* sbmlasnt = sbmlmod->createEventAssignment();
      sbmlasnt->setVariable(event->GetNthAssignmentVariableName(asnt, cc));
      ASTNode* ASTasnt = parseStringToASTNode(event->GetNthAssignmentFormulaString(asnt, '_', true));
      sbmlasnt->setMath(ASTasnt);
      delete ASTasnt;
    }
  }

  //Interactions
  size_t numinteractions = GetNumVariablesOfType(allInteractions);
  for (size_t irxn=0; irxn<numinteractions; irxn++) {
    const Variable* arxnvar = GetNthVariableOfType(allInteractions, irxn);
    const AntimonyReaction* arxn = arxnvar->GetReaction();
    Reaction* rxn = sbmlmod->getReaction(arxn->GetRight()->GetNthReactant(0)->GetNameDelimitedBy(cc));
    if (rxn != NULL) {
      for (size_t interactor=0; interactor<arxn->GetLeft()->Size(); interactor++) {
        ModifierSpeciesReference* msr = rxn->createModifier();
        msr->setSpecies(arxn->GetLeft()->GetNthReactant(interactor)->GetNameDelimitedBy(cc));
        msr->setName(arxnvar->GetNameDelimitedBy(cc));
      }
    }
  }

  //Unknown variables (turn into parameters)
  size_t numunknown = GetNumVariablesOfType(allUnknown);
  for (size_t form=0; form < numunknown; form++) {
    const Variable* formvar = GetNthVariableOfType(allUnknown, form);
    Parameter* param = sbmlmod->createParameter();
    param->setId(formvar->GetNameDelimitedBy(cc));
    if (formvar->GetDisplayName() != "") {
      param->setName(formvar->GetDisplayName());
    }
    switch(formvar->GetConstType()) {
    case constVAR:
      param->setConstant(true);
      break;
    case constCONST:
      param->setConstant(false);
      break;
    case constDEFAULT:
      break;
    }
  }
}
예제 #18
0
	// the signal processing routine;
	inline int perform(t_sample ** __ins, t_sample ** __outs, int __n) { 
		vectorsize = __n;
		const t_sample * __in1 = __ins[0];
		t_sample * __out1 = __outs[0];
		if (__exception) { 
			return __exception;
			
		} else if (( (__in1 == 0) || (__out1 == 0) )) { 
			__exception = GENLIB_ERR_NULL_BUFFER;
			return __exception;
			
		};
		double expr_5155 = safediv(((m_cutoff_16 * 2) * 3.1415926535898), 44100);
		double sin_5012 = sin(expr_5155);
		double clamp_5013 = ((sin_5012 <= 1e-05) ? 1e-05 : ((sin_5012 >= 0.99999) ? 0.99999 : sin_5012));
		double mstosamps_5148 = (m_delay_14 * (samplerate * 0.001));
		double mstosamps_5077 = (m_delay_18 * (samplerate * 0.001));
		double rsub_5064 = (1 - m_ratio_12);
		double mul_5063 = (rsub_5064 * 1000);
		double div_5062 = safediv(mul_5063, m_delay_18);
		samples_to_seconds = (1 / samplerate);
		double rsub_5135 = (1 - m_ratio_15);
		double mul_5134 = (rsub_5135 * 1000);
		double div_5133 = safediv(mul_5134, m_delay_14);
		// the main sample loop;
		while ((__n--)) { 
			const double in1 = (*(__in1++));
			double noise_5014 = noise();
			double abs_5031 = fabs(noise_5014);
			double mul_5035 = (abs_5031 * m_blur_17);
			double noise_5086 = noise();
			double abs_5104 = fabs(noise_5086);
			double mul_5112 = (abs_5104 * m_blur_17);
			double noise_5015 = noise();
			double abs_5032 = fabs(noise_5015);
			double mul_5038 = (abs_5032 * m_blur_17);
			double noise_5084 = noise();
			double abs_5102 = fabs(noise_5084);
			double mul_5106 = (abs_5102 * m_blur_17);
			double noise_5017 = noise();
			double abs_5034 = fabs(noise_5017);
			double mul_5044 = (abs_5034 * m_blur_17);
			double noise_5087 = noise();
			double abs_5105 = fabs(noise_5087);
			double mul_5115 = (abs_5105 * m_blur_17);
			double noise_5016 = noise();
			double abs_5033 = fabs(noise_5016);
			double mul_5041 = (abs_5033 * m_blur_17);
			double noise_5085 = noise();
			double abs_5103 = fabs(noise_5085);
			double mul_5109 = (abs_5103 * m_blur_17);
			double phasor_5083 = m_phasor_19(div_5062, samples_to_seconds);
			double add_5055 = ((phasor_5083 + m_history_9) + 0.75);
			double mod_5054 = safemod(add_5055, 1);
			double delta_5037 = m_delta_20(mod_5054);
			double sah_5018 = m_sah_21(mul_5035, delta_5037, 0);
			double sah_5036 = m_sah_22(mstosamps_5077, delta_5037, 0);
			double mul_5027 = (sah_5036 * mod_5054);
			double sub_5053 = (mod_5054 - 0.5);
			double mul_5052 = (sub_5053 * 3.1415926535898);
			double cos_5051 = cos(mul_5052);
			double mul_5046 = (cos_5051 * cos_5051);
			double add_5061 = ((phasor_5083 + m_history_8) + 0.5);
			double mod_5060 = safemod(add_5061, 1);
			double delta_5040 = m_delta_23(mod_5060);
			double sah_5020 = m_sah_24(mul_5038, delta_5040, 0);
			double sah_5039 = m_sah_25(mstosamps_5077, delta_5040, 0);
			double mul_5028 = (sah_5039 * mod_5060);
			double sub_5059 = (mod_5060 - 0.5);
			double mul_5058 = (sub_5059 * 3.1415926535898);
			double cos_5057 = cos(mul_5058);
			double mul_5047 = (cos_5057 * cos_5057);
			double add_5082 = ((phasor_5083 + m_history_7) + 0);
			double mod_5081 = safemod(add_5082, 1);
			double delta_5025 = m_delta_26(mod_5081);
			double sah_5024 = m_sah_27(mul_5044, delta_5025, 0);
			double sah_5045 = m_sah_28(mstosamps_5077, delta_5025, 0);
			double mul_5030 = (sah_5045 * mod_5081);
			double sub_5080 = (mod_5081 - 0.5);
			double mul_5079 = (sub_5080 * 3.1415926535898);
			double cos_5078 = cos(mul_5079);
			double mul_5049 = (cos_5078 * cos_5078);
			double add_5076 = ((phasor_5083 + m_history_6) + 0.25);
			double mod_5075 = safemod(add_5076, 1);
			double delta_5043 = m_delta_29(mod_5075);
			double sah_5022 = m_sah_30(mul_5041, delta_5043, 0);
			double sah_5042 = m_sah_31(mstosamps_5077, delta_5043, 0);
			double mul_5029 = (sah_5042 * mod_5075);
			double tap_5068 = m_delay_11.read_linear(mul_5030);
			double tap_5069 = m_delay_11.read_linear(mul_5029);
			double tap_5070 = m_delay_11.read_linear(mul_5028);
			double tap_5071 = m_delay_11.read_linear(mul_5027);
			double mul_5050 = (tap_5071 * mul_5046);
			double mul_5056 = (tap_5070 * mul_5047);
			double mul_5066 = (tap_5068 * mul_5049);
			double sub_5074 = (mod_5075 - 0.5);
			double mul_5073 = (sub_5074 * 3.1415926535898);
			double cos_5072 = cos(mul_5073);
			double mul_5048 = (cos_5072 * cos_5072);
			double mul_5065 = (tap_5069 * mul_5048);
			double phasor_5154 = m_phasor_32(div_5133, samples_to_seconds);
			double add_5147 = ((m_history_5 + phasor_5154) + 0.25);
			double mod_5146 = safemod(add_5147, 1);
			double delta_5114 = m_delta_33(mod_5146);
			double sah_5092 = m_sah_34(mul_5112, delta_5114, 0);
			double sah_5113 = m_sah_35(mstosamps_5148, delta_5114, 0);
			double mul_5100 = (sah_5113 * mod_5146);
			double sub_5145 = (mod_5146 - 0.5);
			double mul_5144 = (sub_5145 * 3.1415926535898);
			double cos_5143 = cos(mul_5144);
			double mul_5119 = (cos_5143 * cos_5143);
			double add_5126 = ((m_history_4 + phasor_5154) + 0.75);
			double mod_5125 = safemod(add_5126, 1);
			double delta_5108 = m_delta_36(mod_5125);
			double sah_5088 = m_sah_37(mul_5106, delta_5108, 0);
			double sah_5107 = m_sah_38(mstosamps_5148, delta_5108, 0);
			double mul_5098 = (sah_5107 * mod_5125);
			double sub_5124 = (mod_5125 - 0.5);
			double mul_5123 = (sub_5124 * 3.1415926535898);
			double cos_5122 = cos(mul_5123);
			double mul_5117 = (cos_5122 * cos_5122);
			double add_5153 = ((m_history_3 + phasor_5154) + 0);
			double mod_5152 = safemod(add_5153, 1);
			double delta_5095 = m_delta_39(mod_5152);
			double sah_5094 = m_sah_40(mul_5115, delta_5095, 0);
			double sah_5116 = m_sah_41(mstosamps_5148, delta_5095, 0);
			double mul_5101 = (sah_5116 * mod_5152);
			double sub_5151 = (mod_5152 - 0.5);
			double mul_5150 = (sub_5151 * 3.1415926535898);
			double cos_5149 = cos(mul_5150);
			double mul_5120 = (cos_5149 * cos_5149);
			double add_5132 = ((m_history_2 + phasor_5154) + 0.5);
			double mod_5131 = safemod(add_5132, 1);
			double delta_5111 = m_delta_42(mod_5131);
			double sah_5090 = m_sah_43(mul_5109, delta_5111, 0);
			double sah_5110 = m_sah_44(mstosamps_5148, delta_5111, 0);
			double mul_5099 = (sah_5110 * mod_5131);
			double tap_5139 = m_delay_10.read_linear(mul_5101);
			double tap_5140 = m_delay_10.read_linear(mul_5100);
			double tap_5141 = m_delay_10.read_linear(mul_5099);
			double tap_5142 = m_delay_10.read_linear(mul_5098);
			double mul_5137 = (tap_5139 * mul_5120);
			double mul_5136 = (tap_5140 * mul_5119);
			double mul_5121 = (tap_5142 * mul_5117);
			double sub_5130 = (mod_5131 - 0.5);
			double mul_5129 = (sub_5130 * 3.1415926535898);
			double cos_5128 = cos(mul_5129);
			double mul_5118 = (cos_5128 * cos_5128);
			double mul_5127 = (tap_5141 * mul_5118);
			double add_5174 = (((((((mul_5066 + mul_5065) + mul_5056) + mul_5050) + mul_5121) + mul_5127) + mul_5136) + mul_5137);
			double mix_5173 = (m_y_1 + (clamp_5013 * (add_5174 - m_y_1)));
			double mix_5010 = mix_5173;
			double mix_5175 = (in1 + (m_mix_13 * (mix_5010 - in1)));
			double out1 = mix_5175;
			double history_5019_next_5156 = sah_5018;
			double history_5021_next_5157 = sah_5020;
			double history_5026_next_5158 = sah_5024;
			double history_5023_next_5159 = sah_5022;
			double history_5093_next_5160 = sah_5092;
			double history_5089_next_5161 = sah_5088;
			double history_5096_next_5162 = sah_5094;
			double history_5091_next_5163 = sah_5090;
			double y0_next_5164 = mix_5010;
			m_delay_11.write(in1);
			m_delay_10.write(in1);
			m_history_9 = history_5019_next_5156;
			m_history_8 = history_5021_next_5157;
			m_history_7 = history_5026_next_5158;
			m_history_6 = history_5023_next_5159;
			m_history_5 = history_5093_next_5160;
			m_history_4 = history_5089_next_5161;
			m_history_3 = history_5096_next_5162;
			m_history_2 = history_5091_next_5163;
			m_y_1 = y0_next_5164;
			m_delay_10.step();
			m_delay_11.step();
			// assign results to output buffer;
			(*(__out1++)) = out1;
			
		};
		return __exception;
		
	};