Old 04-20-2021, 06:48 PM   #1
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Location: China
Posts: 654
Default Is there an API for setting the note display mode?

Is there an API for setting the note display mode? Rectangle, triangle, diamond
dangguidan is online now   Reply With Quote
Old 04-21-2021, 02:37 AM   #2
Yanick
Human being with feelings
 
Yanick's Avatar
 
Join Date: May 2018
Location: Moscow, Russia
Posts: 612
Default

probably like this

Code:
midieditor = reaper.MIDIEditor_GetActive()

reaper.MIDIEditor_OnCommand(midieditor, 40450) -- View: Show events as diamonds (drum mode)
reaper.MIDIEditor_OnCommand(midieditor, 40449) -- View: Show events as rectangles (normal mode)
reaper.MIDIEditor_OnCommand(midieditor, 40448) -- View: Show events as triangles (drum mode)
Yanick is offline   Reply With Quote
Old 04-21-2021, 06:25 AM   #3
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Location: China
Posts: 654
Default

Thank you for your reply. Sorry I didn't make it clear. I want to define the note shape of multiple items at one time.
dangguidan is online now   Reply With Quote
Old 04-21-2021, 03:59 PM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

It would be possible with state-chunk-manipulation, even for items, that aren't currently opened in the MIDI-Editor.

CFGEDIT seem to be the entry of the item-statechunk, that you would need to manipulate.
But it's undocumented to my knowledge.
As far as I can see, it's the sixth entry in the line, which is either:

1 - rectangles
9 - triangles
17 - diamonds

Though it looks more like

&8=0 and &16=0 - rectangles
&8=8 and &16=0 - triangles
&8=0 and &16=16 - diamonds.

So if you want to go into item-statechunk-manipulation and string-replacement, it is actually possible. Otherwise, you can only set the ones currently opened in the Midi-Editor, as far as I can see using the method shown by Yanick.

If you use JS-extension, you can get the HWND-identifier of all opened Midi-editors as well, so you could set the shape for all of them.
You can get the adresses for them using JS_MIDIEditor_ListAll and need split and convert them later on.
https://mespotin.uber.space/Ultrasch...Editor_ListAll

But: you can not find out, which item is actually opened in a specific Midi-Editor, so if you want to manipulate only some of them, you'll probably have difficulties to differentiate between those you want to alter and those you don't want to.

tl;dr; if you want to set the shapes for items in a simple and easy way, you're out of luck, it seems.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 04-21-2021, 11:03 PM   #5
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Location: China
Posts: 654
Default

Thank you for your reply!
I used it reaper.GetItemStateChunk This API gets the following characters,But I can't see which line represents the shape of the note?


"<ITEM
POSITION 7.94461000688639
SNAPOFFS 0
LENGTH 174.8790022675737
LOOP 0
ALLTAKES 0
FADEIN 1 0.01 0 1 0 0 0
FADEOUT 1 0.01 0 1 0 0 0
MUTE 0 0
SEL 0
IGUID {0A4E7646-A57B-44DE-B7E3-A65D0824CE2F}
IID 267
NAME 308543-20210405-04.mp3
VOLPAN 1 0 1 -1
SOFFS 0
dangguidan is online now   Reply With Quote
Old 04-22-2021, 03:00 AM   #6
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Your statechunk is incomplete. It must end with a > or otherwise is missing parts.
How did you retrieve it so you could post it here? Easiest is to output it in the ReaScript-console using reaper.ShowConsoleMsg()

The entry in question is CFGEDIT but it's only available for Midi-items, not any other.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 04-22-2021, 09:35 PM   #7
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Location: China
Posts: 654
Default

Thank you for your reply. I've found it,It looks like it's going to be successful ~! What's more, I'm surprised to find that there are many parameters that can't be GetSet before.
dangguidan is online now   Reply With Quote
Old 04-23-2021, 03:00 AM   #8
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Location: China
Posts: 654
Default

I still didn't succeed. Although I changed the data, the note mode didn't change.

Code:
item=reaper.GetMediaItem(0,0)
retval, str = reaper.GetItemStateChunk(item, '', false)
str1,str2,str3,str4,str5,str6,str7=string.match(str, '(CFGEDIT) (%d+) (%d+) (%d+) (%d+) (%d+) (%d+)')
str7=0 str_new=str1..' '..str2..' '..str3..' '..str4..' '..str5..' '..str6..' '..str7
str_out=string.gsub(str,'CFGEDIT %d+ %d+ %d+ %d+ %d+ %d+',str_new,1)
bool=reaper.SetItemStateChunk(item,str_out,false)
reaper.ShowConsoleMsg(str_out)
dangguidan is online now   Reply With Quote
Old 04-23-2021, 03:00 AM   #9
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

There are tons in statechunks that can only be set via statechunks.
One of the reasons why I try to write such get/set functions for statechunks in my Ultraschall-Api.
Just hadn't time yet to do some for CFGEDIT, otherwise I would have suggested installing Ultraschall-Api.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 04-23-2021, 03:01 AM   #10
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by dangguidan View Post
I still didn't succeed. Although I changed the data, the note mode didn't change.

Code:
item=reaper.GetMediaItem(0,0)
retval, str = reaper.GetItemStateChunk(item, '', false)
str1,str2,str3,str4,str5,str6,str7=string.match(str, '(CFGEDIT) (%d+) (%d+) (%d+) (%d+) (%d+) (%d+)')
str7=0 str_new=str1..' '..str2..' '..str3..' '..str4..' '..str5..' '..str6..' '..str7
str_out=string.gsub(str,'CFGEDIT %d+ %d+ %d+ %d+ %d+ %d+',str_new,1)
bool=reaper.SetItemStateChunk(item,str_out,false)
reaper.ShowConsoleMsg(str_out)
You might need to close and reopen the Midi-editor for this.

The statechunk approach probably only helps for items not opened in the Midieditor. For opened items, you might need to use Yannik's approach.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine 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 02:26 AM.


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