Exemplo n.º 1
0
//--------------------------------------------------------------
void
SoundEngine::draw() {

  // Get the correlogram data from the network
  data = getctrl("mrs_realvec/processedData")->to<Marsyas::mrs_realvec>();

  // Every 100 ticks, calculate the max value for each bin
  if (counter % 100 == 0) {
    for (int x = 0; x < MEMORY_SIZE; x++) {
      for (int y = 0; y < POWERSPECTRUM_BUFFER_SIZE; y++) {
        if (data(y,x) > max_data(y)) {
          max_data(y) = data(y,x);
        }
      }
    }
  }

  ofFill();		// draw "filled shapes"

  // Draw a rectangle for each element in the array
  for (int x = 0; x < MEMORY_SIZE; x++) {
    for (int y = 0; y < POWERSPECTRUM_BUFFER_SIZE; y++) {
      int color = 255 - ((data(y,x) * (1.0 / max_data(y))) * 256);
      ofSetColor(color,color,color);
      ofRect(x*4,y*4,4,4);
    }
  }

}
Exemplo n.º 2
0
int QLCCapability_Test::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0:
            initial();
            break;
        case 1:
            min_data();
            break;
        case 2:
            min();
            break;
        case 3:
            max_data();
            break;
        case 4:
            max();
            break;
        case 5:
            middle();
            break;
        case 6:
            name();
            break;
        case 7:
            overlaps();
            break;
        case 8:
            copy();
            break;
        case 9:
            load();
            break;
        case 10:
            loadWrongRoot();
            break;
        case 11:
            loadNoMin();
            break;
        case 12:
            loadNoMax();
            break;
        case 13:
            loadMinGreaterThanMax();
            break;
        case 14:
            save();
            break;
        default:
            ;
        }
        _id -= 15;
    }
    return _id;
}
Exemplo n.º 3
0
//--------------------------------------------------------------
SoundEngine::SoundEngine(string name)
  : ofxMarsyasNetwork(name)
{
  priority	= 2;

  disableAllEvents();
  ofAddListener(ofEvents.setup, (ofxMSAInteractiveObject*)this, &ofxMSAInteractiveObject::_setup);
  ofAddListener(ofEvents.draw, (ofxMSAInteractiveObject*)this, &ofxMSAInteractiveObject::_draw);

  ofSetFrameRate(10); // if vertical sync is off, we can go a bit fast... this caps the framerate at 60fps.

  max_data.create(POWERSPECTRUM_BUFFER_SIZE);

  for (int i = 0; i < POWERSPECTRUM_BUFFER_SIZE; i++) {
    max_data(i) = -999.9;
  }
  counter = 0;
}