# Music visualizer processing \> minim library

**URL:** <https://discourse.processing.org/t/music-visualizer-processing-minim-library/24068>\
**Category:** Español\
**Created:** [September 23, 2020, 3:12am UTC](https://discourse.processing.org/t/music-visualizer-processing-minim-library/24068 "2020-09-23T03:12:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sabrufran](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@sabrufran](https://discourse.processing.org/u/sabrufran)\
**Post date:** [September 23, 2020, 3:12am UTC](https://discourse.processing.org/t/music-visualizer-processing-minim-library/24068/1 "2020-09-23T03:12:39Z")

</div>

hola, soy nueva con processing, y queria lograr sincronizar mi sketh con el audio, especificamente la parte donde surgen las montañas y que crezcan sincronizadamente con el audio.

Para entender lo del audio, use el ejemplo “PlayAFile” de la libreria.

Si alguno podria ayudarme y resolverlo, se lo agradeceria.

Este es mi codigo, que lo segui en base a este video: [https://www.youtube.com/watch?v=IKB1hWWedMk](https://www.youtube.com/watch?v=IKB1hWWedMk)

```auto
//dibujo
int cols,rows;
int scl = 20;
int w= 2000;
int h= 1600;
  
//vuelo
float terrain [][] ;
float flying = 0;

//musica
import ddf.minim.*;
Minim minim;
AudioPlayer player;

void setup(){
  size(500,500, P3D);
  cols = w/scl;
  rows = h/scl;
  terrain = new float[cols][rows];
  
   minim = new Minim(this);
   player = minim.loadFile("when i was your man audio editado.mp3");
}
void draw(){
  
  player.play();
 
  background(0);
  stroke(255);
  noFill();
  
  //posicion dibujo
  translate(width/2,height/2+50);
  rotateX(PI/3);
  translate(-w/2, -h/2);
  
  frameRate(1);
  
   flying -= 0.2;
   float yoff = flying;
    for (int y = 0; y < rows; y++){
     float xoff = 0;
      for(int x= 0; x < cols; x++){
        terrain [x][y] = map(noise (xoff, yoff),0,1,-100, 100);
        xoff += 0.2;
      }
      yoff += 0.2;
   }
  
  for (int y = 0; y < rows-1; y++){
   beginShape(TRIANGLE_STRIP);
    for(int x= 0; x < cols; x++){
     vertex(x*scl, y*scl, terrain[x][y]);
     vertex(x*scl, (y+1)*scl, terrain [x][y+1]);
    
      //rect(x*scl,y*scl,scl,scl);
    }
    endShape();
  } 
}

```

acá les comparto el ejemplo “PlayAFile”:

```auto
/**
  * This sketch demonstrates how to play a file with Minim using an AudioPlayer. <br />
  * It's also a good example of how to draw the waveform of the audio. Full documentation 
  * for AudioPlayer can be found at http://code.compartmental.net/minim/audioplayer_class_audioplayer.html
  * <p>
  * For more information about Minim and additional features, 
  * visit http://code.compartmental.net/minim/
  */

import ddf.minim.*;

Minim minim;
AudioPlayer player;

void setup()
{
  size(512, 200, P3D);
  
  // we pass this to Minim so that it can load files from the data directory
  minim = new Minim(this);
  
  // loadFile will look in all the same places as loadImage does.
  // this means you can find files that are in the data folder and the 
  // sketch folder. you can also pass an absolute path, or a URL.
  player = minim.loadFile("when i was your man audio editado.mp3");
}

void draw()
{
  background(0);
  stroke(255);
  
  // draw the waveforms
  // the values returned by left.get() and right.get() will be between -1 and 1,
  // so we need to scale them up to see the waveform
  // note that if the file is MONO, left.get() and right.get() will return the same value
  for(int i = 0; i < player.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player.bufferSize(), 0, width );
    float x2 = map( i+1, 0, player.bufferSize(), 0, width );
    line( x1, 50 + player.left.get(i)*50, x2, 50 + player.left.get(i+1)*50 );
    //line( x1, 150 + player.right.get(i)*50, x2, 150 + player.right.get(i+1)*50 );
  }
  
  // draw a line to show where in the song playback is currently located
 // float posx = map(player.position(), 0, player.length(), 0, width);
 // stroke(0,200,0);
  //line(posx, 0, posx, height);
  
  if ( player.isPlaying() )
  {
    text("Press any key to pause playback.", 10, 20 );
  }
  else
  {
    text("Press any key to start playback.", 10, 20 );
  }
}

void keyPressed()
{
  if ( player.isPlaying() )
  {
    player.pause();
  }
  // if the player is at the end of the file,
  // we have to rewind it before telling it to play again
  else if ( player.position() == player.length() )
  {
    player.rewind();
    player.play();
  }
  else
  {
    player.play();
  }
}

```

Gracias!

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [September 24, 2020, 8:41pm UTC](https://discourse.processing.org/t/music-visualizer-processing-minim-library/24068/2 "2020-09-24T20:41:10Z")

</div>

¡Hola y bienvenido al foro!

En los ejemplos de minim, mire los ejemplos en “Analysis”. En particular, FrequencyEnergyBeatDetection y SoundEnergyBeatDetection. Debido a que solo desea afectar una variable … la velocidad / tamaño de las montañas … Yo recomendaría usar SoundEnergyBeatDetection y crear un objeto BeatDetect, luego usarlo para cambiar el tamaño / altura de su montaña.

Noto que publicaste esta pregunta en español y [en inglés](https://discourse.processing.org/t/music-visualizer-processing-minim-library/24067). ¿Es este su idioma preferido para cuando los usuarios comparten respuestas? La mayoría de las respuestas del foro están escritas en inglés, pero muchas personas también usan Google Translate.

---

<div class="post-metadata">

**Author:** ![sabrufran](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@sabrufran](https://discourse.processing.org/u/sabrufran)\
**Post date:** [September 28, 2020, 12:34pm UTC](https://discourse.processing.org/t/music-visualizer-processing-minim-library/24068/3 "2020-09-28T12:34:59Z")

</div>

Hola, si prefiero usar es español, muchas gracias por la respuesta, ayudo un montón. Pero debido a como yo programe el dibujo. Lo que yo quería lograr, no se va a poder hacer, tendría que cambiar otras cosas antes.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [September 28, 2020, 1:58pm UTC](https://discourse.processing.org/t/music-visualizer-processing-minim-library/24068/4 "2020-09-28T13:58:07Z")

</div>

¿Ya ha mirada a SoundEnergyBeatDetection?

---

<div class="post-metadata">

**Author:** ![sabrufran](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@sabrufran](https://discourse.processing.org/u/sabrufran)\
**Post date:** [September 28, 2020, 2:51pm UTC](https://discourse.processing.org/t/music-visualizer-processing-minim-library/24068/5 "2020-09-28T14:51:28Z")

</div>

SI, me sirvió un montón para entender mas, pero tengo que volver a hacer el sketch de otra manera para poder lograr el efecto que yo quería.

Gracias
