|
|
|
11-19-2018, 10:17 PM
|
#1
|
Human being with feelings
Join Date: Jan 2009
Location: West Sacramento, CA
Posts: 39
|
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!
|
|
|
11-20-2018, 07:34 PM
|
#2
|
Human being with feelings
Join Date: Jun 2007
Location: Terra incognita
Posts: 7,670
|
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.
|
|
|
11-20-2018, 09:29 PM
|
#3
|
Human being with feelings
Join Date: Jan 2009
Location: West Sacramento, CA
Posts: 39
|
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.
|
|
|
11-21-2018, 10:00 AM
|
#4
|
Human being with feelings
Join Date: Jan 2010
Location: Kalispell
Posts: 14,759
|
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);
|
|
|
11-21-2018, 11:00 AM
|
#5
|
Human being with feelings
Join Date: Jun 2007
Location: Terra incognita
Posts: 7,670
|
Just like that, works great. Thanks Tod and FnA!
|
|
|
11-21-2018, 11:44 AM
|
#6
|
Human being with feelings
Join Date: Jan 2009
Location: West Sacramento, CA
Posts: 39
|
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])
|
|
|
11-21-2018, 08:13 PM
|
#7
|
Human being with feelings
Join Date: Jun 2012
Posts: 2,173
|
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.
|
|
|
11-21-2018, 10:50 PM
|
#8
|
Human being with feelings
Join Date: Jan 2010
Location: Kalispell
Posts: 14,759
|
Quote:
Originally Posted by FnA
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.
|
|
|
11-22-2018, 03:39 AM
|
#9
|
Human being with feelings
Join Date: Jun 2007
Location: Terra incognita
Posts: 7,670
|
Quote:
Originally Posted by FnA
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.
|
|
|
11-22-2018, 04:05 AM
|
#10
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,681
|
Quote:
Originally Posted by Philip Lee
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 ...
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 07:23 PM.
|