Old 10-06-2013, 12:51 AM   #1
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default GetAudioAccessorStart/EndTime() - broken for takes?

Using GetAudioAccessorStartTime() on a take only seems to return 0 regardless of the item start position, source offset or section start, and GetAudioAccessorEndTime() only ever seems to return the item length. The function names led me to think that they would return timeline positions for the start/end of the media item (ie. when the take is audible)

Are these functions behaving as intended?

REAPER 4.53 x86 if it makes a difference.

Last edited by IXix; 10-06-2013 at 06:13 AM.
IXix is offline   Reply With Quote
Old 10-06-2013, 02:33 AM   #2
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by IXix View Post
Using GetAudioAccessorStartTime() on a take only seems to return 0 regardless of the item start position, source offset or section start, and GetAudioAccessorEndTime() only ever seems to return the item length. The function names led me to think that they would return timeline positions for the start/end of the media item (ie. when the take is audible)

Are these functions behaving as intended?

REAPER 4.53 x86 if it makes a difference.
A while ago, I was testing the audio accessor functions (with ReaScript). "RPR_GetAudioAccessorStartTime()" and "RPR_GetAudioAccessorEndTime()" seem to return timeline positions:



Code:
from reaper_python import *
import math

def msg(m):
    RPR_ShowConsoleMsg(str(m))

tr = RPR_GetSelectedTrack(0, 0)
##trackChannelCount = RPR_GetMediaTrackInfo_Value(tr, "I_NCHAN")
aa = RPR_CreateTrackAudioAccessor(tr)
##pos = RPR_GetCursorPosition()
##buf = list([0]*2*1024) # 2 channels, 1024 samples each, initialized to zero
buf = list([0]*2*1) # 2 channels, 1 sample each, initialized to zero
startTime = RPR_GetAudioAccessorStartTime(aa)
endTime = RPR_GetAudioAccessorEndTime(aa)
##(ret, buf) = RPR_GetAudioAccessorSamples(aa, 44100, 4, pos, 1, buf) # buf now holds the first 2*1 audio samples from the track.
for i in range(1):
    pos = float(startTime + (endTime - startTime) / 2)
    """ int GetAudioAccessorSamples(void* accessor, int samplerate, int numchannels, double starttime_sec, int numsamplesperchannel, double* samplebuffer)
    typically GetAudioAccessorSamples() would be called within a loop, increasing pos each time."""
    (ret, buf) = RPR_GetAudioAccessorSamples(aa, 44100, 2, pos, 1, buf)

msg("")
msg("Audio accessor start: " + str(startTime) + "\n")
msg("Audio accessor end: " + str(endTime) + "\n")
msg("\n")

if ret:
    channel1 = buf[0]
    channel2 = buf[1]

    msg("Samples (in the middle):\n")
    msg("Ch.1: " + str(channel1) + "\n")
    msg("Ch.2: " + str(channel2) + "\n")
    msg("\n")

    if channel1 != 0 and channel2 != 0:
        channel1dB = 20 * math.log10(abs(channel1))
        channel2dB = 20 * math.log10(abs(channel2))
        msg("Ch.1 dB: " + str(channel1dB) + "\n")
        msg("Ch.2 dB: " + str(channel2dB))
spk77 is offline   Reply With Quote
Old 10-06-2013, 05:17 AM   #3
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Your using a track accessor though, not a take accessor. The behaviour you show is what I would have expected to see from the take accessors but they only seem to return 0 and item length.

Please could you try using a take accessor? I suck at Python.
IXix is offline   Reply With Quote
Old 10-06-2013, 05:49 AM   #4
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by IXix View Post
Your using a track accessor though, not a take accessor. The behaviour you show is what I would have expected to see from the take accessors but they only seem to return 0 and item length.

Please could you try using a take accessor? I suck at Python.
I suck at Python too (and I didn't know that there's the "RPR_CreateTakeAudioAccessor()" ). You are right - the start time is always 0 and the end time = item length:

spk77 is offline   Reply With Quote
Old 10-06-2013, 05:53 AM   #5
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by spk77 View Post
You are right - the start time is always 0 and the end time = item length:
Thanks for testing it.

Justin/Schwa, is this behaviour correct? It seems wrong to me.
IXix is offline   Reply With Quote
Old 03-14-2018, 04:08 AM   #6
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Sorry for the necro, just for future reference if anyone else should stumble over this thread (like me)...

Now officially stated as intended behaviour.
https://forum.cockos.com/showthread.php?t=204397
nofish 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 08:59 AM.


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