Package de.maramuse.soundcomp.process

Examples of de.maramuse.soundcomp.process.ProcessElement


  private Event getTom(double left, double right) {
  // create a tom.
  // a pitched percussive sound with decreasing pitch and harmonics that fade out
  // faster than the fundamental.
  Event tom=new Event();
  ProcessElement ev=new Envelope();
  ProcessElement m=new mul();
  ProcessElement m1=new mul();
  ProcessElement m2=new mul();
  ProcessElement p1=new plus();
  ProcessElement p2=new plus();
  ProcessElement st=new SawTooth();
  try{
    ev.setSource(SYNC.i, tom, GATE.i);
    ev.setSource(A.i, ConstStream.c(0.01), OUT.i);
    ev.setSource(D.i, ConstStream.c(1), OUT.i);
    ev.setSource(R.i, ConstStream.c(1), OUT.i);
    ev.setSource(S.i, ConstStream.c(0), OUT.i);
    m.setSource(IN_IMAG.i, ev, OUT.i);
    m.setSource(IN.i, st, OUT.i);
    m1.setSource(IN_IMAG.i, ev, OUT.i);
    m1.setSource(IN.i, ConstStream.c(20), OUT.i);
    p1.setSource(IN_IMAG.i, m1, OUT.i);
    p1.setSource(IN.i, ConstStream.c(150), OUT.i);
    st.setSource(FREQUENCY.i, p1, OUT.i);
    p2.setSource(IN_IMAG.i, m2, OUT.i);
    m2.setSource(IN.i, ConstStream.c(0.3), OUT.i);
    m2.setSource(IN_IMAG.i, ev, OUT.i);
    p2.setSource(IN.i, ConstStream.c(0.5), OUT.i);
    st.setSource(DUTYCYCLE.i, p2, OUT.i);
  }catch(UnknownConnectionException e){
    e.printStackTrace();
  }catch(TypeMismatchException e){
    e.printStackTrace();
  }
View Full Code Here


  Event bd=new Event();
  bd.setAbstractName("bass drum");
  bd.setInstanceName("bass drum"+nameCount++);
  bd.setDuration(0.1);
  bd.setLivetime(0.5);
  ProcessElement ev=new Envelope();
  ProcessElement m=new mul();
  ProcessElement m1=new mul();
  ProcessElement m2=new mul();
  ProcessElement p1=new plus();
  ProcessElement p2=new plus();
  ProcessElement st=new SawTooth();
  ProcessElement m3=new mul();
  ProcessElement m4=new mul();
  try{
    ev.setSource(SYNC.i, bd, GATE.i);
    ev.setSource(A.i, ConstStream.c(0.01), OUT.i);
    ev.setSource(D.i, ConstStream.c(0.7), OUT.i);
    ev.setSource(R.i, ConstStream.c(0.7), OUT.i);
    ev.setSource(S.i, ConstStream.c(0), OUT.i);
    m.setSource(IN_IMAG.i, ev, OUT.i);
    m.setSource(IN.i, st, OUT.i);
    m1.setSource(IN_IMAG.i, ev, OUT.i);
    m1.setSource(IN.i, ConstStream.c(20), OUT.i);
    p1.setSource(IN_IMAG.i, m1, OUT.i);
    p1.setSource(IN.i, ConstStream.c(50), OUT.i);
    st.setSource(FREQUENCY.i, p1, OUT.i);
    p2.setSource(IN_IMAG.i, m2, OUT.i);
    m2.setSource(IN.i, ConstStream.c(0.3), OUT.i);
    m2.setSource(IN_IMAG.i, ev, OUT.i);
    p2.setSource(IN.i, ConstStream.c(0.5), OUT.i);
    st.setSource(DUTYCYCLE.i, p2, OUT.i);
    bd.addElement(ev);
    bd.addElement(m);
    bd.addElement(m1);
    bd.addElement(m2);
    bd.addElement(p1);
    bd.addElement(p2);
    bd.addElement(st);
    bd.addElement(m3);
    bd.addElement(m4);
    m3.setSource(IN_IMAG.i, m, OUT.i);
    m3.setSource(IN.i, ConstStream.c(left), OUT.i);
    m4.setSource(IN_IMAG.i, m, OUT.i);
    m4.setSource(IN.i, ConstStream.c(right), OUT.i);
  }catch(UnknownConnectionException e){
    e.printStackTrace();
  }catch(TypeMismatchException e){
    e.printStackTrace();
  }
View Full Code Here

    OutputFile ws=new OutputFile(1);
    int waveform=0;
    double freq=0.01;
    double lasttime=0;
    boolean gate=false;
    ProcessElement sid=new SID6581();
    // set any parameters you like. SID6581 treats unset parameters as 0.
    // you may edit this template to test any features of the SID6581.
    sid.setSource(VOL.i, ConstStream.c(0.8), OUT.i);
    sid.setSource(SQUA1.i, ConstStream.c(1), OUT.i);
    sid.setSource(DUTYCYCLE1.i, ConstStream.c(.75), OUT.i);
    sid.setSource(RING1.i, ConstStream.c(1), OUT.i);
    sid.setSource(SYNC1.i, ConstStream.c(1), OUT.i);
    sid.setSource(A1.i, ConstStream.c(5/15.0), OUT.i);
    sid.setSource(D1.i, ConstStream.c(8/15.0), OUT.i);
    sid.setSource(S1.i, ConstStream.c(9/15.0), OUT.i);
    sid.setSource(R1.i, ConstStream.c(3/15.0), OUT.i);
    ProcessElement m=new mul();
    // multiply the output with 0.05 to reduce signal volume, OutputFile expects abs(signal)<1
    m.setSource(IN_IMAG.i, ConstStream.c(0.95), OUT.i);
    m.setSource(IN.i, sid, OUT.i);
    advancerRegistry.registerAdvancer(ws);
    ws.setSource(0, m, OUT.i);
    advancerRegistry.registerAdvancer(sid);
    for(double time=0; time<10; time+=1/globalParameters.getSampleRate()){
    if(time>lasttime){
View Full Code Here

   */
  public void testMonkey() { // envelope generator
  try{
    advancerRegistry.clear();
    globalParameters.setSampleRate(44100);
    ProcessElement env1=new Envelope();
    advancerRegistry.registerAdvancer(env1);
    Time time=new Time();
    Mixer mix=new Mixer();
    PWM gate=new PWM();
    advancerRegistry.registerAdvancer(mix);
    advancerRegistry.registerAdvancer(time);
    advancerRegistry.registerAdvancer(env1);
    advancerRegistry.registerAdvancer(gate);
    Scale s=new WellTemperedScale();
    ConstStream[] notes=new ConstStream[]{
    new ConstStream(s.getValueFor("c#")),
    new ConstStream(s.getValueFor("e")),
    new ConstStream(s.getValueFor("A")),
    };
    ConstStream beats=new ConstStream(1); // 60 bpm in beats per second
    ConstStream A=new ConstStream(0.13);
    ConstStream D=new ConstStream(1.25);
    ConstStream S=ConstStream.c(0.25);
    ConstStream R=new ConstStream(2.55);
    ConstStream A2=new ConstStream(0.05);
    ConstStream D2=new ConstStream(2.25);
    ConstStream S2=ConstStream.c(0.25);
    ConstStream R2=new ConstStream(1.55);
    ComplexTable<Double> ct=new ComplexTable<Double>();
    ct.put(0.0, 0);
    ct.put(0.25, 1);
    ct.put(1.0, 0);
    ct.put(1.25, -1);
    ct.put(2.0, 0);
    // ct.finish();
    ProcessElement si=new Sine();
    Mixer fmix=new Mixer();
    mul fmul=new mul();
    mul fmul2=new mul();
    Mixer fmix2=new Mixer();
    Envelope fmenv=new Envelope();
    CustomWaveform ts=new CustomWaveform();

    ts.setTable(ct);
    ProcessElement cw=new CustomWave();
    advancerRegistry.registerAdvancer(cw);
    advancerRegistry.registerAdvancer(si);
    advancerRegistry.registerAdvancer(mix);
    advancerRegistry.registerAdvancer(fmix);
    advancerRegistry.registerAdvancer(fmix2);
    advancerRegistry.registerAdvancer(fmul2);
    advancerRegistry.registerAdvancer(fmenv);
    advancerRegistry.registerAdvancer(fmul);
    advancerRegistry.registerAdvancer(env1);
    try{
    mix.setSource(-1, cw, StandardParameters.OUT.i);
    mix.setSource(-1, env1, StandardParameters.OUT.i);
    gate.setSource(StandardParameters.FREQUENCY.i, beats, StandardParameters.OUT.i);
    gate.setSource(StandardParameters.DUTYCYCLE.i, ConstStream.c(0.5), StandardParameters.OUT.i);
    cw.setSource(StandardParameters.FREQUENCY.i, fmix2, StandardParameters.OUT.i);
    cw.setSource(StandardParameters.TABLE.i, ts, StandardParameters.TABLE.i);
    env1.setSource(StandardParameters.A.i, A, StandardParameters.OUT.i);
    env1.setSource(StandardParameters.D.i, D, StandardParameters.OUT.i);
    env1.setSource(StandardParameters.S.i, S, StandardParameters.OUT.i);
    env1.setSource(StandardParameters.R.i, R, StandardParameters.OUT.i);
    env1.setSource(StandardParameters.SYNC.i, gate, StandardParameters.OUT.i);
View Full Code Here

  private Event getTom(double left, double right) {
  // create a tom.
  // a pitched percussive sound with decreasing pitch and harmonics that fade out
  // faster than the fundamental.
  Event tom=new Event();
  ProcessElement ev=new Envelope();
  ProcessElement m=new mul();
  ProcessElement m1=new mul();
  ProcessElement m2=new mul();
  ProcessElement p1=new plus();
  ProcessElement p2=new plus();
  ProcessElement st=new SawTooth();
  try{
    ev.setSource(SYNC.i, tom, GATE.i);
    ev.setSource(A.i, ConstStream.c(0.01), OUT.i);
    ev.setSource(D.i, ConstStream.c(1), OUT.i);
    ev.setSource(R.i, ConstStream.c(1), OUT.i);
    ev.setSource(S.i, ConstStream.c(0), OUT.i);
    m.setSource(IN_IMAG.i, ev, OUT.i);
    m.setSource(IN.i, st, OUT.i);
    m1.setSource(IN_IMAG.i, ev, OUT.i);
    m1.setSource(IN.i, ConstStream.c(20), OUT.i);
    p1.setSource(IN_IMAG.i, m1, OUT.i);
    p1.setSource(IN.i, ConstStream.c(150), OUT.i);
    st.setSource(FREQUENCY.i, p1, OUT.i);
    p2.setSource(IN_IMAG.i, m2, OUT.i);
    m2.setSource(IN.i, ConstStream.c(0.3), OUT.i);
    m2.setSource(IN_IMAG.i, ev, OUT.i);
    p2.setSource(IN.i, ConstStream.c(0.5), OUT.i);
    st.setSource(DUTYCYCLE.i, p2, OUT.i);
  }catch(UnknownConnectionException e){
    e.printStackTrace();
  }catch(TypeMismatchException e){
    e.printStackTrace();
  }
View Full Code Here

  Event bd=new Event();
  bd.setAbstractName("bass drum");
  bd.setInstanceName("bass drum"+nameCount++);
  bd.setDuration(0.1);
  bd.setLivetime(0.5);
  ProcessElement ev=new Envelope();
  ProcessElement m=new mul();
  ProcessElement m1=new mul();
  ProcessElement m2=new mul();
  ProcessElement p1=new plus();
  ProcessElement p2=new plus();
  ProcessElement st=new SawTooth();
  ProcessElement m3=new mul();
  ProcessElement m4=new mul();
  try{
    ev.setSource(SYNC.i, bd, GATE.i);
    ev.setSource(A.i, ConstStream.c(0.01), OUT.i);
    ev.setSource(D.i, ConstStream.c(0.7), OUT.i);
    ev.setSource(R.i, ConstStream.c(0.7), OUT.i);
    ev.setSource(S.i, ConstStream.c(0), OUT.i);
    m.setSource(IN_IMAG.i, ev, OUT.i);
    m.setSource(IN.i, st, OUT.i);
    m1.setSource(IN_IMAG.i, ev, OUT.i);
    m1.setSource(IN.i, ConstStream.c(20), OUT.i);
    p1.setSource(IN_IMAG.i, m1, OUT.i);
    p1.setSource(IN.i, ConstStream.c(50), OUT.i);
    st.setSource(FREQUENCY.i, p1, OUT.i);
    p2.setSource(IN_IMAG.i, m2, OUT.i);
    m2.setSource(IN.i, ConstStream.c(0.3), OUT.i);
    m2.setSource(IN_IMAG.i, ev, OUT.i);
    p2.setSource(IN.i, ConstStream.c(0.5), OUT.i);
    st.setSource(DUTYCYCLE.i, p2, OUT.i);
    bd.addElement(ev);
    bd.addElement(m);
    bd.addElement(m1);
    bd.addElement(m2);
    bd.addElement(p1);
    bd.addElement(p2);
    bd.addElement(st);
    bd.addElement(m3);
    bd.addElement(m4);
    m3.setSource(IN_IMAG.i, m, OUT.i);
    m3.setSource(IN.i, ConstStream.c(left), OUT.i);
    m4.setSource(IN_IMAG.i, m, OUT.i);
    m4.setSource(IN.i, ConstStream.c(right), OUT.i);
  }catch(UnknownConnectionException e){
    e.printStackTrace();
  }catch(TypeMismatchException e){
    e.printStackTrace();
  }
View Full Code Here

   *           if an outer source provides unsuitable data
   */
  private ProcessElement createTemplateFormula(FormulaElement val)
    throws UnknownConnectionException,
    TypeMismatchException {
  ProcessElement el;
  // FormulaElements always are TemplateProvider-s
  el=((TemplateProvider)val).getTemplate().clone();
  // FormulaElements always are ParserVal-s
  el.setAbstractName(((ParserVal)val).getText());
  if(val instanceof FormulaElement3){
    ParserVal v3=((FormulaElement3)val).getInput3Val();
    SourceStore el3=getAsSource(v3);
    el.setSource(StandardParameters.IN.i, el3.source, el3.sourceIndex);
  }
  if(val instanceof FormulaElement2){
    ParserVal v2=((FormulaElement2)val).getInput2Val();
    SourceStore el2=getAsSource(v2);
    el.setSource(StandardParameters.IN.i, el2.source, el2.sourceIndex);
  }
  if(val instanceof FormulaElement1){
    ParserVal v1=((FormulaElement1)val).getInput1Val();
    SourceStore el1=getAsSource(v1);
    el.setSource(StandardParameters.IN.i, el1.source, el1.sourceIndex);
  }
  return el;
  }
View Full Code Here

  throw new IllegalArgumentException("Illegal element "+val.getClass().getName()+" in formula");
  }
 
  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();
    pe.setSource(StandardParameters.IN.i, el, StandardParameters.OUT.i);
    if(element instanceof FormulaElement2){
    ParserVal v2=((FormulaElement2)element).getInput2Val();
    ProcessElement e2=((TemplateProvider)v2).getTemplate();
    pe.setSource(StandardParameters.IN_IMAG.i, e2, StandardParameters.OUT.i);
    }
  }
  return pe;
  }
View Full Code Here

TOP

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

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.