Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Q&A, Tips, Tricks and Howto

Reply
 
Thread Tools Display Modes
Old 11-19-2018, 10:17 PM   #1
Philip Lee
Human being with feelings
 
Philip Lee's Avatar
 
Join Date: Jan 2009
Location: West Sacramento, CA
Posts: 39
Default Action to insert specific note in midi editor?

I'd like to add a button to the MIDI editor to insert a specific note at the edit cursor, and I haven't been able to figure it out. Something along the lines of "insert note 91"

I've looked though reaPack without luck.

Thanks for any tips!
Philip Lee is offline   Reply With Quote
Old 11-20-2018, 07:34 PM   #2
xpander
Human being with feelings
 
xpander's Avatar
 
Join Date: Jun 2007
Location: Terra incognita
Posts: 7,670
Default

If scripts are ok, the following lua script test from spk77 would do that. But you'd have to edit it so that there's just one note line with the note number you want in the note table (local note_tbl):

https://forum.cockos.com/showpost.ph...51&postcount=2

Scripting wizards could maybe even make a specific version of that for your needs if you ask in the script forum:
https://forum.cockos.com/forumdisplay.php?f=3

There are several way more advanced note insert scripts available, but if all you need is just a simple single note insert, they are probably too heavy for your use.
xpander is offline   Reply With Quote
Old 11-20-2018, 09:29 PM   #3
Philip Lee
Human being with feelings
 
Philip Lee's Avatar
 
Join Date: Jan 2009
Location: West Sacramento, CA
Posts: 39
Default

Thank you! I feel like I am pointed in a direction! I think I'm up to the challenge of learning a little lua.

Man, I love reaper.
Philip Lee is offline   Reply With Quote
Old 11-21-2018, 10:00 AM   #4
Tod
Human being with feelings
 
Tod's Avatar
 
Join Date: Jan 2010
Location: Kalispell
Posts: 14,759
Default

Here's a script from FnA that I use all the time. Closer to the bottom, you can use it to set both the note # (pitch) as well as the velocity (vel).

I use this script a lot, and I use "Notepad+++" for editing scripts, it works great, especially if you have several of them to edit.

Code:
// EEL: Insert specified note at play or edit cursor

pp = GetPlayPosition();
Undo_BeginBlock2(0);
take = MIDIEditor_GetTake(MIDIEditor_GetActive());

GetToggleCommandState(1007) ? (
  start = MIDI_GetPPQPosFromProjTime(take, pp) + 0;//if playing: change + 0 for offset in ticks from play cursor
):(
  start = MIDI_GetPPQPosFromProjTime(take, GetCursorPosition()) - 0;// if stopped: - 0 is offset from edit cursor
);
sel = 1;// 0=no,1=yes
muted = 0;// 0=no,1=yes
end = start +350;// start + number of ticks 
chan = 1;// 1-16
pitch = 36;// 0-127
vel =20;// 0-127
MIDI_InsertNote(take, sel, muted, start, end, chan, pitch, vel, 0);

Undo_EndBlock2(0, "Insert keyswitch note", -1);
Tod is offline   Reply With Quote
Old 11-21-2018, 11:00 AM   #5
xpander
Human being with feelings
 
xpander's Avatar
 
Join Date: Jun 2007
Location: Terra incognita
Posts: 7,670
Default

Just like that, works great. Thanks Tod and FnA!
xpander is offline   Reply With Quote
Old 11-21-2018, 11:44 AM   #6
Philip Lee
Human being with feelings
 
Philip Lee's Avatar
 
Join Date: Jan 2009
Location: West Sacramento, CA
Posts: 39
Default

Fantastic, this works perfectly.

My goal was to have buttons for a few of the kit pieces in Addictive Drums. The way they are mapped most of the cymbals are way, way up the keyboard, leading to (MUCH) unnecessary scrolling around while programming beats.

I'm super stoked, Thank you Tod (and of course FnA [and certainly xpander as well])
Philip Lee is offline   Reply With Quote
Old 11-21-2018, 08:13 PM   #7
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 2,173
Default

You're welcome, guys. Hey... Is Undo working for you after you use the script, on the notes it inserted? It's not here. I remember there was a problem with MIDI scripts and UndoEndBlock1 and 2. So I changed the script to use a function that was found more reliable with MIDI scripts, and it seems to work right.

Code:
// Insert specified note at play or edit cursor

pp = GetPlayPosition();
take = MIDIEditor_GetTake(MIDIEditor_GetActive());

GetToggleCommandState(1007) ? (
  start = MIDI_GetPPQPosFromProjTime(take, pp) + 0;//if playing: change + 0 for offset in ticks from play cursor
):(
  start = MIDI_GetPPQPosFromProjTime(take, GetCursorPosition()) - 0;// if stopped: - 0 is offset from edit cursor
);
sel = 1;// 0=no,1=yes
muted = 0;// 0=no,1=yes
end = start +350;// start + number of ticks 
chan = 1;// 0-15
pitch = 36;// 0-127
vel =20;// 0-127
MIDI_InsertNote(take, sel, muted, start, end, chan, pitch, vel, 0);

Undo_OnStateChange("Insert keyswitch note");
Edit. Hm. Looks like channel is zero based and should be 0-15 rather than 1-16. Changed //comment in code.

Last edited by FnA; 11-21-2018 at 08:21 PM.
FnA is offline   Reply With Quote
Old 11-21-2018, 10:50 PM   #8
Tod
Human being with feelings
 
Tod's Avatar
 
Join Date: Jan 2010
Location: Kalispell
Posts: 14,759
Default

Quote:
Originally Posted by FnA View Post
You're welcome, guys. Hey... Is Undo working for you after you use the script, on the notes it inserted? It's not here. I remember there was a problem with MIDI scripts and UndoEndBlock1 and 2. So I changed the script to use a function that was found more reliable with MIDI scripts, and it seems to work right.
Hi FnA, ha ha, I've got this script set up in so many ways, there's no way I'm going back to change it. Actually I haven't had any problems with it any way.

Thank you so much FnA, I don't see this in the ReaPack, it should be there, it's a great script.
Tod is offline   Reply With Quote
Old 11-22-2018, 03:39 AM   #9
xpander
Human being with feelings
 
xpander's Avatar
 
Join Date: Jun 2007
Location: Terra incognita
Posts: 7,670
Default

Quote:
Originally Posted by FnA View Post
Hey... Is Undo working for you after you use the script, on the notes it inserted? It's not here. I remember there was a problem with MIDI scripts and UndoEndBlock1 and 2. So I changed the script to use a function that was found more reliable with MIDI scripts, and it seems to work right.
You're right, undo was not working correctly. After the change to Undo_OnStateChange it is working now, thanks for the correction FnA.
xpander is offline   Reply With Quote
Old 11-22-2018, 04:05 AM   #10
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 19,681
Default

Quote:
Originally Posted by Philip Lee View Post
Fantastic, this works perfectly.

My goal was to have buttons for a few of the kit pieces in Addictive Drums. The way they are mapped most of the cymbals are way, way up the keyboard, leading to (MUCH) unnecessary scrolling around while programming beats.

I'm super stoked, Thank you Tod (and of course FnA [and certainly xpander as well])
A related discussion thread: http://forum.cockos.com/showthread.php?t=69095





__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:23 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.