예제 #1
0
 EEL_F *GetNamedVar(const char *s, bool createIfNotExists)
 {
   if (!*s) return NULL;
   EEL_F *r = m_namedvars.Get(s);
   if (r || !createIfNotExists) return r;
   r=NSEEL_VM_regvar(m_vm,s);
   if (r) m_namedvars.Insert(s,r);
   return r;
 }
예제 #2
0
IPlugEEL::IPlugEEL(IPlugInstanceInfo instanceInfo)
  :	IPLUG_CTOR(kNumParams, kNumPrograms, instanceInfo), mGain(1.)
{
  TRACE;
  
  vm = NSEEL_VM_alloc(); // create virtual machine
  
  mVmOutput = NSEEL_VM_regvar(vm, "x"); // register a variable into vm to get a value out

  memset(codetext, 0, 65536);
  strcpy(codetext, "x=rand(2)-1.;");
  
  codehandle = NSEEL_code_compile(vm, codetext, 0); // compile code

  //arguments are: name, defaultVal, minVal, maxVal, step, label
  GetParam(kGain)->InitDouble("Gain", 50., 0., 100.0, 0.01, "%");
  GetParam(kGain)->SetShape(2.);

  IGraphics* pGraphics = MakeGraphics(this, kWidth, kHeight);
  pGraphics->AttachPanelBackground(&COLOR_RED);

  IBitmap knob = pGraphics->LoadIBitmap(KNOB_ID, KNOB_FN, kKnobFrames);

  pGraphics->AttachControl(new IKnobMultiControl(this, kGainX, kGainY, kGain, &knob));
  
  IRECT textRect(5, 70, kWidth-5, kHeight-5);
  IText textProps(15, &COLOR_BLACK, "Arial", IText::kStyleNormal, IText::kAlignNear, 0, IText::kQualityDefault);
  
  mTextControl = new AlgDisplay(this, textRect, &textProps, codetext);
  pGraphics->AttachControl(mTextControl);

  AttachGraphics(pGraphics);

  //MakePreset("preset 1", ... );
  MakeDefaultPreset((char *) "-", kNumPrograms);
}
예제 #3
0
int main(int argc, char **argv)
{
  FILE *fp = stdin;
  int argpos = 1;
  while (argpos < argc && argv[argpos][0] == '-' && argv[argpos][1])
  {
    if (!strcmp(argv[argpos],"-v")) g_verbose++;
    else if (!strcmp(argv[argpos],"-i")) g_interactive++;
    else
    {
      printf("Usage: %s [-v] [-i | scriptfile | -]\n",argv[0]);
      return -1;
    }
    argpos++;
  }
  if (argpos < argc && !g_interactive)
  {
    fp = strcmp(argv[argpos],"-") ? fopen(argv[argpos],"r") : stdin;
    if (!fp)
    {
      printf("Error opening %s\n",argv[argpos]);
      return -1;
    }
    argpos++;
  }
  else
  {
#ifndef _WIN32
    if (!g_interactive && isatty(0)) 
#else
    if (1)
#endif
       g_interactive=1;
  }

  if (NSEEL_init())
  {
    printf("NSEEL_init(): error initializing\n");
    return -1;
  }
  EEL_string_register();
  EEL_file_register();

  WDL_FastString code,t;

  sInst inst;
  {
    const int argv_offs = 1<<22;
    code.SetFormatted(64,"argc=0; argv=%d;\n",argv_offs);
    int x;
    for (x=0;x<argc;x++)
    {
      if (x==0 || x >= argpos)
      {
        t.Set(argv[x]);
        code.AppendFormatted(64,"argv[argc]=%d; argc+=1;\n",inst.AddString(t));
      }
    }
    inst.runcode(code.Get(),true,true);
  }

  if (g_interactive)
  {
    printf("EEL interactive mode, type quit to quit, abort to abort multiline entry\n");
    EEL_F *resultVar = NSEEL_VM_regvar(inst.m_vm,"__result");
    code.Set("");
    char line[4096];
    for (;;)
    {
      if (!code.Get()[0]) printf("EEL> ");
      else printf("> ");
      fflush(stdout);
      line[0]=0;
      fgets(line,sizeof(line),fp);
      if (!line[0]) break;
      code.Append(line);
      while (line[0] && (
               line[strlen(line)-1] == '\r' ||
               line[strlen(line)-1] == '\n' ||
               line[strlen(line)-1] == '\t' ||
               line[strlen(line)-1] == ' '
              )) line[strlen(line)-1]=0;

      if (!strcmp(line,"quit")) break;
      if (!strcmp(line,"abort")) code.Set("");

      t.Set("__result = (");
      t.Append(code.Get());
      t.Append(");");
      int res=inst.runcode(t.Get(),false,true);
      if (!res)
      {
        if (resultVar) printf("=%g ",*resultVar);
        code.Set("");
      }
      else
      {
        res=inst.runcode(code.Get(),true, false);
        if (res<=0) code.Set("");
        // res>0 means need more lines
      }
    }
  }
  else
  {
    code.Set("");
    char line[4096];
    for (;;)
    {
      line[0]=0;
      fgets(line,sizeof(line),fp);
      if (!line[0]) break;
      code.Append(line);
    }
    if (fp != stdin) fclose(fp);

    inst.runcode(code.Get(),true,true);
    
  }

  return 0;
}
예제 #4
0
void texmgr::RegisterBuiltInVariables(int iSlot)
{
	NSEEL_VMCTX eel_ctx = m_tex[iSlot].tex_eel_ctx;
	NSEEL_VM_resetvars(eel_ctx);
	
	// input variables
    m_tex[iSlot].var_time        = NSEEL_VM_regvar(eel_ctx, "time");     
	m_tex[iSlot].var_frame       = NSEEL_VM_regvar(eel_ctx, "frame");    
	m_tex[iSlot].var_fps         = NSEEL_VM_regvar(eel_ctx, "fps");      
	m_tex[iSlot].var_progress    = NSEEL_VM_regvar(eel_ctx, "progress"); 
	m_tex[iSlot].var_bass        = NSEEL_VM_regvar(eel_ctx, "bass");     
	m_tex[iSlot].var_bass_att    = NSEEL_VM_regvar(eel_ctx, "bass_att"); 
	m_tex[iSlot].var_mid         = NSEEL_VM_regvar(eel_ctx, "mid");      
	m_tex[iSlot].var_mid_att     = NSEEL_VM_regvar(eel_ctx, "mid_att");  
	m_tex[iSlot].var_treb        = NSEEL_VM_regvar(eel_ctx, "treb");     
	m_tex[iSlot].var_treb_att    = NSEEL_VM_regvar(eel_ctx, "treb_att"); 
	
	// output variables
	m_tex[iSlot].var_x           = NSEEL_VM_regvar(eel_ctx, "x");        
	m_tex[iSlot].var_y           = NSEEL_VM_regvar(eel_ctx, "y");        
	m_tex[iSlot].var_sx          = NSEEL_VM_regvar(eel_ctx, "sx");       
	m_tex[iSlot].var_sy          = NSEEL_VM_regvar(eel_ctx, "sy");       
	m_tex[iSlot].var_repeatx     = NSEEL_VM_regvar(eel_ctx, "repeatx");       
	m_tex[iSlot].var_repeaty     = NSEEL_VM_regvar(eel_ctx, "repeaty");       
	m_tex[iSlot].var_rot         = NSEEL_VM_regvar(eel_ctx, "rot");      
	m_tex[iSlot].var_flipx       = NSEEL_VM_regvar(eel_ctx, "flipx");    
	m_tex[iSlot].var_flipy       = NSEEL_VM_regvar(eel_ctx, "flipy");    
	m_tex[iSlot].var_r           = NSEEL_VM_regvar(eel_ctx, "r");        
	m_tex[iSlot].var_g           = NSEEL_VM_regvar(eel_ctx, "g");        
	m_tex[iSlot].var_b           = NSEEL_VM_regvar(eel_ctx, "b");        
	m_tex[iSlot].var_a           = NSEEL_VM_regvar(eel_ctx, "a");        
	m_tex[iSlot].var_blendmode   = NSEEL_VM_regvar(eel_ctx, "blendmode");
	m_tex[iSlot].var_done        = NSEEL_VM_regvar(eel_ctx, "done"); 
	m_tex[iSlot].var_burn        = NSEEL_VM_regvar(eel_ctx, "burn"); 

//	resetVars(NULL);
}