Old 05-23-2020, 03:17 AM   #1
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,516
Default Q: Get average pitch of items with GetMediaItemTake_Peaks (peakrate ?)

Hi !


I'm trying to see if GetMediaItemTake_Peaks can be good enough to get average note of an item.


The doc:
Quote:
Code:
reaper.GetMediaItemTake_Peaks( take, peakrate, starttime, numchannels, numsamplesperchannel, want_extra_type, buf )
Gets block of peak samples to buf. Note that the peak samples are interleaved, but in two or three blocks (maximums, then minimums, then extra). Return value has 20 bits of returned sample count, then 4 bits of output_mode (0xf00000), then a bit to signify whether extra_type was available (0x1000000). extra_type can be 115 ('s') for spectral information, which will return peak samples as integers with the low 15 bits frequency, next 14 bits tonality.

In its initial code snippet to get pitch of item at certain position, using this function, Justin just put "1000" as peak rate. Why 1000 ?

https://github.com/ReaTeam/ReaScript...sition.lua#L43

What would be the best way to average pitch of a whole items ? Using peakrate = 1000 and sample pitch every X value (what would be in X in this case ?), or putting as many sample as the item has in peakrate without the need to create a loop ?

Thanks for the clarification about this function !
X-Raym is offline   Reply With Quote
Old 05-23-2020, 06:38 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,516
Default

Well maybe this function isnt the most adapted for such things. I just found a cross platform CLI tool wich can do media pitch analyses with various algorythms possible, this extra flexibility can be useful.


Though my questions are still open, for curiosity.
X-Raym is offline   Reply With Quote
Old 05-23-2020, 07:28 AM   #3
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 2,831
Default

Probably best way is just loop every 1000samples to build pitch corellation (obey tonality and octave shifts).

Quote:
Originally Posted by X-Raym View Post
Why 1000 ?
I think 1000 samples is near 40Hz sine period for 44100Hz samplerate aka lower detection limit.
__________________
SoundCloud | MPL Scripts discussion | ReaPack | Donate
mpl 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 07:12 AM.


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