Package de.maramuse.soundcomp.generator

Examples of de.maramuse.soundcomp.generator.Envelope


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

  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);
    noiseenv.setSource(S.i, ConstStream.c(0.1), OUT.i);
    sawenv.setSource(A.i, ConstStream.c(0.02), OUT.i);
    sawenv.setSource(D.i, ConstStream.c(1), OUT.i);
    if(n.legato){
    sawenv.setSource(S.i, ConstStream.c(0), OUT.i);
    sawenv.setSource(R.i, ConstStream.c(1), OUT.i);
    noiseenv.setSource(R.i, ConstStream.c(1), OUT.i);
    }else{
    sawenv.setSource(S.i, ConstStream.c(0.2), OUT.i);
    sawenv.setSource(R.i, ConstStream.c(0.01), OUT.i);
    noiseenv.setSource(R.i, ConstStream.c(0.01), OUT.i);
    }
  }catch(UnknownConnectionException e){
    e.printStackTrace();
  }catch(TypeMismatchException e){
View Full Code Here

  event.setFrequency(scale.getValueFor(note));
  event.setPitch(scale.getPitch(note));
  SawTooth st=new SawTooth();
  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);
View Full Code Here

  event.setFrequency(scale.getValueFor(note));
  event.setPitch(scale.getPitch(note));
  PWM pwm=new PWM();
  pwm.setAbstractName("pad-pw");
  pwm.setInstanceName("pad-pw"+nameCount++);
  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);
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);
    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);
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);
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);
View Full Code Here

  Event event=new Event();
  SawTooth st=new SawTooth();
  WhiteNoise pn=new WhiteNoise();
  mul noisevol=new mul();
  mul sawvol=new mul();
  Envelope noiseenv=new Envelope();
  Envelope sawenv=new Envelope();
  Sine dclfo1=new Sine();
  Sine dclfo2=new Sine();
  mul lfomul1=new mul(), lfomul2=new mul();
  mul lfomul1a=new mul(), lfomul2a=new mul();
  plus lfopl1=new plus(), lfopl2=new plus();
  Mixer out=new Mixer();
  try{
    lfomul1.setSource(IN_IMAG.i, ConstStream.c(n.frequency), OUT.i);
    lfomul1.setSource(IN.i, ConstStream.c(0.00033), OUT.i);
    dclfo1.setSource(FREQUENCY.i, lfomul1, OUT.i);
    lfomul1a.setSource(IN_IMAG.i, dclfo1, OUT.i);
    lfomul1a.setSource(IN.i, ConstStream.c(0.333), OUT.i);
    lfopl1.setSource(IN_IMAG.i, lfomul1a, OUT.i);
    lfopl1.setSource(IN.i, ConstStream.c(0.5), OUT.i);
    lfomul2.setSource(IN_IMAG.i, ConstStream.c(n.frequency), OUT.i);
    lfomul2.setSource(IN.i, ConstStream.c(0.00013), OUT.i);
    dclfo2.setSource(FREQUENCY.i, lfomul2, OUT.i);
    lfomul2a.setSource(IN_IMAG.i, dclfo2, OUT.i);
    lfomul2a.setSource(IN.i, ConstStream.c(0.133), OUT.i);
    lfopl2.setSource(IN_IMAG.i, lfomul2a, OUT.i);
    lfopl2.setSource(IN.i, lfopl1, OUT.i);
    st.setSource(FREQUENCY.i, ConstStream.c(n.frequency), OUT.i);
    st.setSource(DUTYCYCLE.i, lfopl2, 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.23), OUT.i);
    noiseenv.setSource(S.i, ConstStream.c(0.05), OUT.i);
    sawenv.setSource(A.i, ConstStream.c(0.02), OUT.i);
    sawenv.setSource(D.i, ConstStream.c(1), OUT.i);
    if(n.legato){
    sawenv.setSource(S.i, ConstStream.c(0.3), OUT.i);
    sawenv.setSource(R.i, ConstStream.c(1), OUT.i);
    noiseenv.setSource(R.i, ConstStream.c(1), OUT.i);
    }else{
    sawenv.setSource(S.i, ConstStream.c(0.2), OUT.i);
    sawenv.setSource(R.i, ConstStream.c(0.01), OUT.i);
    noiseenv.setSource(R.i, ConstStream.c(0.01), OUT.i);
    }
  }catch(UnknownConnectionException e){
    e.printStackTrace();
  }catch(TypeMismatchException e){
View Full Code Here

  event.setFrequency(scale.getValueFor(note));
  event.setPitch(scale.getPitch(note));
  SawTooth st=new SawTooth();
  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);
View Full Code Here

TOP

Related Classes of de.maramuse.soundcomp.generator.Envelope

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.