Package de.maramuse.soundcomp.process

Examples of de.maramuse.soundcomp.process.SourceStore


  this.variables=variables;
  }
 
  SourceStore getElement(ParserVal val) throws UnknownConnectionException, TypeMismatchException{
  if(val instanceof TemplateProvider){
    return new SourceStore(createTree((TemplateProvider) val), StandardParameters.OUT.i);
  }
  if(val instanceof de.maramuse.soundcomp.parser.Number){
    return new SourceStore(ConstStream.c(val.asDouble()), StandardParameters.OUT.i);
  }
  if(val instanceof ConnectionPoint){
    ConnectionPoint cp=(ConnectionPoint)val;
    String elName=cp.getElementName();
    String coName=cp.getConnectionName();
    NamedSource src=subprocesses.get(elName);
    if(src==null)throw new IllegalArgumentException("Element "+elName+" not found");
    Parameter param=src.outputsByName().get(coName);
    if(param==null)throw new IllegalArgumentException("Output "+coName+" not found in element "+elName);
    return new SourceStore(src, param.i);
  }
  if(val instanceof Element){ // a variable or an input?
    String varName=val.getText();
    Variable v=variables.get(varName);
    if(v!=null)
    return new SourceStore(v, StandardParameters.OUT.i);
    SourceStore ret=process.getInputProxy(varName);
    if(ret==null)throw new IllegalArgumentException(varName+" not found in element "+process.getAbstractName()+", should be an input or variable");
    return ret;
  }
  throw new IllegalArgumentException("Illegal element "+val.getClass().getName()+" in formula");
  }
View Full Code Here


  public NamedSource createTree(TemplateProvider element)
      throws UnknownConnectionException, TypeMismatchException{
  ProcessElement pe=element.getTemplate().clone();
  if(element instanceof FormulaElement3){
    ParserVal v1=((FormulaElement1)element).getInput1Val();
    SourceStore e1=getElement(v1);
    pe.setSource(StandardParameters.IN.i, e1.source, e1.sourceIndex);
    ParserVal v2=((FormulaElement1)element).getInput1Val();
    SourceStore e2=getElement(v2);
    pe.setSource(StandardParameters.LOW.i, e2.source, e2.sourceIndex);
    ParserVal v3=((FormulaElement1)element).getInput1Val();
    SourceStore e3=getElement(v3);
    pe.setSource(StandardParameters.HIGH.i, e3.source, e3.sourceIndex);
  }else
  if(element instanceof FormulaElement1){
    ParserVal v1=((FormulaElement1)element).getInput1Val();
    ProcessElement el=((TemplateProvider)v1).getTemplate();
View Full Code Here

  @Override
  public void setSource(int connection, NamedSource source,
            int sourceIndex) throws UnknownConnectionException,
      TypeMismatchException {
  params.put(connection, new SourceStore(source, sourceIndex));
  }
View Full Code Here

  return val;
  }

  @Override
  public void advanceState() {
  SourceStore s=params.get(StandardParameters.A.i);
  if(phase!=ATTACK){
    if(s!=null)
    attack=s.getValue();
    if(attack<0)
    attack=0;
  }
  if(phase!=DECAY){
    s=params.get(StandardParameters.D.i);
    if(s!=null)
    decay=s.getValue();
    if(decay<0)
    decay=0;
  }
  if(phase!=SUSTAIN){
    s=params.get(StandardParameters.S.i);
    if(s!=null)
    sustain=s.getValue();
    if(sustain<0)
    sustain=0;
    if(sustain>1)
    sustain=1;
  }
  if(phase!=RELEASE){
    s=params.get(StandardParameters.R.i);
    if(s!=null)
    release=s.getValue();
    if(release<0)
    release=0;
  }
  s=params.get(StandardParameters.SYNC.i);
  trigold=trig;
  trig=s!=null&&s.getValue()>0;
  if(trig&&!trigold){
    // attack starts
    restRelease=_val;
    _val=minVal+restRelease;// we do not expect more than 16 bits resolution in the end.
                // starting with even one power below should be safe
View Full Code Here

      TypeMismatchException {
  if(!source.getSourceTypes().containsKey(sourceIndex))
    throw new UnknownConnectionException("attempt to get invalid source's output for SID6581");
  if(!destinationTypes.containsKey(connectionIndex))
    throw new UnknownConnectionException("attempt to set unkown parameter for SID6581");
    sourceStoreMap.put(connectionIndex, new SourceStore(source, sourceIndex));
    nsetSource(nativeSpace, connectionIndex, source.getNativeSpace(), sourceIndex);
  }
View Full Code Here

  public void setSource(int connection, NamedSource source,
            int sourceIndex) throws UnknownConnectionException,
      TypeMismatchException {
  if(connection==StandardParameters.FREQUENCY.i){
    if(source.getSourceTypes().containsKey(sourceIndex)){
    freq=new SourceStore(source, sourceIndex);
    sourceStoreMap.put(connection, freq);
    }else
    throw new UnknownConnectionException("unknown source for generator frequency");
  }else if(connection==StandardParameters.SYNC.i){
    if(source.getSourceTypes().containsKey(sourceIndex)){
    sync=new SourceStore(source, sourceIndex);
    sourceStoreMap.put(connection, sync);
    }else
    throw new UnknownConnectionException("unkown source for generator sync");
  }else if(connection==StandardParameters.SYNCPHASE.i){
    if(source.getSourceTypes().containsKey(sourceIndex)){
    syncphase=new SourceStore(source, sourceIndex);
    sourceStoreMap.put(connection, syncphase);
    }else
    throw new UnknownConnectionException("unkown source for generator syncphase");
  }else
    throw new UnknownConnectionException("attempt to set unknown generator parameter");
View Full Code Here

  public void setSource(int connection, NamedSource source,
            int sourceIndex) throws UnknownConnectionException,
      TypeMismatchException {
  if(connection==StandardParameters.DUTYCYCLE.i){
    if(source.getSourceTypes().containsKey(sourceIndex)){
    dc=new SourceStore(source, sourceIndex);
    }else
    throw new UnknownConnectionException("source for SawTooth dutycycle unknown");
  }else if(connection==StandardParameters.PHASEOFFSET.i){
    if(source.getSourceTypes().containsKey(sourceIndex)){
    po=new SourceStore(source, sourceIndex);
    }else
    throw new UnknownConnectionException("source for SawTooth phaseoffset unknown");
  }else
    super.setSource(connection, source, sourceIndex);
  }
View Full Code Here

TOP

Related Classes of de.maramuse.soundcomp.process.SourceStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.