# New Tool (2.8): Mpe

**URL:** <https://forum.renoise.com/t/new-tool-2-8-mpe/32580>\
**Category:** Renoise Tools\
**Created:** [May 20, 2011, 1:37pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580 "2011-05-20T13:37:44Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![esaruoho](https://forum.renoise.com/user_avatar/forum.renoise.com/esaruoho/32/795_2.png) [@esaruoho](https://forum.renoise.com/u/esaruoho)\
**Post date:** [May 29, 2011, 2:54pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/41 "2011-05-29T14:54:00Z")

</div>

> [@sevenscientist](#):
>
> I have also made the sample mode button begin sampling a new sample every time you press it after the forst press to bring up the sample record window, press trim/prog/mixer/song for it to go away.  
> PS I cant change or control the color of the text next to the display parts so yes its your palette thats causing the text to be almost invisible… look at the first post for version 2.3 please download and try and let me know if this is better ps you can see the text in the screenshot on the first post, (PS I have tried it with all other themes and It has been consistent in displaying.  
> thanks again for the feedback!  
> I will update it in the tools page as soon as I hear back from you!

Hey, that’s real neat thinking! (1st click on Sample opening sample recorder, second click and third click starting and stopping sampling). I’ll have to find out what exactly I did wrong with the palette ![;)](https://forum.renoise.com/uploads/default/original/2X/c/cc6810a6a8ecbfcb592ca3fd490fb59d90ec9739.gif)  
Thanks for being so swift with your song-trim-prog-mixer fixes!!  
I think you should probably just update it on the tools page… I can work out the palette thing on me own ![:)](https://forum.renoise.com/uploads/default/original/2X/f/f31646767a12ff3f4d6b8c4766d2ea41b23d4ab9.gif)

---

<div class="post-metadata">

**Author:** ![esaruoho](https://forum.renoise.com/user_avatar/forum.renoise.com/esaruoho/32/795_2.png) [@esaruoho](https://forum.renoise.com/u/esaruoho)\
**Post date:** [June 1, 2011, 1:21am UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/42 "2011-06-01T01:21:49Z")

</div>

Nice to see the 2.4 update on this with rotary controllers! Btw, can you make them read the current sample’s pitch, because it doesn’t seem to get refreshed to transpose pitch 0 if you switch from a -40 sample to 0 sample.

---

<div class="post-metadata">

**Author:** ![triple\_d](https://forum.renoise.com/letter_avatar/triple_d/32/6_449c533f586939b6e5f246632a46421f.png) [@triple\_d](https://forum.renoise.com/u/triple_d)\
**Post date:** [June 2, 2011, 1:50pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/43 "2011-06-02T13:50:43Z")

</div>

So far this tool looks very promising. I am having a lot of fun with it!

But it would be even better if all the buttons on the tool are controllable by a midi-controller. Some form of midi-bind would be awesome.

Keep up the good work!

---

<div class="post-metadata">

**Author:** ![hotelsinus](https://forum.renoise.com/user_avatar/forum.renoise.com/hotelsinus/32/32426_2.png) [@hotelsinus](https://forum.renoise.com/u/hotelsinus)\
**Post date:** [June 2, 2011, 2:06pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/44 "2011-06-02T14:06:40Z")

</div>

this is really kool

Somebody can make one for the Emu Command Station… if it possible ![:D](https://files.renoise.com/forum/emoticons/default/biggrin.gif)

nice gui !!!+

---

<div class="post-metadata">

**Author:** ![esaruoho](https://forum.renoise.com/user_avatar/forum.renoise.com/esaruoho/32/795_2.png) [@esaruoho](https://forum.renoise.com/u/esaruoho)\
**Post date:** [June 2, 2011, 2:09pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/45 "2011-06-02T14:09:37Z")

</div>

> [@hotelsinus](#):
>
> this is really kool
> 
> Somebody can make one for the Emu Command Station… if it possible ![:D](https://forum.renoise.com/uploads/default/original/2X/4/4e279733a789da83bda5b44aedcf6a0d5178edcb.gif)
> 
> nice gui !!!+

D’you have a screenshot of the Emu Command Station?

---

<div class="post-metadata">

**Author:** ![esaruoho](https://forum.renoise.com/user_avatar/forum.renoise.com/esaruoho/32/795_2.png) [@esaruoho](https://forum.renoise.com/u/esaruoho)\
**Post date:** [June 8, 2011, 1:18pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/46 "2011-06-08T13:18:38Z")

</div>

Hi, looking at your code, now you first have some Script screenset alterations, and then call global#8 viewpreset…

```lua
 vb:button {  
 tooltip = "Disable (Follow Player Position) and (Enable Record Mode).",  
 text = "Step",  
 width = BTN_FUNCTION_WIDTH,  
 color = {0xf5, 0xf5, 0xf5},  
 pressed = function()  
 renoise.app().window.active_middle_frame = 1  
 renoise.app().window.active_lower_frame = 2  
 renoise.app().window.lower_frame_is_visible = true  
 renoise.app().window.upper_frame_is_visible = false  
 renoise.app().window.pattern_matrix_is_visible = false  
  
 renoise.app().window:select_preset(8)  
 renoise.song().transport.follow_player = false  
 renoise.song().transport.edit_mode = true  
 renoise.song().transport.edit_step = 0  
 end  
 },  

```

So you do both? But however, it’s better to not do the select\_preset no more in this tool if you are already calling the specific “preset” inside the script… Right?

---

<div class="post-metadata">

**Author:** ![tavernamax](https://forum.renoise.com/user_avatar/forum.renoise.com/tavernamax/32/1530_2.png) [@tavernamax](https://forum.renoise.com/u/tavernamax)\
**Post date:** [June 10, 2011, 4:46am UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/47 "2011-06-10T04:46:34Z")

</div>

> [@esaruoho](#):
>
> Hi, looking at your code, now you first have some Script screenset alterations, and then call global#8 viewpreset..
> 
> ```lua
> vb:button {  
> tooltip = "Disable (Follow Player Position) and (Enable Record Mode).",  
> text = "Step",  
> width = BTN_FUNCTION_WIDTH,  
> color = {0xf5, 0xf5, 0xf5},  
> pressed = function()  
> renoise.app().window.active_middle_frame = 1  
> renoise.app().window.active_lower_frame = 2  
> renoise.app().window.lower_frame_is_visible = true  
> renoise.app().window.upper_frame_is_visible = false  
> renoise.app().window.pattern_matrix_is_visible = false  
>   
> renoise.app().window:select_preset(8)  
> renoise.song().transport.follow_player = false  
> renoise.song().transport.edit_mode = true  
> renoise.song().transport.edit_step = 0  
> end  
> },  
> 
> ```
> 
> So you do both? But however, it’s better to not do the select\_preset no more in this tool if you are already calling the specific “preset” inside the script.. Right?

you are correct I missed that, fixed for the next version

> [@esaruoho](#):
>
> So far this tool looks very promising. I am having a lot of fun with it!
> 
> But it would be even better if all the buttons on the tool are controllable by a midi-controller. Some form of midi-bind would be awesome.
> 
> Keep up the good work!

coming soon..

> [@esaruoho](#):
>
> Nice to see the 2.4 update on this with rotary controllers! Btw, can you make them read the current sample’s pitch, because it doesn’t seem to get refreshed to transpose pitch 0 if you switch from a -40 sample to 0 sample.

I am trying to make it work but Im getting strange errors , so far I have only managed to make the instrument transpose rotary \> update the sample transpose by its value.

every time i make it read the current samples pitch i get loop notifier errors?

and according to the exampletoolgui..

## – there is another way of dealing with “values”, which we will describe in the – next example more in detail. Basically you can also pass over an Observable – object to the view (not the raw number, boolen), which then will be used by – the view instead of its onw value. Any changes to this value can then tracked – outside of this view. This often is very useful to seperate the GUI code from – the controller and data. Here is a simple example:

– – (the controller part of your script)  
– options.current\_velocity = 0x7f  
– options.current\_velocity.add\_notifier(current\_value\_changed\_function)

– – (and the GUI)  
– vb:slider {  
– bind = options.current\_velocity, – only gets a reference passed  
– min = 0,  
– max = 0x7f

– Valid in the construction table only: Bind the view’s value to a  
– renoise.Document.ObservableNumber object. Will change the Observable  
– value as soon as the view’s value changes, and change the view’s value as  
– soon as the Observable’s value changes - automatically keeps both values  
– in sync.  
– Notifiers can be added to either the view or the Observable object.  
rotary.bind  
 → [ObservableNumber Object]

but I cant get the bind function to work for me? anyone have any ideas?

---

<div class="post-metadata">

**Author:** ![dac514](https://forum.renoise.com/user_avatar/forum.renoise.com/dac514/32/100_2.png) [@dac514](https://forum.renoise.com/u/dac514)\
**Post date:** [June 12, 2011, 2:49pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/48 "2011-06-12T14:49:19Z")

</div>

> [@sevenscientist](#):
>
> but I cant get the bind function to work for me? anyone have any ideas?

As far as I can tell to do this you’d have to create a Document variable for every sample and keep track of them individually.

Let’s look at it another way:

- renoise.song().selected\_instrument\_index\_observable
- renoise.song().selected\_sample\_index\_observable
- renoise.song().instruments.samples.transpose\_observable

You can combine the first two functions in a way that, if something changes, update the rotary. The third is a bit more complicated since you have to add an observable for every possible combination of instrument and sample, which is the same problem faced with using Document variables. Also, after looking at the code I feel you are kind of shooting yourself in the foot. You do alot of :add\_notifier, but never remove them. I’m not sure Renoise even cleans these…

If you are feeling brave, I would rewrite a lot of your code using `app_idle_observable` .

Example:

```auto
  
  
function run()  
 if not (renoise.tool().app_idle_observable:has_notifier(update_gui)) then  
 renoise.tool().app_idle_observable:add_notifier(update_gui)  
 end  
end  
  
  
function stop()  
 if (renoise.tool().app_idle_observable:has_notifier(update_gui)) then  
 renoise.tool().app_idle_observable:remove_notifier(update_gui)  
 end  
end  
  
  
function update_gui()  
 -- Dialogue is gone?  
 if (not my_dialog or not my_dialog.visible) then  
 stop()  
 return  
 end  
 -- Update the Rotary  
 -- Update the BPM  
 -- Update the Track  
 -- Etc. Every single thing that needs to be updated goes in this function  
end  
  
-- Add run() to main(), after if (my_dialog and my_dialog.visible) [...] end  
  

```

With this idea, you get rid of all your other notifiers all over the place and, instead, update the GUI when the app has a few cycles to spare. This also destroys the notifier when the MPE goes away; making it cleaner and safer.

That said, there’s a lot of stuff that will need to be moved around for this to work. Right now main() encapsulates everything as a local, so some stuff you will need can’t be accessed globally, doing some preliminary testing and optiomizing with os.clock() to make sure this works, yada yada yada. Look at Cie’s Step Sequence and Nibbles for inspiration.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![hotelsinus](https://forum.renoise.com/user_avatar/forum.renoise.com/hotelsinus/32/32426_2.png) [@hotelsinus](https://forum.renoise.com/u/hotelsinus)\
**Post date:** [June 12, 2011, 3:01pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/49 "2011-06-12T15:01:23Z")

</div>

> [@esaruoho](#):
>
> D’you have a screenshot of the Emu Command Station?

yes i put it here

[[Album] E-MU XL7 Command Station ![](https://forum.renoise.com/uploads/default/original/3X/c/d/cd4219537ee7b54ca3e527c1e5926be51f6051a5.jpeg "E-MU XL7 Command Station") ](https://www.flickr.com/photos/hotelsinus/sets/72157624664547052/)

---

<div class="post-metadata">

**Author:** ![tavernamax](https://forum.renoise.com/user_avatar/forum.renoise.com/tavernamax/32/1530_2.png) [@tavernamax](https://forum.renoise.com/u/tavernamax)\
**Post date:** [June 13, 2011, 1:13pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/50 "2011-06-13T13:13:23Z")

</div>

released updated version 2.5 (re-written) check tools page. Sorry I don’t own an Emu command station …looks cool (so I wont be coding a tool for it but feel free to do so yourself)

---

<div class="post-metadata">

**Author:** ![dac514](https://forum.renoise.com/user_avatar/forum.renoise.com/dac514/32/100_2.png) [@dac514](https://forum.renoise.com/u/dac514)\
**Post date:** [June 13, 2011, 1:32pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/51 "2011-06-13T13:32:42Z")

</div>

Very awesome.

One thing I noticed, I can open multiple instance of the MPE gui.

I fixed it locally by changing

```auto
  
function main()--1 dialog at a time  
 local my_dialog = nil  
 -- [...]  
  

```

to

```auto
  
local my_dialog = nil  
function main()--1 dialog at a time  
 -- [...]  
  

```

Cheers.

---

<div class="post-metadata">

**Author:** ![tavernamax](https://forum.renoise.com/user_avatar/forum.renoise.com/tavernamax/32/1530_2.png) [@tavernamax](https://forum.renoise.com/u/tavernamax)\
**Post date:** [June 14, 2011, 10:40am UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/52 "2011-06-14T10:40:51Z")

</div>

thanks again Conner\_Bw! fixed for the next version 2.6 coming soon… also adding midi mapping now.

---

<div class="post-metadata">

**Author:** ![esaruoho](https://forum.renoise.com/user_avatar/forum.renoise.com/esaruoho/32/795_2.png) [@esaruoho](https://forum.renoise.com/u/esaruoho)\
**Post date:** [June 14, 2011, 4:16pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/53 "2011-06-14T16:16:40Z")

</div>

> [@crytek](#):
>
> Can we somehow disable the feature that the ESC command has when this tool is loaded? I hit escape to exit certain things in Renoise, but I don’t want to get rid of the MPE session I have up either.

Yeah, sevenscientist could change “esc” to “\_” (btw, if anyone knows what \_ is in realspeak, please let me know ![:)](https://forum.renoise.com/uploads/default/original/2X/f/f31646767a12ff3f4d6b8c4766d2ea41b23d4ab9.gif)

---

<div class="post-metadata">

**Author:** ![kazakore](https://forum.renoise.com/user_avatar/forum.renoise.com/kazakore/32/258_2.png) [@kazakore](https://forum.renoise.com/u/kazakore)\
**Post date:** [June 14, 2011, 4:41pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/54 "2011-06-14T16:41:46Z")

</div>

> [@esaruoho](#):
>
> (btw, if anyone knows what \_ is in realspeak, please let me know ![:)](https://forum.renoise.com/uploads/default/original/2X/f/f31646767a12ff3f4d6b8c4766d2ea41b23d4ab9.gif)

Underscore?

---

<div class="post-metadata">

**Author:** ![mxb](https://forum.renoise.com/letter_avatar/mxb/32/6_449c533f586939b6e5f246632a46421f.png) [@mxb](https://forum.renoise.com/u/mxb)\
**Post date:** [June 14, 2011, 4:57pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/55 "2011-06-14T16:57:30Z")

</div>

> [@esaruoho](#):
>
> Yeah, sevenscientist could change “esc” to “\_” (btw, if anyone knows what \_ is in realspeak, please let me know ![:)](https://forum.renoise.com/uploads/default/original/2X/f/f31646767a12ff3f4d6b8c4766d2ea41b23d4ab9.gif)

I’m not sure this can be done from scripts.

Pressing escape seems to close all dialog boxes and I don’t think it is possible to override this.

One work around could be to identify when the dialog is closed and then automagically re-open it again (with this behaviour to be enabled/disabled by the user).

---

<div class="post-metadata">

**Author:** ![dac514](https://forum.renoise.com/user_avatar/forum.renoise.com/dac514/32/100_2.png) [@dac514](https://forum.renoise.com/u/dac514)\
**Post date:** [June 14, 2011, 6:19pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/56 "2011-06-14T18:19:04Z")

</div>

> [@mxb](#):
>
> I’m not sure this can be done from scripts.

It’s possible.

```auto
  
function key_handler(dialog, key)  
 if (key.name == "esc") then return end  
end  
  
my_dialog = renoise.app():show_custom_dialog("Title", foo, key_handler)  
  

```

---

<div class="post-metadata">

**Author:** ![esaruoho](https://forum.renoise.com/user_avatar/forum.renoise.com/esaruoho/32/795_2.png) [@esaruoho](https://forum.renoise.com/u/esaruoho)\
**Post date:** [June 14, 2011, 8:43pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/57 "2011-06-14T20:43:38Z")

</div>

> [@mxb](#):
>
> I’m not sure this can be done from scripts.
> 
> Pressing escape seems to close all dialog boxes and I don’t think it is possible to override this.
> 
> One work around could be to identify when the dialog is closed and then automagically re-open it again (with this behaviour to be enabled/disabled by the user).

It most certainly is possible to override (btw it’s really cool that the API allows for stuff like this!!!). I got a script to stay “on top” even if I’d press ESC on it. This is what I did, ripped off MPE code and altered it to this:

```lua
 local function my_keyhandler_func(dialog, key)  
 if not (key.modifiers == "" and key.name == "exclamation") then  
 return key  
 else  
 dialog:close()  
 end  

```

Nevermind the exclamation ![:D](https://forum.renoise.com/uploads/default/original/2X/4/4e279733a789da83bda5b44aedcf6a0d5178edcb.gif)

> [@mxb](#):
>
> Underscore?

Unfortunately not exactly. At least Underscore/underscore didn’t make it so that \_ would kill a GUI

---

<div class="post-metadata">

**Author:** ![esaruoho](https://forum.renoise.com/user_avatar/forum.renoise.com/esaruoho/32/795_2.png) [@esaruoho](https://forum.renoise.com/u/esaruoho)\
**Post date:** [June 14, 2011, 11:29pm UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/58 "2011-06-14T23:29:34Z")

</div>

> [@dac514](#):
>
> One thing I noticed, I can open multiple instance of the MPE gui.
> 
> ```auto
>   
> local my_dialog = nil  
> function main()--1 dialog at a time  
> -- [...]  
>   
> 
> ```

Thanks for this, Conner\_Bw! Works like a charm ![:)](https://forum.renoise.com/uploads/default/original/2X/f/f31646767a12ff3f4d6b8c4766d2ea41b23d4ab9.gif)

---

<div class="post-metadata">

**Author:** ![esaruoho](https://forum.renoise.com/user_avatar/forum.renoise.com/esaruoho/32/795_2.png) [@esaruoho](https://forum.renoise.com/u/esaruoho)\
**Post date:** [June 15, 2011, 1:05am UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/59 "2011-06-15T01:05:02Z")

</div>

Can ya try "local function instead of function…  
I wrapped mine inside the viewbuilder

---

<div class="post-metadata">

**Author:** ![dac514](https://forum.renoise.com/user_avatar/forum.renoise.com/dac514/32/100_2.png) [@dac514](https://forum.renoise.com/u/dac514)\
**Post date:** [June 15, 2011, 1:25am UTC](https://forum.renoise.com/t/new-tool-2-8-mpe/32580/60 "2011-06-15T01:25:39Z")

</div>

> [@crytek](#):
>
> I plugged that in and this is what I got.

Sorry, that wasn’t usable code. It was a generic pseudo example.

In the MPE code, look for `my_keyhandler_func` and play with that. Personally I think escape _should_ close the dialogue so I don’t recommend it. The decision will be up to sevenscientist. My comment was for mxb; just to show that it was possible.

[Previous page](https://forum.renoise.com/t/new-tool-2-8-mpe/32580.md?page=2)

[Next page](https://forum.renoise.com/t/new-tool-2-8-mpe/32580.md?page=4)
