# Minim and assign character

**URL:** https://discourse.processing.org/t/minim-and-assign-character/14274
**Category:** Libraries
**Created:** [September 29, 2019, 12:56pm UTC](https://discourse.processing.org/t/minim-and-assign-character/14274 "2019-09-29T12:56:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nishafatin96](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@nishafatin96](https://discourse.processing.org/u/nishafatin96)
#### Post date: [September 29, 2019, 12:56pm UTC](https://discourse.processing.org/t/minim-and-assign-character/14274/1 "2019-09-29T12:56:19Z")

</div>

hi there, do help me, first of all, I have problem to add more than 1 sound and make sound that I add detect the beat of it. my sound is in different file because I want to do wearable electronic using fingers and assign one by sound by each fingers, that one after coding part is done I’m connecting it with arduino . I am using drum sound which is drum bass, cymbal , hi hat, clap and snare. So when one fingers is move so come out with one sound… I just dont get the solution for adding more than one sound and to make the sound detect the beat of image pattern. Here is the coding

float n;  
float n3;  
float n5;  
float speed2;

//MUSIC  
import ddf.minim._;  
import ddf.minim.signals._;  
import ddf.minim.analysis._;  
import ddf.minim.effects._;  
Minim minim;  
AudioPlayer s1, s2, s3, s4, s5;

void setup () {  
fullScreen(P3D);  
noCursor();  
smooth();  
background (0);

minim = new Minim(this);

s1= minim.loadFile (“hihat.mp3”, 1024);  
s2 = minim.loadFile (“cymbal.mp3”,1024);  
s3 = minim.loadFile (“bassdrum.mp3”,1024);  
s4 = minim.loadFile (“snare.mp3”,1024);  
s5 = minim.loadFile (“clap.mp3”,1024);

s1.play ();  
s2. play ();  
[//s3.play](https://s3.play) ();  
s4.play ();  
s5. play ();  
s4. loop (1);  
s2.loop (4);

}

void draw () {

fill(0, 20);  
noStroke();  
rect(0, 0, width, height);  
translate(width/2, height/2);

```
 for (int i = 0; i <s1 .bufferSize() -1; i++) {

float angle = sin(i+(n-2))*40;
float x = sin(radians(i))*(n/angle);

float leftLevel = s1.left.level() * 20;

ellipse(i, i, leftLevel, leftLevel);
rotateZ(n*-PI/3*0.05);

fill (random(255), random (255), random (255));
//fill(#00ccff, 90); //Light Blue

```

}

n += 0.008 ;  
n3 += speed2;  
n5 += speed2;

exit ();  
}

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [September 29, 2019, 2:16pm UTC](https://discourse.processing.org/t/minim-and-assign-character/14274/2 "2019-09-29T14:16:24Z")

</div>

-a- please post your code by using the  
`</> Preformatted text` button in the editor

-b- as long you have a

```auto
exit();

```

inside your draw() loop  
you might see a short flicker of the canvas  
and no sound will be played

-c- as the drum sample file are possibly short  
and all play once ( or 4 times ) from setup  
not much to hear,  
why you not start with 2 and link them to 2 keys

```auto
 void keyPressed() {
 if ( key == 'q' ) s1.play();
 if ( key == 'w' ) s2.play();
 }

```

so you can experiment.

-d- ignore the show question until the DRUM works.
