# IPlug2 Faust IMidiMsg Note On / Note Off

**URL:** <https://iplug2.discourse.group/t/iplug2-faust-imidimsg-note-on-note-off/141>\
**Category:** Faust\
**Created:** [1 July 2020 11:31 UTC](https://iplug2.discourse.group/t/iplug2-faust-imidimsg-note-on-note-off/141 "2020-07-01T11:31:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![suton](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@suton](https://iplug2.discourse.group/u/suton)\
**Post date:** [1 July 2020 11:31 UTC](https://iplug2.discourse.group/t/iplug2-faust-imidimsg-note-on-note-off/141/1 "2020-07-01T11:31:55Z")

</div>

hello everyone, i am trying to figure out how to receive midi from my DAW inside of my Faustcode for a couple of days now.  
i have this event handler running:

```
void mySynth::ProcessMidiMsg(const IMidiMsg& msg)
{
  int status = msg.StatusMsg();
  switch (status)
  {
  case IMidiMsg::kNoteOn:
  {
    
    SendMidiMsg(msg);
    break;
  }
  case IMidiMsg::kNoteOff:
  {
    
    SendMidiMsg(msg);
    break;
  }

```

…  
on faust’s side i have this code:

declare options “[midi:on]”;

```
frequency = hslider("frequency",500,30,12000,0.01);

gate = checkbox("h:gate");

osc = os.osc(frequency);  

process = osc*gate;

```

but i miss the link inbetween. how can i send the midi on and off messages to the “gate” ?

thanks for your help in advance

---

<div class="post-metadata">

**Author:** ![olilarkin](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/olilarkin/32/2_2.png) [@olilarkin](https://iplug2.discourse.group/u/olilarkin)\
**Post date:** [6 July 2020 09:43 UTC](https://iplug2.discourse.group/t/iplug2-faust-imidimsg-note-on-note-off/141/2 "2020-07-06T09:43:48Z")

</div>

Since the gate is a parameter of the Faust dsp in your above example, you can use ` mFaustProcessor.SetParameterValue("gate", 1.)` to set it high when there is a note on message.

related news…

Stéphane Letz, one of the Faust developers has added support for faust’s own poly dsp midi handling, so you can now make a polysynth in faust like this (see IPlugFaustDSP example)

```auto
declare options "[midi:on][nvoices:12]";
declare name "FaustExample";

import("stdfaust.lib");

freq = hslider("freq ",200,50,1000,0.01);
gain = hslider("gain",0.5,0,1,0.01);
master = hslider("master [midi: ctrl 7]",0.5,0,1,0.01);
gate = button("gate");
envelope = en.adsr(0.01,0.01,0.8,0.1,gate)*gain;
process = os.sawtooth(freq)*envelope*master <: (_,_);

```

---

<div class="post-metadata">

**Author:** ![suton](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@suton](https://iplug2.discourse.group/u/suton)\
**Post date:** [6 July 2020 13:46 UTC](https://iplug2.discourse.group/t/iplug2-faust-imidimsg-note-on-note-off/141/3 "2020-07-06T13:46:49Z")

</div>

thanks a lot… i am going to try that out very soon
