Package de.maramuse.soundcomp.math

Examples of de.maramuse.soundcomp.math.mul


  }

  private Event getSnare(double left, double right) {
  // create the snare drum from a sampled file
  Event snare=new Event();
  mul m3=new mul(), m4=new mul();
  InputFile ifsn=new InputFile("javasrc/de/maramuse/soundcomp/test/testfiles/sd.wav");
  snare.setAbstractName("snare");
  snare.setInstanceName("snare"+nameCount++);
  snare.setDuration(0.025);
  snare.setLivetime(1.25);
  snare.addElement(ifsn);
  try{
    m3.setSource(IN_IMAG.i, ifsn, OUT.i);
    m3.setSource(IN.i, ConstStream.c(left), OUT.i);
    m4.setSource(IN_IMAG.i, ifsn, OUT_IMAG.i);
    m4.setSource(IN.i, ConstStream.c(right), OUT.i);
  }catch(Exception ex){
    ex.printStackTrace();
  }
  snare.addElement(m3);
  snare.addElement(m4);
View Full Code Here


  // 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){
View Full Code Here

  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

  private Event getHHClosed(double left, double right) {
  // create the closed hihat from a sampled file
  synchronized(hihatsync){
    Event hihat_closed=new Event();
    mul m3=new mul(), m4=new mul();
    InputFile ifhc=new InputFile("javasrc/de/maramuse/soundcomp/test/testfiles/hh-c.wav");
    ifhc.setAbstractName("ifhc");
    ifhc.setInstanceName("ifhc"+nameCount++);
    hihat_closed.setDuration(0.025);
    hihat_closed.setLivetime(0.5);
    /*
     * we would have to disregister the open hihat when it is hit closed, but not at creation time, rather at run
     * time. if(hihat!=null){ hihat.die(); drums_L.disconnect(hihatcl); drums_R.disconnect(hihatcr); }
     */
    hihat_closed.setAbstractName("hihat_closed");
    hihat_closed.setInstanceName("hihat_closed"+nameCount++);
    try{
    m3.setSource(IN_IMAG.i, ifhc, OUT.i);
    m3.setSource(IN.i, ConstStream.c(left), OUT.i);
    m4.setSource(IN_IMAG.i, ifhc, OUT.i);
    m4.setSource(IN.i, ConstStream.c(right), OUT.i);
    }catch(Exception ex){
    ex.printStackTrace();
    }
    hihat_closed.addElement(ifhc);
    hihat_closed.addElement(m3);
View Full Code Here

  double effvol=volume;
  if(n.beats<1.0/8)effvol*=0.7;
  Event event=new Event();
  SawTooth st=new SawTooth();
  PinkNoise pn=new PinkNoise();
  mul noisevol=new mul();
  mul sawvol=new mul();
  Envelope noiseenv=new Envelope();
  Envelope sawenv=new Envelope();
  Mixer out=new Mixer();
  try{
    st.setSource(FREQUENCY.i, ConstStream.c(n.frequency), OUT.i);
    st.setSource(DUTYCYCLE.i, ConstStream.c(0.5), OUT.i);
    out.setSource(-1, sawvol, OUT.i);
    out.setSource(-1, ConstStream.c(0.5*effvol), OUT.i);
    out.setSource(-2, noisevol, OUT.i);
    out.setSource(-2, ConstStream.c(0.4*effvol), OUT.i);
    sawvol.setSource(IN_IMAG.i, st, OUT.i);
    noisevol.setSource(IN_IMAG.i, pn, OUT.i);
    sawvol.setSource(IN.i, sawenv, OUT.i);
    noisevol.setSource(IN.i, noiseenv, OUT.i);
    noiseenv.setSource(SYNC.i, event, GATE.i);
    sawenv.setSource(SYNC.i, event, GATE.i);
    noiseenv.setSource(A.i, ConstStream.c(0.02), OUT.i);
    noiseenv.setSource(D.i, ConstStream.c(0.03), OUT.i);
View Full Code Here

  st.setAbstractName("bass-st");
  st.setInstanceName("bass-st"+nameCount++);
  Envelope filterEnv=new Envelope();
  Envelope volumeEnv=new Envelope();
  StateVariableFilter svf=new StateVariableFilter();
  mul mfilfreq=new mul(), mfilfreq2=new mul();
  plus pfilfreq=new plus();
  mul mout=new mul();
  mul mvol=new mul();
  try{
    filterEnv.setSource(SYNC.i, event, GATE.i);
    filterEnv.setSource(A.i, ConstStream.c(0.2), OUT.i);
    filterEnv.setSource(D.i, ConstStream.c(0.4), OUT.i);
    filterEnv.setSource(R.i, ConstStream.c(0.4), OUT.i);
    filterEnv.setSource(S.i, ConstStream.c(0), OUT.i);
    volumeEnv.setSource(SYNC.i, event, GATE.i);
    volumeEnv.setSource(A.i, ConstStream.c(0.1), OUT.i);
    volumeEnv.setSource(D.i, ConstStream.c(0.3), OUT.i);
    volumeEnv.setSource(R.i, ConstStream.c(0.3), OUT.i);
    volumeEnv.setSource(S.i, ConstStream.c(0.3), OUT.i);
    st.setSource(FREQUENCY.i, event, FREQUENCY.i);
    svf.setSource(IN.i, st, OUT.i);
    mfilfreq.setSource(IN.i, filterEnv, OUT.i);
    mfilfreq.setSource(IN_IMAG.i, ConstStream.c(4), OUT.i);
    mfilfreq2.setSource(IN.i, mfilfreq, OUT.i);
    mfilfreq2.setSource(IN_IMAG.i, event, FREQUENCY.i);
    pfilfreq.setSource(IN_IMAG.i, mfilfreq2, OUT.i);
    pfilfreq.setSource(IN.i, event, FREQUENCY.i);
    svf.setSource(FREQUENCY.i, pfilfreq, OUT.i);
    svf.setSource(Q.i, ConstStream.c(0.9), OUT.i);
    mout.setSource(IN_IMAG.i, volumeEnv, OUT.i);
    mout.setSource(IN.i, mvol, OUT.i);
    mvol.setSource(IN_IMAG.i, svf, LP.i);
    mvol.setSource(IN.i, ConstStream.c(volume), OUT.i);
  }catch(UnknownConnectionException e){
    e.printStackTrace();
  }catch(TypeMismatchException e){
    e.printStackTrace();
  }
View Full Code Here

  Envelope filterEnv=new Envelope();
  Sine lfo=new Sine();
  Envelope volumeEnv=new Envelope();
  StateVariableFilter svf=new StateVariableFilter();
  StateVariableFilter hp=new StateVariableFilter();
  mul mfilfreq=new mul(), mfilfreq2=new mul();
  plus pfilfreq=new plus();
  mul mout=new mul();
  mul lfof=new mul();
  mul mvol=new mul();
  mul dmul=new mul();
  mul dmul2=new mul();
  plus dpl=new plus();
  plus dpl2=new plus();
  try{
    lfof.setSource(IN_IMAG.i, event, FREQUENCY.i);
    lfof.setSource(IN.i, ConstStream.c(0.005), OUT.i);
    lfo.setSource(FREQUENCY.i, lfof, OUT.i);
    hp.setSource(FREQUENCY.i, ConstStream.c(20), OUT.i);
    hp.setSource(IN.i, pwm, OUT.i);
    filterEnv.setSource(SYNC.i, event, GATE.i);
    filterEnv.setSource(A.i, ConstStream.c(0.4), OUT.i);
    filterEnv.setSource(D.i, ConstStream.c(0.7), OUT.i);
    filterEnv.setSource(R.i, ConstStream.c(0.7), OUT.i);
    filterEnv.setSource(S.i, ConstStream.c(0), OUT.i);
    volumeEnv.setSource(SYNC.i, event, GATE.i);
    volumeEnv.setSource(A.i, ConstStream.c(0.4), OUT.i);
    volumeEnv.setSource(D.i, ConstStream.c(1.1), OUT.i);
    volumeEnv.setSource(R.i, ConstStream.c(1.1), OUT.i);
    volumeEnv.setSource(S.i, ConstStream.c(0.8), OUT.i);
    pwm.setSource(FREQUENCY.i, event, FREQUENCY.i);
    dmul.setSource(IN_IMAG.i, filterEnv, OUT.i);
    dmul.setSource(IN.i, ConstStream.c(0.4), OUT.i);
    dpl.setSource(IN_IMAG.i, dmul, OUT.i);
    dpl.setSource(IN.i, ConstStream.c(0.5), OUT.i);
    pwm.setSource(DUTYCYCLE.i, dpl2, OUT.i);
    dpl2.setSource(IN.i, dpl, OUT.i);
    dpl2.setSource(IN_IMAG.i, dmul2, OUT.i);
    dmul2.setSource(IN_IMAG.i, lfo, OUT.i);
    dmul2.setSource(IN.i, ConstStream.c(0.2), OUT.i);
    svf.setSource(IN.i, hp, HP.i);
    mfilfreq.setSource(IN.i, filterEnv, OUT.i);
    mfilfreq.setSource(IN_IMAG.i, ConstStream.c(4), OUT.i);
    mfilfreq2.setSource(IN.i, mfilfreq, OUT.i);
    mfilfreq2.setSource(IN_IMAG.i, event, FREQUENCY.i);
View Full Code Here

    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

    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);
    fmenv.setSource(StandardParameters.A.i, A2, StandardParameters.OUT.i);
    fmenv.setSource(StandardParameters.D.i, D2, StandardParameters.OUT.i);
    fmenv.setSource(StandardParameters.S.i, S2, StandardParameters.OUT.i);
    fmenv.setSource(StandardParameters.R.i, R2, StandardParameters.OUT.i);
    fmenv.setSource(StandardParameters.SYNC.i, gate, StandardParameters.OUT.i);
    si.setSource(StandardParameters.FREQUENCY.i, fmix, StandardParameters.OUT.i);
    fmix.setSource(-1, fmenv, StandardParameters.OUT.i);
    fmix.setSource(-1, new ConstStream(-10), StandardParameters.OUT.i);
    fmix.setSource(-2, new ConstStream(10), StandardParameters.OUT.i);
    fmix2.setSource(-1, si, StandardParameters.OUT.i);
    fmix2.setSource(-1, fmenv, StandardParameters.OUT.i);
    fmix2.setSource(-1, new ConstStream(12), StandardParameters.OUT.i);
    fmul.setSource(StandardParameters.IN.i, new ConstStream(s.getValueFor("A")),
      StandardParameters.OUT.i);
    fmul.setSource(StandardParameters.IN_IMAG.i, new ConstStream(1), StandardParameters.OUT.i);
    fmix2.setSource(-2, fmul, StandardParameters.OUT.i);
    }catch(Exception te){
    fail(te.getMessage());
    }
    OutputFile ws1=new OutputFile(2);
    mul m1=new mul();
    mul m2=new mul();
    ws1.setSource(0, m1, OUT.i);
    ws1.setSource(-1, m2, OUT.i);
    m1.setSource(IN_IMAG.i, ConstStream.c(0.5), OUT.i);
    m2.setSource(IN_IMAG.i, ConstStream.c(0.5), OUT.i);
    m1.setSource(IN.i, mix, OUT.i);
    m2.setSource(IN.i, gate, OUT.i);
    advancerRegistry.registerAdvancer(ws1);
    double lastVal=0;
    int lastIndex=0;
    int sampleCounter=0;
    long starttime=System.currentTimeMillis();
View Full Code Here

  }

  private Event getSnare(double left, double right) {
  // create the snare drum from a sampled file
  Event snare=new Event();
  mul m3=new mul(), m4=new mul();
  InputFile ifsn=new InputFile("javasrc/de/maramuse/soundcomp/test/testfiles/sd.wav");
  snare.setAbstractName("snare");
  snare.setInstanceName("snare"+nameCount++);
  snare.setDuration(0.025);
  snare.setLivetime(1.25);
  snare.addElement(ifsn);
  try{
    m3.setSource(IN_IMAG.i, ifsn, OUT.i);
    m3.setSource(IN.i, ConstStream.c(left), OUT.i);
    m4.setSource(IN_IMAG.i, ifsn, OUT_IMAG.i);
    m4.setSource(IN.i, ConstStream.c(right), OUT.i);
  }catch(Exception ex){
    ex.printStackTrace();
  }
  snare.addElement(m3);
  snare.addElement(m4);
View Full Code Here

TOP

Related Classes of de.maramuse.soundcomp.math.mul

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.