/src/Mouth.cpp

http://github.com/mazbox/Speakotron · C++ · 64 lines · 18 code · 17 blank · 29 comment · 0 complexity · 354ec3cf1ec458c4c0b9ad06aaa28fcb MD5 · raw file

  1. /*
  2. * Mouth.cpp
  3. * mouthsynth
  4. *
  5. * Created by Marek Bereza on 04/09/2010.
  6. * Copyright 2010 Marek Bereza. All rights reserved.
  7. *
  8. */
  9. #include "Mouth.h"
  10. void Mouth::update(const ofRectangle &rect) {
  11. state = false;
  12. filter = 0;
  13. // find x, y, width, height
  14. this->x = rect.x;
  15. this->y = rect.y;
  16. this->width = rect.width;
  17. this->height = rect.height;
  18. float pitchInput = y+(height/2); // this is the vertical centre of the mouth
  19. pitch = ofMap(pitchInput, 0, 320, 0, 1);
  20. pitch = ofMap(pitch, 0.6, 0.1, 0, 1);
  21. pan = ofMap(x + width/2, 0, width, 0, 1);
  22. pos = ofPoint(x + width/2, y + height/2);
  23. /*
  24. // this is some weird ratio of width to height
  25. if(state==true) {
  26. filter = (rightMost-leftMost)/width;
  27. }
  28. // find filter and whether the state is on or not
  29. if(state&&!lastState) {
  30. justOpened = true;
  31. } else {
  32. justOpened = false;
  33. }
  34. lastState = state;
  35. */
  36. }
  37. void Mouth::draw() {
  38. ofSetHexColor(0xFF0000);
  39. ofRect(*this);
  40. }