Go Back   Cockos Incorporated Forums > Projects > Deprecated REAPER issue tracker > Open Bug

Reascript RPR_MIDI_InsertNote produces unexpected results Issue Tools
issueid=5365 09-30-2014 05:15 AM
Human being with feelings
Reascript RPR_MIDI_InsertNote produces unexpected results

Some calls to RPR_MIDI_InsertNote produce invalid events (it seems) with position 0 on channel 1 (no other data visible in event list view).

Attached is a test script which reproduces this bug (failing calls to RPR_MIDI_InsertNote are marked). This script can be run in an empty project, it will add one track, create MIDI item take and write notes to it.
I simplified it as much as possible, but couldn't find any good reason why this is not working.

#======================
END_TIME = 420.
PPQ1 = 99840. # 27.1.00
PPQ2 = 103680. # 28.1.00
PPQ3 = 798720. # 209.1.00
END_OF_TRACK = '\xFF\x2F\x00'

RPR_InsertTrackAtIndex(0, False)
track_id = RPR_GetTrack(0, 0)
item_id = RPR_CreateNewMIDIItemInProj(track_id, 0., END_TIME)
take_id = RPR_GetMediaItemTake(item_id, 0)

## the following lines only work if RPR_MIDI_InsertEvt is changed in reaper_python.py as following (note next to last arg):
## t=(rpr_packp('MediaItem_Take*',p0),c_byte(p1),c_by te(p2),c_double(p3),c_char_p(p4),c_int(p5))
## instead of current:
## t=(rpr_packp('MediaItem_Take*',p0),c_byte(p1),c_by te(p2),c_double(p3),rpr_packsc(p4),c_int(p5))
ppq_end = RPR_MIDI_GetPPQPosFromProjTime(take_id, END_TIME)
#RPR_MIDI_InsertEvt(take_id, False, False, ppq_end, END_OF_TRACK, len(END_OF_TRACK))

RPR_MIDI_InsertNote(take_id, False, False, 0.0, 0.0, 7, 40, 127)
RPR_MIDI_InsertNote(take_id, False, False, 0.0, PPQ1, 7, 38, 127)
RPR_MIDI_InsertNote(take_id, False, False, 0.0, PPQ1, 7, 40, 127) # this is missing
RPR_MIDI_InsertNote(take_id, False, False, 0.0, PPQ1, 8, 37, 127)
RPR_MIDI_InsertNote(take_id, False, False, 0.0, PPQ1, 8, 41, 127)
RPR_MIDI_InsertNote(take_id, False, False, PPQ1, PPQ2, 7, 74, 127)
RPR_MIDI_InsertNote(take_id, False, False, PPQ1, PPQ2, 8, 36, 127)
RPR_MIDI_InsertNote(take_id, False, False, PPQ1, PPQ3, 10, 38, 127) # this is missing unless line 17 is uncommented
RPR_MIDI_InsertNote(take_id, False, False, PPQ1, PPQ3, 10, 44, 127)
RPR_MIDI_InsertNote(take_id, False, False, PPQ2, PPQ3, 8, 37, 127)
RPR_MIDI_InsertNote(take_id, False, False, PPQ2, PPQ3, 7, 37, 127)
RPR_MIDI_InsertNote(take_id, False, False, PPQ2, PPQ3, 7, 38, 127) # this is missing
Issue Details
Issue Type Open Bug
Project Deprecated REAPER issue tracker
Category Plugins
Status Fix Coming Soon
Priority 5 - Medium
Affected Version 4.73
Fixed Version (none)
Users able to reproduce bug 4
Users unable to reproduce bug 0
Assigned Users (none)
Tags (none)

10-09-2014 06:39 AM
Human being with feelings
 
Additional information

Confirmed. There seems to be something wrong with MIDI_InsertNote
  • I'm trying to add a note at pitch 0.
  • It adds "00 00 00" events.
  • Running the script three times finally adds the note.
  • MIDI_InsertNote function returns "1".

EEL script for testing below:
  • Open new MIDI item in editor
  • Open "Raw MIDI data" window
  • Run the script


Code:
function insert_note() local(take, ret)
(
  (take = MIDIEditor_GetTake(MIDIEditor_GetActive())) ? (
    //bool MIDI_InsertNote(MediaItem_Take* take, bool selected, bool muted, startppqpos, endppqpos, int chan, int pitch, int vel)
    ret = MIDI_InsertNote(take, 1, 0, 0.0, 960.0, 0, 0, 96);
    ShowConsoleMsg(sprintf(#, "%d", ret));
    //UpdateArrange();
  );
);

insert_note();


(REAPER v4.731, Win XP32)
Reply
Reply

Issue Tools
Subscribe to this issue

All times are GMT -7. The time now is 03:57 PM.


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