Old 11-05-2018, 09:10 AM   #1
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default What is the AudioAccessor Samples Per Buffer limit?

HI Guys,

When trying to run code involving AudioAccessor on longer Items I run into an error:

Test Script.lua:70: bad argument #1 to 'new_array' (invalid size)

It's related to this line:

S_Buffer = reaper.new_array(Samples_Per_Item)

Is there a hard-limit? If so, what is a good workaround to process a larger Item?

This particular Item gives me the error when the size of the take is larger than around 2:30 min at 48K. So roughly around 4,007,040 samples.

Here is the code if interested:
https://forum.cockos.com/showpost.ph...2&postcount=12

Any ideas?

Cheers.
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.

Last edited by Thonex; 11-05-2018 at 11:58 AM.
Thonex is offline   Reply With Quote
Old 11-05-2018, 02:21 PM   #2
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,109
Default

The usual approach is to go through the samples in smaller blocks rather than all samples of the take at once so big amounts of memory don't need to be allocated.

Here's an exmple:

Defining the block size
https://github.com/X-Raym/REAPER-Rea...%20RMS.lua#L97

Then looping throu the samples per block:
https://github.com/X-Raym/REAPER-Rea...20RMS.lua#L124
nofish is offline   Reply With Quote
Old 11-05-2018, 03:24 PM   #3
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

Or use this code snippet: https://github.com/ReaTeam/ReaScript...%20samples.lua


Highly documented :P
X-Raym is offline   Reply With Quote
Old 11-05-2018, 04:04 PM   #4
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

For what it's worth, I fiddled with a few different values and didn't notice any sort of performance changes right up until it crashed and refused to entertain the idea.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 11-05-2018, 04:46 PM   #5
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default

Thanks everyone!!

Very good info here.

Nice examples!!

I saw this in X-Raym's link:

Code:
-- Break the range into blocks
    local block_size = 65536
Is that "65536" (16bit binary limit) really a good number to use here... or is it imply for nostalgia when used in 32 and 64 bit environments?

Sorry... I'm a musician... I missed that day in class

Thanks!
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 11-05-2018, 10:22 PM   #6
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
Default

Block size also depending on what resolution you want for further performing FFT of this sample block.
mpl is offline   Reply With Quote
Old 11-06-2018, 10:17 AM   #7
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default

Quote:
Originally Posted by mpl View Post
Block size also depending on what resolution you want for further performing FFT of this sample block.
Thanks mpl.

I'll experiment.

Cheers!
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 10-02-2019, 12:12 PM   #8
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

I'm trying to make a rough track navigator and noticed that reaper.GetMediaItemTake_Peaks can break a script when trying to get peak data from very very long takes.

But it's a very nice and efficient function :
spk77 is offline   Reply With Quote
Old 10-02-2019, 01:22 PM   #9
Vagelis
Human being with feelings
 
Vagelis's Avatar
 
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,827
Default

Quote:
Originally Posted by spk77 View Post
I'm trying to make a rough track navigator and noticed that reaper.GetMediaItemTake_Peaks can break a script when trying to get peak data from very very long takes.

But it's a very nice and efficient function :
Wow this looks great!
Vagelis is online now   Reply With Quote
Old 10-03-2019, 12:23 PM   #10
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Vagelis View Post
Wow this looks great!
Thanks!
I'll create a new thread for the script when all basic things are done.

Testing things:
Left click = play/stop
Right click/drag = move edit cursor (and arrange view)
spk77 is offline   Reply With Quote
Old 10-03-2019, 04:32 PM   #11
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default

Quote:
Originally Posted by spk77 View Post
I'm trying to make a rough track navigator and noticed that reaper.GetMediaItemTake_Peaks can break a script when trying to get peak data from very very long takes.
How long is very long?

Yeah... I think my limit was 45 seconds (ish).

Cheers,

Andrew K
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 10-04-2019, 05:27 AM   #12
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Thonex View Post
How long is very long?
Yeah... I think my limit was 45 seconds (ish).
The ReaScript arrays have a maximum length of about 4 million elements (64 bit floating point numbers). Oddly enough that isn't documented anywhere...What you can fit into that array depends on your particular data. It's best to do any processing split into smaller buffers, like was suggested at the beginning of this thread.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios 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 03:05 PM.


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