# \[p5.js Sound\] Setting time between which amp.getLevel returns values

**URL:** <https://discourse.processing.org/t/p5-js-sound-setting-time-between-which-amp-getlevel-returns-values/31297>\
**Category:** Libraries\
**Created:** [July 17, 2021, 12:40pm UTC](https://discourse.processing.org/t/p5-js-sound-setting-time-between-which-amp-getlevel-returns-values/31297 "2021-07-17T12:40:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![acagastya](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@acagastya](https://discourse.processing.org/u/acagastya)\
**Post date:** [July 17, 2021, 12:40pm UTC](https://discourse.processing.org/t/p5-js-sound-setting-time-between-which-amp-getlevel-returns-values/31297/1 "2021-07-17T12:40:56Z")

</div>

![Screenshot 2021-07-17 at 10.36.39](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/3b3e3d9f550d49a879b7c074adf65735e235f866.png)  
Hi, I am trying to get the amplitude of an audio file, to render something similar to the attached screenshot. I want to show the amp every 100ms only. If I understand correctly, amp.getLevel is called every time a new frame is rendered. Is there a way I can control in how many seconds do I wish to get the value of the amplitude? I can try setting `frameRate(10)`, but that makes the visual look rather laggy.

What I am trying to do can be understood by looking at the visual of Apple’s Voice Memos [Demo link on YouTube from 00:46 - 00:50](https://youtu.be/8jb9fR4foS0?t=46)

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [July 18, 2021, 7:24pm UTC](https://discourse.processing.org/t/p5-js-sound-setting-time-between-which-amp-getlevel-returns-values/31297/2 "2021-07-18T19:24:14Z")

</div>

hi! welcome to the forum.

sounds like what you want to do is to scan the entire file at first rather than analyzing on the fly. I haven’t tried it yet but [`getPeaks`](https://p5js.org/reference/#/p5.SoundFile/getPeaks) might do the exact job what you’re looking for!
