# Project Help Adding Sound

**URL:** <https://discourse.processing.org/t/project-help-adding-sound/9368>\
**Category:** Coding Questions\
**Created:** [March 17, 2019, 3:22am UTC](https://discourse.processing.org/t/project-help-adding-sound/9368 "2019-03-17T03:22:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ixd](https://avatars.discourse-cdn.com/v4/letter/i/41988e/32.png) [@ixd](https://discourse.processing.org/u/ixd)\
**Post date:** [March 17, 2019, 3:22am UTC](https://discourse.processing.org/t/project-help-adding-sound/9368/1 "2019-03-17T03:22:19Z")

</div>

Trying to make it so that when I press on number 1, the first sound (rollingsuitcase) is played. If you click again on the number 1, the sound should stop. Number 2 will make second sound (airportambiance) play. What’s the best way to do this? Very beginner so need detailed step by step!

```auto
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];

function preload() {
  soundFormats('mp3');
  rollingsuitcase = loadSound('RollingSuitcase.mp3');
  airportambiance = loadSound('Airportambiance.mp3');
  seatbeltsound = loadSound('SeatbeltSound.mp3');
  seatbeltclick = loadSound('SeatbeltClick.mp3');
  airplanetakeoff = loadSound('AirplaneTakeOff.mp3');
  eating = loadSound('Eating.mp3');
  water = loadSound('Water.mp3');
  toiletflush = loadSound('AirplaneToilet.mp3');
  airplaneland = loadSound('AirplaneLanding.mp3');
  
}

function setup() {
  createCanvas(500, 500);
  colorMode(HSB);
}

function draw() {
  background(0);
	strokeWeight(1);
	stroke(255);
	
	i = 0;
	for (var x = 50; x < width; x = x + 180)
	for (var y = 50; y < 500; y = y + 180) {
	ellipse(x, y, 25, 25);
	text(numbers[i], x, y);
	i++;
	}		
  
}

```

---

<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:** [March 17, 2019, 4:36am UTC](https://discourse.processing.org/t/project-help-adding-sound/9368/2 "2019-03-17T04:36:22Z")

</div>

sorry, but there is no

- code to play a sound file
- code to operate the tiles.

how about team work,  
you get a song loaded and played, stopped for play a other …  
and i do the operation of 9 tiles with keyboard and mouse click…  
interface between the “modules” is a variable  
let mysel = -1;  
and 0 … 8 for a song to play.  
[https://editor.p5js.org/kll/sketches/QUnp7YbGv](https://editor.p5js.org/kll/sketches/QUnp7YbGv)
