# Using Minim, when getting loudness of the song, how come I sometimes get a negative value?

**URL:** https://discourse.processing.org/t/using-minim-when-getting-loudness-of-the-song-how-come-i-sometimes-get-a-negative-value/23222
**Category:** Libraries
**Created:** [August 13, 2020, 4:23am UTC](https://discourse.processing.org/t/using-minim-when-getting-loudness-of-the-song-how-come-i-sometimes-get-a-negative-value/23222 "2020-08-13T04:23:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![anon76195010](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@anon76195010](https://discourse.processing.org/u/anon76195010)
#### Post date: [August 13, 2020, 4:23am UTC](https://discourse.processing.org/t/using-minim-when-getting-loudness-of-the-song-how-come-i-sometimes-get-a-negative-value/23222/1 "2020-08-13T04:23:03Z")

</div>

```auto
import ddf.minim.*;
import ddf.minim.analysis.*;

Minim minim;
AudioPlayer audio;
final int BUFFERSIZE = 2048;

void setup()
{
  minim = new Minim(this);
  audio = minim.loadFile("audio.mp3");//, BUFFERSIZE);
  audio.play();
  size(800, 800);
  stroke(0);
}

void draw()
{
  println(audio.left.get(1)); // Sometimes I get negative value
  background(255);
  ellipse(200, 400, audio.left.get(1)*800, audio.left.get(1)*800);
  ellipse(600, 400, audio.right.get(1)*800, audio.right.get(1)*800);
  //audio.drawShape();
  
}

```

How is it possible for me to get a negative value? Shouldn’t it only be positive value?

---

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [August 13, 2020, 5:39am UTC](https://discourse.processing.org/t/using-minim-when-getting-loudness-of-the-song-how-come-i-sometimes-get-a-negative-value/23222/2 "2020-08-13T05:39:24Z")

</div>

Not sure per say, but have you tried taking the absolute value?

---

<div class="post-metadata">

### Author: ![Hapiel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hapiel/32/10226_2.png) [@Hapiel](https://discourse.processing.org/u/Hapiel)
#### Post date: [August 13, 2020, 4:20pm UTC](https://discourse.processing.org/t/using-minim-when-getting-loudness-of-the-song-how-come-i-sometimes-get-a-negative-value/23222/3 "2020-08-13T16:20:03Z")

</div>

Audio is a waveform, every sample you select could be above or below zero.  
If you want to get the loudness, you should be using level(), which is the average level of the whole song  
[http://code.compartmental.net/minim/audiobuffer\_method\_level.html](http://code.compartmental.net/minim/audiobuffer_method_level.html)
