# Getting amplitude values from a SoundFile (processing.sound)

**URL:** <https://discourse.processing.org/t/getting-amplitude-values-from-a-soundfile-processing-sound/13877>\
**Category:** Libraries\
**Created:** [September 8, 2019, 2:29pm UTC](https://discourse.processing.org/t/getting-amplitude-values-from-a-soundfile-processing-sound/13877 "2019-09-08T14:29:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brunehilde](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/brunehilde/32/6387_2.png) [@Brunehilde](https://discourse.processing.org/u/Brunehilde)\
**Post date:** [September 8, 2019, 2:29pm UTC](https://discourse.processing.org/t/getting-amplitude-values-from-a-soundfile-processing-sound/13877/1 "2019-09-08T14:29:35Z")

</div>

Hi !  
I’ve been playing around with the Sound library for a bit to make a simple music visualizer, but I can’t seem to get the amp values for specific points in the music to make a nice timeline.

Here’s how I defined all the stuff I believe to be necessary for this:

```auto
SoundFile music;
Amplitude amp;
float[] ampValues;

void setup()
{
  size(512, 512);

  music = new SoundFile(this, "gohma-forward.mp3");
  amp = new Amplitude(this);
  ampValues = new float[width];

  setAmpValues();

  music.play();
}

```

And here’s the `setAmpValues()` function supposed to put all the amp values taken at regular intervals into the `ampValues[]` array which doesn’t seem to work:

```auto
void setAmpValues()
{
  music.play();
  for(int i = 0; i < ampValues.length; i++)
  {
    music.jump(map(i, 0, width, 0, music.duration()));
    ampValues[i] = amp.analyze();
  }
  music.stop();
}

```

Thanks for taking a look at my problem 🙂

P.S: does anyone know why processing is kinda weird with how it handles code highlighting ? In `music.play()` the `play()` isn’t highlighted, but in `music.stop()` the `stop()` is highlighted…

---

<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 8, 2019, 9:54pm UTC](https://discourse.processing.org/t/getting-amplitude-values-from-a-soundfile-processing-sound/13877/2 "2019-09-08T21:54:42Z")

</div>

> [@Brunehilde](#):
>
> processing … how it handles code highlighting

-a- the editor can highlight lots of words from the basic processing language,  
and add also some JAVA defaults.  
-b- and sometimes there is a bug because one is forgotten…

but what you talk here is the highlighting of methods of a external library…  
no, as far i know there is no way that a added library can modify the  
highlighting of the editor ( load add words to the word list / even make it depending on if a external lib is imported … )

so if that is not the case, what is it here?  
stop() is a known method of a other tool or JAVA  
( i think here the internal serial library ( also clear() works ))  
processing-3.5.3\modes\java\keywords.txt line 288

play() is no known default command.

so when you make libraries or just own classes  
you write methods ( functions ) for it,  
and there might be a naming convention??  
[Java Naming Conventions - HowToDoInJava](https://howtodoinjava.com/java/basics/java-naming-conventions/) ?not too detailed?  
so you can avoid or choose known words…  
in a class  
MyCircle{} you can make a  
`void draw(){} `  
function. ( and it will be BLUE when you call `onecircle.draw();` )  
if you choose to call that  
`void show(){}`  
( ` onecircle.show();` it will be black )

* * *

besides that sound lib is not loaded by default ( i call it external ),  
but when it is loaded ( by contribution manager )  
it appears in the internal libraries list. also confusing.
