Package de.maramuse.soundcomp.process

Examples of de.maramuse.soundcomp.process.Event


  return 0.3+note16/16.0/tempo;
  }

  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);
  snare.addMixerConnection(drums_L, m3, OUT.i);
  snare.addMixerConnection(drums_R, m4, OUT.i);
  return snare;
  }
View Full Code Here


  private Event getCrash(double left, double right) {
  // create the crash cymbal
  // TODO a crash cymbal, when hit multiple times, does not create overlaying sounds, the older sound
  // would need to be stopped similar to the hihat handling
  Event crash=new Event();
  InputFile ifsn=new InputFile("javasrc/de/maramuse/soundcomp/test/testfiles/crash.wav");
  crash.setDuration(0.025);
  crash.setLivetime(5.25);
  crash.addElement(ifsn);
  crash.setAbstractName("crash");
  crash.setInstanceName("crash"+nameCount++);
  return crash;
  }
View Full Code Here

  private Event getRide(double left, double right) {
  // create the ride cymbal
  // TODO a ride cymbal is played in multiple, clearly distinct ways
  // TODO a ride cymbal, when hit multiple times, does not create simple overlaying sounds, the older sound
  // would need to be influenced on a second hit depending on what kind of hit occurs
  Event ride=new Event();
  InputFile ifsn=new InputFile("javasrc/de/maramuse/soundcomp/test/testfiles/ride.wav");
  ride.setDuration(0.025);
  ride.setLivetime(5.25);
  ride.addElement(ifsn);
  ride.setAbstractName("ride");
  ride.setInstanceName("ride"+nameCount++);
  return ride;
  }
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();
  }
  tom.addElement(ev);
  tom.addElement(m);
  tom.addElement(m1);
  tom.addElement(m2);
  tom.addElement(p1);
  tom.addElement(p2);
  tom.addElement(st);
  tom.setAbstractName("tom");
  tom.setInstanceName("tom"+nameCount++);

  return tom;
  }
View Full Code Here

  return tom;
  }

  private Event getBassDrum(double left, double right) {
  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();
  }
  bd.addMixerConnection(drums_L, m3, OUT.i);
  bd.addMixerConnection(drums_R, m4, OUT.i);
  return bd;
  }
