Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 07-26-2017, 06:05 AM   #1
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,866
Default [SOLVED] Q: EEL version of Get item source frequency code snippet ?

Hi,

Justin shows us lua script to get pitch at certain time for a take, in Lua.

Code:
-- http://forum.cockos.com/showpost.php?p=1777001&postcount=2
-- REAPER v32
item = reaper.GetSelectedMediaItem(0,0);
take = reaper.GetMediaItemTake(item,0);
nch = reaper.GetMediaSourceNumChannels(reaper.GetMediaItemTake_Source(take));

ns = 1;
buf = reaper.new_array(ns*3*nch);
rv = reaper.GetMediaItemTake_Peaks(take,1000.0, reaper.GetCursorPosition(),nch,ns,115,buf);
if rv & (1<<24) and (rv&0xfffff) > 0 then
  spl = buf[nch*ns*2 + 1];
  pitch = spl&0x7fff;
  tonality = (spl>>15)/16384.0
end
What would be the EEL conversion for this ?

Here how far I went :
Code:
item = GetSelectedMediaItem(0,0);
take = GetMediaItemTake(item,0);
nch = GetMediaSourceNumChannels(GetMediaItemTake_Source(take));

ns = 1;
buf = 0;
rv = GetMediaItemTake_Peaks(take,1000.0, GetCursorPosition(),nch,ns,115,buf);
rv & (1<<24) && (rv&0xfffff) > 0 ? (
  spl = buf[nch*ns*2 + 1];
  pitch = spl&0x7fff;
  tonality = (spl>>15)/16384.0;
);
rv as the same value in both EEL and Lua in my test (aka, conversion works), but spl, pitch and tonality are still 0 (aka, something is wrong in EEL with this lines).

Any ideas ?

Thanks !

EDIT: to use the code snippet, put your edit cursor inside a selected audio take boundary.

Last edited by X-Raym; 07-26-2017 at 08:12 AM.
X-Raym is offline   Reply With Quote
Old 07-26-2017, 08:12 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,866
Default

I get it.

Lua - 1 based array
buf[nch*ns*2 + 1];

EEL - 0 based array

buf[nch*ns*2];

It was pretty simple in fact ^^
X-Raym 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 10:05 PM.


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