예제 #1
0
 public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
   synthLead.setFreq(440);
   smusic.frame = inputFrame;
   return inputFrame.rgba();
 }
예제 #2
0
  public void onCameraViewStarted(int width, int height) {
    // WtOsc ugOscA1 = new WtOsc();
    // ugOscA1.fillWithHardSin(7.0f);
    // ugOscA1.setFreq(220);
    synthLead = new WtOsc();
    synthLead.fillWithHardSin(7.0f);
    // synthLead.fillWith();
    bass = new WtOsc();
    bass.fillWithSin();
    bass.setFreq(100);
    synthPad = new WtOsc();
    synthPad.fillWithSqr();
    synthPad.setFreq(100f);

    delay = new Delay(UGen.SAMPLE_RATE / 8);
    // env = new ExpEnv();
    // synthLead.chuck(delay);
    // bass.chuck(delay);

    synthLead.setFreq(220);
    ugDac = new Dac();
    synthLead.chuck(delay).chuck(ugDac);
    // env.setFactor(ExpEnv.hardFactor);
    // bass.chuck(ugDac);
    // synthLead.chuck(ugDac);

    synthPad.chuck(delay).chuck(ugDac);

    // ugOscA1.chuck(ugDac);

    if (smusic == null) {
      smusic = new SurroundMusic(this, ugDac, synthLead);
      smusic.start();
    }

    Thread thisThread =
        new Thread(
            new Runnable() {
              public void run() {
                ugDac.open();
                // double curr = 200.0;
                int del = 0;
                int maxDel = 15;
                while (true) {
                  if (smusic.leadNotes != null) {

                    if (del == 0) {
                      float freq = (float) smusic.leadNotes.advance();
                      synthLead.unchuck(delay);
                      synthLead = new WtOsc();
                      synthLead.setFreq(freq);
                      synthLead.fillWithHardSin(7.0f);
                      del++;
                      float max = -1;
                      int max_i = -1;
                      for (int i = 0; i < smusic.colors.length; i++) {
                        if (smusic.colors[i] > max) {

                          max = smusic.colors[i];
                          max_i = i;
                        }
                      }
                      delay.unchuck(ugDac);
                      synthPad.unchuck(delay);
                      delay = new Delay((int) (Delay.SAMPLE_RATE * (max_i + 1)));
                      synthPad.unchuck(ugDac);
                      synthPad = new WtOsc();
                      synthPad.setFreq((float) (max_i + 1) * 400);
                      synthPad.fillWithSqr();
                      synthPad.chuck(delay).chuck(ugDac);
                      synthLead.chuck(delay);

                    } else if (del == maxDel) {
                      del = 0;
                      if (smusic.locality.canGetWeather()) {
                        // maxDel = smusic.locality.getWeather().windspeed*2;
                      }
                    } else {
                      del++;
                    }
                  }
                  if (smusic.locality.canGetWeather()) {
                    // bass.setFreq((float)smusic.locality.getWeather().hightemp);
                  }
                  // synthLead.setFreq((float)curr);
                  // curr += 5;

                  ugDac.tick();
                }
              }
            });
    thisThread.setPriority(Thread.MAX_PRIORITY);
    thisThread.start();
    // ugDac.close();
  }