# Question of how to generate multiple sound by TriOsc

**URL:** <https://discourse.processing.org/t/question-of-how-to-generate-multiple-sound-by-triosc/40522>\
**Category:** Libraries\
**Created:** [January 9, 2023, 3:33pm UTC](https://discourse.processing.org/t/question-of-how-to-generate-multiple-sound-by-triosc/40522 "2023-01-09T15:33:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joygou](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@Joygou](https://discourse.processing.org/u/Joygou)\
**Post date:** [January 9, 2023, 3:33pm UTC](https://discourse.processing.org/t/question-of-how-to-generate-multiple-sound-by-triosc/40522/1 "2023-01-09T15:33:26Z")

</div>

Hi, I’m trying to do some generating music stuff by processing and the sound library.  
I am trying to generate note by clicking the mouse, and the note will be played again and agian in draw() function. I want to have a new note playing when each time the mouse click on the screen, but the issue is I found that when I click the mouse twice the second note will replace the first note, so two notes cannot play in parallel.  
I’m very new to processing, I want to know how I can solve this problem and is there any better way to build this. Thank you.  
This is part of my code:

```auto
void draw() {
        if (note == -1){
        }
        //note will note play until mouse click
        else if ((millis() > trigger) && (note< midiSequence.length) && (amp > 0)) {
                  
            triOsc.play(midiToFreq(midiSequence[note]), amp);

            env.play(triOsc, attackTime, sustainTime, sustainLevel, releaseTime);
            
     
            trigger = millis() + duration;
       //other code

```

```auto
void mouseClicked() {
        ellipse(mouseX,mouseY,50,50);
      //using position of X to decide the note
      float n = map(mouseX, 0, width, 0, 800);
      note = int(n/100);

      notestored.add(note);
      
      amp = 0.5;

 }
 

```

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [January 15, 2023, 8:16am UTC](https://discourse.processing.org/t/question-of-how-to-generate-multiple-sound-by-triosc/40522/2 "2023-01-15T08:16:00Z")

</div>

Hi @Joygou,

Please just read the documentation…

Cheers  
— mnse

> **[Sound](https://processing.org/tutorials/sound/)**
>
> Learn how to play, analyze, and synthesize sound with the Sound Library.

---

<div class="post-metadata">

**Author:** ![Joygou](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@Joygou](https://discourse.processing.org/u/Joygou)\
**Post date:** [February 3, 2023, 11:08am UTC](https://discourse.processing.org/t/question-of-how-to-generate-multiple-sound-by-triosc/40522/3 "2023-02-03T11:08:16Z")

</div>

Thanks for replying, I read the documentation again and I see how the multiple note is played. But what I want is to make each added note playing independently with different characteristic.(pitches frequence and amplitutde), I dont think the content in documentation is what I want but anyway I will read through it agian.  
Thanks a lot.
