Python script to get note information with REAPER

If you can get the timing of notes numerically with REAPER I was wondering if it would be possible to visualize it in sync with various sounds. Memo made

GetNoteList.py


RPR_ClearConsole()

outlist = ""

midieditor = RPR_MIDIEditor_GetActive()
take = RPR_MIDIEditor_GetTake( midieditor )

notecntOut = 0
ccevtcntOut = 0
textsyxevtcntOut = 0

( retval, take, notecntOut, ccevtcntOut, textsyxevtcntOut ) = RPR_MIDI_CountEvts(take, notecntOut, ccevtcntOut, textsyxevtcntOut )

for noteidx in range(notecntOut):
  selectedOut = True
  mutedOut = True
  startppqposOut = 0
  endppqposOut = 0
  chanOut = 0
  pitchOut = 0
  velOut = 0

  ( retval, take, noteidx, selectedOut, mutedOut, startppqposOut, endppqposOut, chanOut, pitchOut, velOut ) = RPR_MIDI_GetNote(take, noteidx, selectedOut, mutedOut, startppqposOut, endppqposOut, chanOut, pitchOut, velOut )
  
  outlist += str(pitchOut) + "," + str(startppqposOut) + "," + str(endppqposOut) + "\n"

#RPR_ShowMessageBox("End", "status", 0 )
RPR_ShowConsoleMsg(outlist)

When you do this

image.png

Like this, you can get the note number and note-on / note-off timing information in text.

TIPS --Select the target MIDI Editor (MIDI region) and execute it. --If you want to know the time from the beginning, execute the regions together. ――Doesn't it work if you change the tempo on the way?

Notes I tried variously below

quarter note count (QN)

QN is a 1/4 note count, one bar is 4 beats, and it seems to be a count that represents 1 beat. It's like one beat at 960.

Convert from QN to MS (milliseconds)

  start = RPR_TimeMap_QNToTime( startppqposOut)
  end = RPR_TimeMap_QNToTime( endppqposOut)

I wonder if this does not support tempo changes ...

Postscript If this is a millisecond, it seems that dividing by 1000 will be a second, but for some reason 960 is a good value? ** * Yokuwakaran **

Get in absolute time from the beginning of the project

  start = RPR_TimeMap_QNToTime_abs(0, startppqposOut)
  end = RPR_TimeMap_QNToTime_abs(0, endppqposOut)

It is written in the reference, but I can not take it well ... ** * So extend the range of the editor to the beginning **

  start = RPR_TimeMap2_QNToTime(0, startppqposOut)
  end = RPR_TimeMap2_QNToTime(0, endppqposOut)

Is this newer ... I don't really understand the difference. This also seems to be incompatible with tempo changes on the way.

What to do if the output is longer than the Reaper console log

If it was long data, the log amount of the console was exceeded. I wish I could copy the text for the time being

import pyperclip

#Abbreviation

pyperclip.copy(outlist)

Well, it feels reasonable to output to a file.

Recommended Posts

Python script to get note information with REAPER
Get Alembic information with Python
Link to get started with python
How to get started with Python
Get weather information with Python & scraping
Get property information by scraping with python
Trying to handle SQLite3 with Python [Note]
PhytoMine-I tried to get the genetic information of plants with Python
[REAPER] How to play with Reascript in Python
[Yahoo! Weather Replacement Version] How to get weather information with LINE Notify + Python
I tried to get CloudWatch data with Python
[Improved version] Script to monitor CPU with Python
Get information about videos uploaded to YouTube [Python]
Note to daemonize python
Get CPU information of Raspberry Pi with Python
Get date with python
I tried to get the movie information of TMDb API with Python
A layman wants to get started with Python
Note: How to get the last day of the month with python (added the first day of the month)
How to add help to HDA (with Python script bonus)
[First API] Try to get Qiita articles with Python
I tried to get started with blender python script_Part 01
Reading Note: An Introduction to Data Analysis with Python
I tried to get started with blender python script_Part 02
How to get mouse wheel verdict with Python curses
[Python-pptx] Output PowerPoint font information to csv with python
[Python] Get user information and article information with Qiita API
Connect to BigQuery with Python
Get Twitter timeline with python
POST json with Python3 script
Get Youtube data with python
Post to slack with Python 3
Get information with zabbix api
Get thread ID with python
Switch python to 2.7 with alternatives
Write to csv with Python
Get started with Python! ~ ② Grammar ~
Get stock price with Python
Get home directory with python
Get keyboard events with python
Get information equivalent to the Network tab of Chrome developer tools with Python + Selenium
Try to display various information useful for debugging with python
Minimum knowledge to get started with the Python logging module
[python] A note when trying to use numpy with Cython
[Python] Get the script execution directory with an absolute path
How to get into the python development environment with Vagrant
[Python x Zapier] Get alert information and notify with Slack
Get additional data to LDAP with python (Writer and Reader)
Try Juniper JUNOS PyEz (python library) Memo 2 ~ Get information with PyEz ~
Get the source of the page to load infinitely with python.
Call github api in python to get pull request information
How to get the information of organizations, Cost Explorer of another AWS account with Lambda (python)
Get video file information with ffmpeg-python
Python: How to use async with
Get started with Python! ~ ① Environment construction ~
[Python] Write to csv file with Python
Get reviews with python googlemap api
Create folders from '01' to '12' with python
Nice to meet you with python
Get the weather with Python requests
Get web screen capture with python