|
|
|
10-03-2020, 01:00 PM
|
#1
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,792
|
Get buffer size?
Is there any way to get what the current buffer sizes? Thanks as always
|
|
|
10-03-2020, 01:11 PM
|
#2
|
Human being with feelings
Join Date: Mar 2013
Posts: 5,857
|
If you're referring to the sample buffer size of the audio device, try the GetAudioDeviceInfo function: https://www.extremraym.com/cloud/rea...udioDeviceInfo
Quote:
GetAudioDeviceInfo
Get information about the currently open audio device. attribute can be MODE, IDENT_IN, IDENT_OUT, BSIZE, SRATE, BPS. returns false if unknown attribute or device not open.
|
lua example:
Code:
retval, desc = reaper.GetAudioDeviceInfo("BSIZE", "")
if retval then
reaper.ShowConsoleMsg(desc)
end
|
|
|
10-04-2020, 05:34 AM
|
#3
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,792
|
Awesome, that made it so easy for me to enable master fx based on my buffer. Thanks solger !
Code:
retval, desc = reaper.GetAudioDeviceInfo("BSIZE", "")
if(tonumber(desc) < 257) then
-- disable master fx
reaper.Main_OnCommand(reaper.NamedCommandLookup("_SWS_DISMASTERFX"), 0)
else
-- enable master fx
reaper.Main_OnCommand(reaper.NamedCommandLookup("_SWS_ENMASTERFX"), 1)
end
|
|
|
10-05-2020, 11:30 AM
|
#4
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,792
|
How come I'm getting nil:
JB_mastering_mode_fx_toggle.lua:45: attempt to compare nil with number
from "desc" when I run this in a project startup script ?
retval, desc = reaper.GetAudioDeviceInfo("BSIZE", "")
Code:
retval, desc = reaper.GetAudioDeviceInfo("BSIZE", "")
if retval then
if debug then Msg("buffer returned: " .. desc) end
end
if(tonumber(desc) < 257) then
-- disable master fx
reaper.Main_OnCommand(reaper.NamedCommandLookup("_SWS_DISMASTERFX"), 0)
if debug then Msg("disabled master fx") end
else
-- enable master fx
reaper.Main_OnCommand(reaper.NamedCommandLookup("_SWS_ENMASTERFX"), 1)
if debug then Msg("enabled master fx") end
end
|
|
|
10-05-2020, 12:08 PM
|
#5
|
Human being with feelings
Join Date: May 2018
Location: Moscow, Russia
Posts: 612
|
And how to set a new buffer size? The reaper.SNM_SetIntConfigVar('asio_bsize', newvalue ) function doesn't seem to work
|
|
|
10-05-2020, 01:58 PM
|
#6
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,792
|
Quote:
Originally Posted by Yanick
And how to set a new buffer size? The reaper.SNM_SetIntConfigVar('asio_bsize', newvalue ) function doesn't seem to work
|
I think that depends on your sound card and whether or not it can accept the commands are not. I've got an rme 9652 and I'll have to give it a try to see if it likes the command or not. What sound cards are you using Yanick.
|
|
|
10-05-2020, 02:04 PM
|
#7
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,792
|
And the code I posted up top work once Reaper is started but running it during startup gives me nil as I guess the sound card has not been initialized yet. I wonder if there's a way to wait for it to be initialized before running the command
|
|
|
10-05-2020, 02:45 PM
|
#8
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Quote:
Originally Posted by Coachz
And the code I posted up top work once Reaper is started but running it during startup gives me nil as I guess the sound card has not been initialized yet. I wonder if there's a way to wait for it to be initialized before running the command
|
You can put it into a defer-loop and keep that loop running until you get a valid value.
And keep in mind, that on Windows at least, the returned value can be nil, when the Prefs->Devices page is opened.
Last edited by Meo-Ada Mespotine; 10-05-2020 at 02:50 PM.
|
|
|
10-05-2020, 02:48 PM
|
#9
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Quote:
Originally Posted by Yanick
And how to set a new buffer size? The reaper.SNM_SetIntConfigVar('asio_bsize', newvalue ) function doesn't seem to work
|
You can't. Maybe with ugly hacks involving opening prefs, virtually clicking stuff including inserting the new buffersize and hitting ok. But this is ugly and messes with potential userinteraction.
|
|
|
10-05-2020, 03:02 PM
|
#10
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,792
|
Quote:
Originally Posted by Meo-Ada Mespotine
You can put it into a defer-loop and keep that loop running until you get a valid value.
And keep in mind, that on Windows at least, the returned value can be nil, when the Prefs->Devices page is opened.
|
Thanks for the reply, by defer loop do you mean something like....
repeat
statement(s)
until( condition )
|
|
|
10-05-2020, 04:14 PM
|
#11
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Quote:
Originally Posted by Coachz
Thanks for the reply, by defer loop do you mean something like....
repeat
statement(s)
until( condition )
|
No, rather this one:
https://forum.cockos.com/showpost.ph...2&postcount=21
Other loops block Reapers Gui. Defer-loops keep Reaper's gui active.
|
|
|
10-06-2020, 12:58 AM
|
#12
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,792
|
Thanks, that got me going and the script doesn't seem to keep running as I don't see it in the Actions menu where continuously running scripts show up. Instead of using a timer is there a way to run the script until success and then have it end ?
Code:
local desc = nil
time_start = reaper.time_precise()
local function Main()
local elapsed = reaper.time_precise() - time_start
if elapsed >= 1 then
retval, desc = reaper.GetAudioDeviceInfo("BSIZE", "")
if retval then
if debug then Msg("buffer returned: " .. desc) end
end
if(tonumber(desc) < 257) then
-- disable master fx
reaper.Main_OnCommand(reaper.NamedCommandLookup("_SWS_DISMASTERFX"), 0)
if debug then Msg("disabled master fx") end
else
-- enable master fx
reaper.Main_OnCommand(reaper.NamedCommandLookup("_SWS_ENMASTERFX"), 1)
if debug then Msg("enabled master fx") end
end
return
else
reaper.defer(Main)
end
end
Main()
Last edited by Coachz; 10-06-2020 at 01:06 AM.
|
|
|
10-06-2020, 06:20 AM
|
#13
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Code:
if desc==nil
reaper.defer(Main)
else
-- do your stuff here with desc
end
|
|
|
10-06-2020, 08:31 AM
|
#14
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,792
|
Thanks so much!
|
|
|
10-06-2020, 09:48 AM
|
#15
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,792
|
Quote:
Originally Posted by Meo-Ada Mespotine
Code:
if desc==nil
reaper.defer(Main)
else
-- do your stuff here with desc
end
|
What is Main in your example ?
|
|
|
10-06-2020, 02:02 PM
|
#16
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Your own main function. Couldn't rewrite it accordingly as I'm afk right now and writing code on my phone is too difficult to do.
I advice you to read the post I mentioned again. The last example under PS helps you guiding through this.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 09:31 PM.
|