Go Back   Cockos Incorporated Forums > REAPER Forums > Dstruct's Casa De Nitpicks

Reply
 
Thread Tools Display Modes
Old 09-11-2020, 05:23 AM   #1
Yanick
Human being with feelings
 
Yanick's Avatar
 
Join Date: May 2018
Location: Moscow, Russia
Posts: 612
Default The function reaper.CreateNewMIDIItemInProj does not create .MID files

If I activate the "Create new MIDI items as .MID files" setting, then the function CreateNewMIDIItemInProj does not create .MID files in project directory.
Yanick is offline   Reply With Quote
Old 09-20-2020, 04:17 PM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

I can confirm that, no MIDI-file is created, unlike the action "Insert new MIDI item...".

In addition to that, when I duplicate the MIDI-items, no additional MIDI-files are created. I would expect that being the case.
__________________
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 09-20-2020, 04:49 PM   #3
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Seems reasonable to me as the function's purpose is to create new in project MIDI items (edit: that's what I gather from its name at least, otherwise the function could just have been named "CreateNewMIDIItem") which is disabled via Preferences, so the function does nothing.

edit2:
I think the confusion may come from OP is taking InProj for 'in project directory' but I think it actually refers to 'in project MIDI' (as opposed to .MID files).

edit3:
I can only guess though as the API doc doesn't clarify this.

Last edited by nofish; 09-20-2020 at 05:17 PM.
nofish is offline   Reply With Quote
Old 09-21-2020, 12:02 AM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Not necessarily. The OP set the option, that new Midi items shall be created as modi-files in the prefs.
It's only natural to assume, that this function obeys this setting and creates a new midi item as .mid-file.
It works with the action I mentioned but not in other cases.

I think an optional parameter would help:
integer Create_Mid - 0 or nil, don't create it as midifile, 1, create as midifile, 2, obey preference's setting
__________________
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 09-21-2020, 06:36 AM   #5
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
It works with the action I mentioned but not in other cases.
But the action doesn't contain the InProj suffix (or a similar wording), unlike the API function, that's the difference imo.
I.e. the action doesn't specify if a new MIDI item should be created as in project MIDI or .MID file, but the API function does (to my understanding), hence it's no-op if the Preference is set to only create MIDI items as .MID files.
nofish is offline   Reply With Quote
Old 09-21-2020, 11:05 AM   #6
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

The action obeys the preferences setting which is totally fine.

I think the problem is that, despite the prefs-setting set, certain parts of Reaper do their own stuff. In regards of the function in the OP, there's no chance to insert with it a midi item, that obeys the prefs setting. So you can't insert midi items who are stored as mid-files, despite the setting and you have no alternative to do it via Api, unless you make a hack.

Speaking of which, I have an idea that could help Yanick, thanks to your responses.
__________________
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 09-21-2020, 11:54 AM   #7
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
In regards of the function in the OP, there's no chance to insert with it a midi item, that obeys the prefs setting. So you can't insert midi items who are stored as mid-files, despite the setting and you have no alternative to do it via Api, unless you make a hack.
I didn't deny that, in fact I fully agree.
But I still think the function behaves correctly in its current form (even if quite limited in functionality, as noted by you), so this would be better suited for feature requests than nitpicks imo.
nofish is offline   Reply With Quote
Old 09-21-2020, 01:49 PM   #8
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

I agree that this thread should be moved to FR.
__________________
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 09-23-2020, 07:17 AM   #9
Yanick
Human being with feelings
 
Yanick's Avatar
 
Join Date: May 2018
Location: Moscow, Russia
Posts: 612
Default

I'm not really using this, I just helped people tune the Reaper, and I accidentally discovered this moment. Because I have been creating the item for a long time using the following script on double click like in Studio one
PHP Code:
 reaper.Undo_BeginBlock()
 
reaper.PreventUIRefresh(1)
 
 
if 
reaper.GetToggleCommandState(1013) == 0 then
 local get_track
,_,reaper.BR_TrackAtMouseCursor()
  if 
get_track then
   local _
track_name reaper.GetTrackName(get_track0)
   if 
track_name ~= "MASTER" then
    local _
name reaper.GetSetMediaTrackInfo_String(get_track'P_NAME'0false)
    
local num_cursor reaper.BR_PositionAtMouseCursor(true)
    if 
num_cursor then 
      local QN_cursor 
reaper.TimeMap_timeToQN(num_cursor)
      
local _measure_startmeasure_end reaper.TimeMap_QNToMeasures(0QN_cursor)
      
local QN_start reaper.TimeMap_QNToTime(measure_start)
      
local QN_end reaper.TimeMap_QNToTime(measure_end)
      
local item_at_cursor reaper.CreateNewMIDIItemInProjget_trackQN_startQN_endfalse)
      
reaper.SetMediaItemInfo_Value(item_at_cursor'B_LOOPSRC'0)
      
local take reaper.GetActiveTake(item_at_cursor)
      
reaper.GetSetMediaItemTakeInfo_String(take'P_NAME'nametrue)
      
reaper.SetMediaItemSelected(item_at_cursor1)
    
end
   end
  end
end

 reaper
.Undo_EndBlock('Insert item', -1)
 
reaper.PreventUIRefresh(-1

Last edited by Yanick; 09-23-2020 at 07:22 AM.
Yanick 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 11:19 AM.


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