ControlP5 matrix doubt

i have a question friends I am making king of a synthethizer using libpd with processing and im doing good so far doing some faders comunicating with pure data vanilla etc but now that I'm doing a matrix I can't define like do this x1 and y1 activate a trigger and get me a buffer from pd! I can show you my code and you can see where it goes ok (in the faders) and when I can declare (the matrix) i need to do this quick so i hope some help best regards Luis

Answers

  • Answer ✓

    I can't define like do this x1 and y1 activate a trigger

    If you provide and mcve showing your matrix, and what is your approach to generate the trigger from this matrix, then you will get better feedback.

    Kf

  • edited December 2

    I can show you the code but i don't know how to post it here lol sec

  • import controlP5.*; import org.puredata.processing.PureData; import controlP5.*; import oscP5.*; import netP5.*; PureData pd; ControlP5 controlP5; OscP5 oscP5; Knob myKnob; Knob myKnob2; Knob myKnob3; Knob myKnob4; Textlabel texto; Textlabel texto2; int currTime = 0; int currColumn = 0; int x = 10; int y = 5; float osc1 = 0.3; float lfo1 = 0.2; float mix = 0.4; float osc2 = 0.1; float lfo2 = 0.5; float speed = 0.5; float depth = 0.3; float freq = 0.1; float res = 0.5; float vol = 0.2; float oscx = 0.5; float oscy = 0.5; float oscz = 0.5; float linha1 = 1; boolean power = true; void setup() { size(1000, 500); frameRate(25); pd = new PureData(this, 44100, 0, 2); // sampling rate depois inputs e outputs pd.openPatch("Trabalho.pd"); pd.start(); controlP5 = new ControlP5(this); //currColumn = 0; //currTime = millis();
    //oscP5 = new OscP5(this, 8000); // se eu quiser enviar para fora em osc //criar a matrix controlP5.addMatrix("Sequenciador") .setPosition(680, 100) .setSize(280, 280) .setGrid(x, y) .setGap(10, 1) .setInterval(200) .setMode(ControlP5.MULTIPLES) .setColorBackground(color(120)) .setBackground(color(50)) ;
    //obter a matriz int[][] matrix = controlP5.get(Matrix.class, "Sequenciador").getCells(); //manipular a matriz //neste caso faz um print for (int j = 0; j < y; j++) { println(); for (int i = 0; i < x; i++){ print (matrix[i][j]); } } //controlo dos knobs
    myKnob = controlP5.addKnob("oscx") .setRange(0,1) .setValue(50) .setPosition(500,280) .setRadius(30) .setDragDirection(Knob.VERTICAL) ;
    myKnob2 = controlP5.addKnob("oscy") .setRange(0,1) .setValue(50) .setPosition(400,280) .setRadius(30) .setDragDirection(Knob.VERTICAL) ;
    myKnob3 = controlP5.addKnob("oscz") .setRange(0,1) .setValue(50) .setPosition(300,280) .setRadius(30) .setDragDirection(Knob.VERTICAL) ;
    myKnob4 = controlP5.addKnob("phz") .setRange(0,1) .setValue(50) .setPosition(200,280) .setRadius(30) .setDragDirection(Knob.VERTICAL) ; //texto
    texto = controlP5.addTextlabel("label") .setText("Luis Arandas SSMD '17") .setPosition(50,400) .setColorValue(#FFFFFF) .setFont(createFont("Helvetica",14)) ;
    texto2 = new Textlabel(controlP5,"Based on Andy Farnell and Shawn Greenlee Codes",50,420,250,200);
    controlP5.setColorForeground(#134D61); controlP5.setColorBackground(#458DA5); controlP5.setColorActive(#ffffff); Slider osc1 = controlP5.addSlider("osc", 0, 1, 0.3, 40, 50, 35, 200); // name, range-lo, range-hi, start-val, pos-X, pos-Y, width, height osc1.setSliderMode(Slider.FLEXIBLE);
    Slider lfo1 = controlP5.addSlider("lfo", 0, 1, 0.2, 100, 50, 35, 200); lfo1.setSliderMode(Slider.FLEXIBLE); Slider mix = controlP5.addSlider("mix", 0, 1, 0.4, 160, 50, 35, 200); mix.setSliderMode(Slider.FLEXIBLE); Slider osc2 = controlP5.addSlider("osc2", 0, 1, 0.1, 220, 50, 35, 200); osc2.setSliderMode(Slider.FLEXIBLE); Slider lfo2 = controlP5.addSlider("lfo2", 0, 1, 0.5, 280, 50, 35, 200); lfo2.setSliderMode(Slider.FLEXIBLE); Slider speed = controlP5.addSlider("speed", 0, 1, 0.5, 340, 50, 35, 200); speed.setSliderMode(Slider.FLEXIBLE); Slider depth = controlP5.addSlider("depth", 0, 1, 0.22, 400, 50, 35, 200); depth.setSliderMode(Slider.FLEXIBLE); Slider freq = controlP5.addSlider("freq", 0, 1, 0.3, 460, 50, 35, 200); freq.setSliderMode(Slider.FLEXIBLE); Slider res = controlP5.addSlider("res", 0, 1, 0.5, 520, 50, 35, 200); res.setSliderMode(Slider.FLEXIBLE); Slider vol = controlP5.addSlider("vol", 0, 1, 0.2, 580, 50, 35, 200); vol.setSliderMode(Slider.FLEXIBLE); controlP5.addToggle("power", false, 50, 300, 40, 20).setMode(ControlP5.SWITCH); } void matrix(int x, int y) { println("trigger", x, y); }
    // comunicar os sliders com o patch de pd void draw() { background(#1D6983); texto2.draw(this); pd.sendFloat("pd_osc1", (float)osc1); pd.sendFloat("pd_lfo1", (float)vol); pd.sendFloat("pd_mix", (float)mix); pd.sendFloat("pd_osc2", (float)osc2); pd.sendFloat("pd_lfo2", (float)lfo2); pd.sendFloat("pd_speed", (float)speed); pd.sendFloat("pd_depth", (float)depth); pd.sendFloat("pd_freq", (float)freq); pd.sendFloat("pd_res", (float)res); pd.sendFloat("pd_vol", (float)vol); pd.sendFloat("pd_oscx", (float)oscx); pd.sendFloat("pd_oscy", (float)oscy); pd.sendFloat("pd_oscz", (float)oscz);
    if (power==true) { pd.sendFloat("pd_power", (0)); } else { pd.sendFloat("pd_power", (1)); } } //meter a matrix a cantar /*
    int [][] matrix = controlP5.get(Matrix.class, "Sequenciador").getCells();
    if(millis() - currTime > 200) // obter coluna ativa para um dado instante { if(currColumn < x - 1 ) { currColumn += 1 ; }else{ currColumn = 0 ; } currTime = millis(); // guardar tempo }
    // obter a coluna em que cada indice representa se algum dos sons foi ativado int[] column = new int[y] ; // neste caso 5 sons for(int j = 0; j < y; j ++) { column[j] = matrix[currColumn][j]; //if( column[j] = 1) { pd.sendFloat("linha1", (float)linha1);// send to pd

    }
    

    } }
    */ void controlEvent(ControlEvent theEvent) { if (theEvent.isFrom(controlP5.getController("Sequenciador"))) { pd.sendFloat("linha1", linha1);
    } }

  • So here it is I can send it to you if you want and the pure data patch too

  • I can't define like do this x1 and y1 activate a trigger

    So it is not clear what is needed. You want to retrieve some data via pd. You have a matrix from controlP5. There is some sort of trigger based on x1 and y1. You will need to re-formulate your question. Is this question related to Processing or to pd by the way?

    Kf

  • To processing how do I say -> on the 5 Y lines do to pd grab something

  • So this example doesn't work for you? http://www.sojamo.de/libraries/controlP5/examples/controllers/ControlP5matrix/ControlP5matrix.pde

    To clarify, is this when clicking on the matrix or when the sequencer goes on top of an element? in any case, what you are looking is in the above example in this block:

    void myMatrix(int theX, int theY) {
      println("got it: "+theX+", "+theY);
      d[theX][theY].update();
    }
    

    Click on an element and see the console. Then let the sequencer cursor go over that element and see that it triggers it as well.

    Kf

  • Thank Kf i figured out with minim library

Sign In or Register to comment.