|
|
|
10-06-2013, 12:51 AM
|
#1
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
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.
|
|
|
10-06-2013, 02:33 AM
|
#2
|
Human being with feelings
Join Date: Aug 2012
Location: Finland
Posts: 2,668
|
Quote:
Originally Posted by IXix
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))
|
|
|
10-06-2013, 05:17 AM
|
#3
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
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.
|
|
|
10-06-2013, 05:49 AM
|
#4
|
Human being with feelings
Join Date: Aug 2012
Location: Finland
Posts: 2,668
|
Quote:
Originally Posted by IXix
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_Create TakeAudioAccessor()" ). You are right - the start time is always 0 and the end time = item length:
|
|
|
10-06-2013, 05:53 AM
|
#5
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
Quote:
Originally Posted by spk77
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.
|
|
|
03-14-2018, 04:08 AM
|
#6
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
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
|
|
|
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 08:59 AM.
|