View Full Code Here

  }

  private Event getHHOpen(double left, double right) {
  // create the open hihat from a sampled file
  synchronized(hihatsync){
    Event hihat_open=new Event();
    InputFile ifho=new InputFile("javasrc/de/maramuse/soundcomp/test/testfiles/hh-o.wav");
    hihat_open.setDuration(0.025);
    hihat_open.setLivetime(1.25);
    hihat_open.addElement(ifho);
    /*
     * 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_open.setAbstractName("hihat_open");
    hihat_open.setInstanceName("hihat_open"+nameCount++);
    return hihat=hihat_open;
  }
  }
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);
    hihat_closed.addElement(m4);
    hihat_closed.addMixerConnection(drums_L, m3, OUT.i);
    hihat_closed.addMixerConnection(drums_R, m4, OUT.i);
    return hihat=hihat_closed;
  }
  }
View Full Code Here

  // create one note instance for the solo instrument
  private Event createSoloNote(note n, double volume) {
  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);
    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){
    e.printStackTrace();
  }
  double ts=n.startbeat/tempo;
  event.setStarttime(ts);
  if(n.legato){
    event.setDuration(n.beats/tempo);
  }else{
    event.setDuration(Math.min(n.beats, 1.0/4.0)/tempo*0.6);
  }
  event.setLivetime(event.getDuration()+1);
  event.setFrequency(n.frequency);
  // System.out.println("solo note "+n.frequency+"Hz at "+ts+" for "+event.getDuration()+"/"+event.getLivetime()+"(beats:"+n.beats+","+tempo+")");
  event.setPitch(n.pitch);
  event.addElement(st);
  event.addElement(pn);
  event.addElement(noisevol);
  event.addElement(noiseenv);
  event.addElement(sawvol);
  event.addElement(sawenv);
  event.addElement(out);
  NoteGateOffEvent ng0e=new NoteGateOffEvent(event, ts+event.getDuration(), advancerRegistry);
  NoteBirthEvent nbe=new NoteBirthEvent(event, ts, advancerRegistry);
  NoteGateOnEvent ng1e=new NoteGateOnEvent(event, ts+1.01/globalParameters.getSampleRate(),
    advancerRegistry);
  NoteDeathEvent nde=new NoteDeathEvent(event, ts+event.getLivetime(), advancerRegistry);
  event.addMixerConnection(solo_L, out, OUT.i);
  event.addMixerConnection(solo_R, out, OUT.i);
  advancerRegistry.addEvent(nbe.getTimestamp(), nbe, event);
  advancerRegistry.addEvent(ng0e.getTimestamp(), ng0e, event);
  advancerRegistry.addEvent(ng1e.getTimestamp(), ng1e, event);
  advancerRegistry.addEvent(nde.getTimestamp(), nde, event);
  return event;
View Full Code Here

  }

  // create one note instance for the bass instrument
  private Event createBassNote(String note, double ts, double durationGate, double durationTotal,
                 double volume) {
  Event event=new Event();
  event.setAbstractName("bass");
  event.setInstanceName("bass"+nameCount++);
  event.setStarttime(ts);
  event.setDuration(durationGate);
  event.setLivetime(durationTotal);
  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);
    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();
  }
  event.addElement(st);
  event.addElement(filterEnv);
  event.addElement(volumeEnv);
  event.addElement(mout);
  event.addElement(mvol);
  event.addElement(svf);
  event.addElement(pfilfreq);
  event.addElement(mfilfreq);
  event.addElement(mfilfreq2);
  NoteGateOffEvent nge=new NoteGateOffEvent(event, ts+event.getDuration(), advancerRegistry);
  NoteBirthEvent nbe=new NoteBirthEvent(event, ts, advancerRegistry);
  NoteGateOnEvent ng1e=new NoteGateOnEvent(event, ts+1.01/globalParameters.getSampleRate(),
    advancerRegistry);
  NoteDeathEvent nde=new NoteDeathEvent(event, ts+event.getLivetime(), advancerRegistry);
  event.addMixerConnection(bass_L, mout, OUT.i);
  event.addMixerConnection(bass_R, mout, OUT.i);
  advancerRegistry.addEvent(nbe.getTimestamp(), nbe, event);
  advancerRegistry.addEvent(nge.getTimestamp(), nge, event);
  advancerRegistry.addEvent(ng1e.getTimestamp(), ng1e, event);
  advancerRegistry.addEvent(nde.getTimestamp(), nde, event);
  return event;
View Full Code Here

  }

  // create one note instance for the pad instrument
  private Event createPadNote(String note, double ts, double durationGate, double durationTotal,
                double volume) {
  Event event=new Event();
  event.setAbstractName("pad");
  event.setInstanceName("pad"+nameCount++);
  event.setStarttime(ts);
  event.setDuration(durationGate);
  event.setLivetime(durationTotal);
  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);
    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);
    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*totalVolume), OUT.i);
  }catch(UnknownConnectionException e){
    e.printStackTrace();
  }catch(TypeMismatchException e){
    e.printStackTrace();
  }
  event.addElement(pwm);
  event.addElement(filterEnv);
  event.addElement(volumeEnv);
  event.addElement(mout);
  event.addElement(mvol);
  event.addElement(svf);
  event.addElement(hp);
  event.addElement(pfilfreq);
  event.addElement(mfilfreq);
  event.addElement(mfilfreq2);
  event.addElement(dmul);
  event.addElement(dmul2);
  event.addElement(dpl);
  event.addElement(lfo);
  event.addElement(lfof);
  event.addElement(dpl2);
  NoteGateOffEvent nge=new NoteGateOffEvent(event, ts+event.getDuration(), advancerRegistry);
  NoteBirthEvent nbe=new NoteBirthEvent(event, ts, advancerRegistry);
  NoteGateOnEvent ng1e=new NoteGateOnEvent(event, ts+1.01/globalParameters.getSampleRate(),
    advancerRegistry);
  NoteDeathEvent nde=new NoteDeathEvent(event, ts+event.getLivetime(), advancerRegistry);
  event.addMixerConnection(pad_L, mout, OUT.i);
  event.addMixerConnection(pad_R, mout, OUT.i);
  advancerRegistry.addEvent(nbe.getTimestamp(), nbe, event);
  advancerRegistry.addEvent(nge.getTimestamp(), nge, event);
  advancerRegistry.addEvent(ng1e.getTimestamp(), ng1e, event);
  advancerRegistry.addEvent(nde.getTimestamp(), nde, event);
  return event;
View Full Code Here

TOP

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

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.