# Mousepress for playing sound component works, but sound 'piles up' with multiple presses

**URL:** <https://discourse.psychopy.org/t/mousepress-for-playing-sound-component-works-but-sound-piles-up-with-multiple-presses/19414>\
**Category:** Online experiments\
**Tags:** sound\
**Created:** [January 6, 2021, 12:58pm UTC](https://discourse.psychopy.org/t/mousepress-for-playing-sound-component-works-but-sound-piles-up-with-multiple-presses/19414 "2021-01-06T12:58:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sabinosaurus](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/sabinosaurus/32/13114_2.png) [@Sabinosaurus](https://discourse.psychopy.org/u/Sabinosaurus)\
**Post date:** [January 6, 2021, 12:58pm UTC](https://discourse.psychopy.org/t/mousepress-for-playing-sound-component-works-but-sound-piles-up-with-multiple-presses/19414/1 "2021-01-06T12:58:21Z")

</div>

Hi guys,

I am building an experiment (version 2.10, standalone) where participants must create a signal by pressing a mouse button. It’s one of these things that work fine locally, but not online.

The critical part is that they can test whether the apparatus works: they can try it out and click multiple times in the test round. So, basically, they click --\> sound is played, they release --\> sound stops, click again and sound is played again, etc.

When I try this in my pilot online, the sound seems to ‘pile up’: it sounds as though multiple instances of the sound get played at the same time.

Here’s my JS code:

if ((! (testsound.status === STARTED))) {  
if (mouse\_2.getPressed()[0]) {  
testsound.play();  
}  
} else {  
if ((testsound.status === STARTED)) {  
if ((! mouse\_2.getPressed()[0])) {  
testsound.stop();  
}  
}  
}

The sound component is set to ‘set every frame’, so for every frame, it checks whether the mouse is being clicked or not.

I’m not sure what’s causing this; like i said, it worked locally before… I feel like it needs something to clear the presses, but clearEvent() does not work.

-Sabine

---

<div class="post-metadata">

**Author:** ![sotiri](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@sotiri](https://discourse.psychopy.org/u/sotiri)\
**Post date:** [January 6, 2021, 4:19pm UTC](https://discourse.psychopy.org/t/mousepress-for-playing-sound-component-works-but-sound-piles-up-with-multiple-presses/19414/2 "2021-01-06T16:19:39Z")

</div>

Hi @Sabinosaurus, thanks for flagging, could you send me a link to your repo so I can take a closer look? Thanks, s.

---

<div class="post-metadata">

**Author:** ![sotiri](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@sotiri](https://discourse.psychopy.org/u/sotiri)\
**Post date:** [January 7, 2021, 1:59pm UTC](https://discourse.psychopy.org/t/mousepress-for-playing-sound-component-works-but-sound-piles-up-with-multiple-presses/19414/3 "2021-01-07T13:59:46Z")

</div>

Hi @Sabinosaurus, thanks for adding my account to your repo, could you give me developer level permissions so I can access the code? Cheers, x

---

<div class="post-metadata">

**Author:** ![Sabinosaurus](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/sabinosaurus/32/13114_2.png) [@Sabinosaurus](https://discourse.psychopy.org/u/Sabinosaurus)\
**Post date:** [January 7, 2021, 7:42pm UTC](https://discourse.psychopy.org/t/mousepress-for-playing-sound-component-works-but-sound-piles-up-with-multiple-presses/19414/4 "2021-01-07T19:42:20Z")

</div>

Sorry @sotiri, fixed it now

---

<div class="post-metadata">

**Author:** ![sotiri](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@sotiri](https://discourse.psychopy.org/u/sotiri)\
**Post date:** [January 8, 2021, 1:10pm UTC](https://discourse.psychopy.org/t/mousepress-for-playing-sound-component-works-but-sound-piles-up-with-multiple-presses/19414/5 "2021-01-08T13:10:52Z")

</div>

Hi @Sabinosaurus, great thanks 😊 Cool study! It looks like your desktop project is using the latest PsychoPy, but the HTML export is set to an older, pre 2020 version. You can choose which version to target for online use via the settings dialog below,

 ![Brenda 2021-01-08 at 12.57.14](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/2/2/2280818db46fcd35ff6075e00adf97bc3faa8622.png)

I have staged [an updated support fork](https://pavlovia.org/support/pilotsp_aud), does that work more or less as expected? x

---

<div class="post-metadata">

**Author:** ![Sabinosaurus](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/sabinosaurus/32/13114_2.png) [@Sabinosaurus](https://discourse.psychopy.org/u/Sabinosaurus)\
**Post date:** [January 10, 2021, 8:46pm UTC](https://discourse.psychopy.org/t/mousepress-for-playing-sound-component-works-but-sound-piles-up-with-multiple-presses/19414/6 "2021-01-10T20:46:30Z")

</div>

Hey, sorry for the late response! That is actually odd; I created the project initially in 2015, but updated my psychopy standalone version recently in order to run this experiment online.

It didn’t fix the issue unfortunately… In the end I decided to adjust the task a bit so that I no longer have to deal with the issue.

Thanks for reaching out though!

---

<div class="post-metadata">

**Author:** ![sotiri](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@sotiri](https://discourse.psychopy.org/u/sotiri)\
**Post date:** [January 11, 2021, 11:34am UTC](https://discourse.psychopy.org/t/mousepress-for-playing-sound-component-works-but-sound-piles-up-with-multiple-presses/19414/7 "2021-01-11T11:34:39Z")

</div>

No problem, happy coding ☀
