Archive for the 'Audio' Category

Mar 28 2009

Jmyron + controlP5 iteration #2

From the old version, the problem that was happening was that there setting all RGB values to one slider value would only detect black to white colors. I changed so that now the RGB channels can now be all set individually. It works a lot better as can be seen from the screenshot. The bright blue areas with the green outline are the blogs, I've set it to detect the red boxes in this screenshot.
rgb_detection
And here's the code for it:

  1. import JMyron.*;
  2. import controlP5.*;
  3.  
  4. JMyron m;
  5. ControlP5 controlP5;
  6.  
  7. int red_color = 0;
  8. int green_color = 0;
  9. int blue_color = 0;
  10. int sensitivity = 40;
  11. int min_size = 10;
  12. int max_size=10;
  13. String RGBValue = "";
  14. int mouseX;
  15. int mouseY;
  16.  
  17. void setup(){
  18. int width = 720;
  19. int height = 576;
  20. size(width,height);
  21. m = new JMyron();
  22. m.start(width,height);
  23. frameRate(30);
  24. println("Myron " + m.version());
  25. noFill();
  26. controlP5 = new ControlP5(this);
  27. controlP5.addSlider("R",0,255,0,10,10,10,50).setId(1);
  28. controlP5.addSlider("G",0,255,0,60,10,10,50).setId(2);
  29. controlP5.addSlider("B",0,255,0,100,10,10,50).setId(3);
  30. controlP5.addSlider("sensitivity",0,255,40,10,140,10,50).setId(4);
  31. controlP5.addSlider("min size",0,400,10,60,140,10,50).setId(5);
  32. controlP5.addSlider("max size",0,400,10,100,140,10,50).setId(6);
  33.  
  34. }
  35.  
  36. void draw(){
  37.  
  38. m.trackColor(red_color,green_color,blue_color,sensitivity);
  39. //m.minDensity(min_size);
  40. //m.maxDensity(max_size);
  41. float ir,ig,ib;
  42. m.update();//update the camera view
  43. int[] img = m.image(); //get the normal image of the camera
  44.  
  45. //draw what the camera sees
  46. loadPixels();
  47. for(int i=0;i<width*height;i++){ //loop through all the pixels
  48. pixels[i] = img[i]; //draw each pixel to the screen
  49. }
  50. updatePixels();
  51.  
  52. stroke(0,150,0);
  53. int[][][] list = m.globEdgePoints(30);//get the outlines
  54. for(int i=0;i
  55. <list.length;i++){
  56. beginShape();
  57. if(list[i]!=null){
  58. for(int ii=0;ii<list[i].length;ii++){
  59. vertex(list[i][ii][0],list[i][ii][1]);
  60. }
  61. }
  62. endShape();
  63. }
  64.  
  65. }
  66.  
  67. void controlEvent(ControlEvent theEvent) {
  68. //if a control event is received from the P5 controller
  69. //println("got a control event from controller with id "+theEvent.controller().id());
  70.  
  71. //check from what controller it came
  72. //by looking for the ID element
  73. switch(theEvent.controller().id()) {
  74.  
  75. //if the ID element is number 1 (the tracing color slider)
  76. case(1):
  77. red_color = (int)(theEvent.controller().value());
  78. println("Red" + red_color);
  79. println("Green" + green_color);
  80. println("Blue" + blue_color);
  81. break;
  82.  
  83. case(2):
  84. green_color = (int)(theEvent.controller().value());
  85. break;
  86.  
  87. case(3):
  88. blue_color = (int)(theEvent.controller().value());
  89. break;
  90.  
  91. case(4):
  92. sensitivity = (int)(theEvent.controller().value());
  93. print("tracetolerance changed to " + sensitivity + "\n");
  94. break;
  95.  
  96. case(5):
  97. min_size = (int)(theEvent.controller().value());
  98. break;
  99.  
  100. case(6):
  101. max_size = (int)(theEvent.controller().value());
  102. break;
  103.  
  104. }
  105.  
  106. }
  107. public void stop(){
  108. m.stop();//stop the object
  109. super.stop();
  110. }

No responses yet

Feb 24 2009

ess r2

Published by Michael Doyle under Audio, Processing, ess r2

Been playing around with ess r2. I made a small throwaway prototype to control audio and pitch. It's not working really well at the moment due to the report deadline.

  1.  
  2. if(mouseButton == LEFT)
  3. myWave=new SineWave(pitch,volume++);
  4. myWave.generate(myChannel,0,myChannel.frames(1000));
  5. myChannel.play();
  6.  

Have to come back to it later and implement it with controlP5.

No responses yet

Jan 22 2009

proMIDI

Published by Michael Doyle under Audio, Processing, proMIDI

Playing around with proMIDI. There's a sequencer example in the library. Notes are easily generated and sequenced by:

Track track = new Track("one", test);
track.setQuantization(Q._1_4);
track.addEvent(new Note(36, 127,40), 0);
track.addEvent(new Note(49, 80,40), 1);
track.addEvent(new Note(41, 90,40), 2);
track.addEvent(new Note(46, 127,40), 3);

The newNote takes in the variables pitch, voume and velocity. Velocity doesn't seem to work for me.

No responses yet

Jan 14 2009

Jmusic + jm-Etude

Published by Michael Doyle under Audio

Having big problems with understanding these. The documentation is leanign a lot more towards the theory of composition and how to program music.
The tutorials are all in java, so I have to get a firm grip on Java first and then transpose it into processing.
I think I might stick with promidi for the moment and concentrate getting JMyron working with the new webcam.

No responses yet

Jan 07 2009

Audio Cookbook

Published by Michael Doyle under Audio, Processing

http://audiocookbook.org/tag/processingorg/

No responses yet

Nov 07 2008

jm-Etude + jMusic

Published by Michael Doyle under Audio, Processing

jm-Etude is an api to communicate with jMusic

jMusic can create, store and manipulate various audio formats.

There's a huge amount of information on jMusic that I have jest skimmed through, I haven't had the chance to really sift through it all. I have seen tutorials on basic methods of manipulating data.

No responses yet