Old 05-01-2016, 05:24 AM   #1
kronihias
Human being with feelings
 
Join Date: Oct 2013
Posts: 26
Default PCM_sink retrieve marker/regions

Hi,

I am working on a Render plugin (additional Output format) but struggling to write the marker/region data.

As I understand Reaper should call the PCM_sink member function
Code:
int Extended(int call, void *parm1, void *parm2, void *parm3)
with
Code:
call = PCM_SINK_EXT_ADDCUE
parm1=(PCM_cue*)cue
However this method is not being called for my Sink. Also the struct PCM_cue does not exist in reaper_plugin.h. (Maybe a typo and should be REAPER_cue?)

Do I have to tell Reaper somehow that my sink supports PCM_SINK_EXT_ADDCUE ?

Thanks, Matthias
kronihias is offline   Reply With Quote
Old 05-10-2016, 01:31 PM   #2
kronihias
Human being with feelings
 
Join Date: Oct 2013
Posts: 26
Default

Any news on this topic?
Is it even possible with the API to retrieve Marker information during writing or is this not implemented?

It'd be great to know, as I'd spend probably a lot of time trying something which might not even be possible at the moment...?
kronihias is offline   Reply With Quote
Old 05-10-2016, 01:35 PM   #3
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 2,068
Default

Hi Matthias,
I sent you a PM. Did you get it?

Wyatt
__________________
DDP To Cue Writer. | DDP Marker Editor.
WyattRice is offline   Reply With Quote
Old 05-10-2016, 03:30 PM   #4
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by kronihias View Post
Any news on this topic?
Is it even possible with the API to retrieve Marker information during writing or is this not implemented?

It'd be great to know, as I'd spend probably a lot of time trying something which might not even be possible at the moment...?
I don't know for sure, but if it appears to not work, it'd be a safe guess that custom PCM_sink implementations can't do it at the moment. (So it'd be hardcoded to only work with particular PCM_sink implementations within Reaper itself.)
__________________
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
Old 05-11-2016, 08:28 AM   #5
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,737
Default

Hmm, it should be calling Extended() with PCM_SINK_EXT_ADDCUE regardless of what sink it is. It may wait until the end of the render to call it, though, you should ideally be flexible on when you receive those calls. Also, if you don't return 1 from that Extended() call, you won't receive any more of them.
Justin is offline   Reply With Quote
Old 05-20-2016, 11:52 PM   #6
kronihias
Human being with feelings
 
Join Date: Oct 2013
Posts: 26
Default

Hi,

Extended() is not being called for my sink, but I solved the problem by calling the API function enumProjectMarkers at the end of writing all samples.
(Have a look at reaper_plugin_functions.h if you have the same problem)

Thanks to Wyatt for the hint.

Best, Matthias
kronihias is offline   Reply With Quote
Old 05-21-2016, 08:03 AM   #7
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,737
Default

Quote:
Originally Posted by kronihias View Post
Hi,

Extended() is not being called for my sink, but I solved the problem by calling the API function enumProjectMarkers at the end of writing all samples.
(Have a look at reaper_plugin_functions.h if you have the same problem)

Thanks to Wyatt for the hint.

Best, Matthias
If you'd like to post the code I can take a look as to why this is. Are you using the sink for rendering (via file->Render) or some other action?
Justin is offline   Reply With Quote
Old 05-21-2016, 08:13 AM   #8
kronihias
Human being with feelings
 
Join Date: Oct 2013
Posts: 26
Default

Hi Justin,

I am using the sink for the File->Render Dialog, yes.

The code lives here: ( I guess it's too much to post here )
https://github.com/kronihias/reaper_...sink_ambix.cpp

I realized that the API function enumProjectMarkers does not help me a lot as the markers timestamps are absolute to the project, not to the part being rendered. I did not find a way to query the actual start time of the segment that is being rendered. Is there a way to do that?

Thanks, Matthias
kronihias is offline   Reply With Quote
Old 05-22-2016, 03:14 PM   #9
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,737
Default

Quote:
Originally Posted by kronihias View Post
Hi Justin,

I am using the sink for the File->Render Dialog, yes.

The code lives here: ( I guess it's too much to post here )
https://github.com/kronihias/reaper_...sink_ambix.cpp

I realized that the API function enumProjectMarkers does not help me a lot as the markers timestamps are absolute to the project, not to the part being rendered. I did not find a way to query the actual start time of the segment that is being rendered. Is there a way to do that?
Yes, your sink's SetStartTime() will likely get called with the offset.

Quote:
Extended() is not being called for my sink
Is it not being called at all, or just not for marker info?

Code:
  int Extended(int call, void *parm1, void *parm2, void *parm3)
Hmm, that looks right, but try making it:

Code:
virtual int Extended(int call, void *parm1, void *parm2, void *parm3) override
(assuming your compiler supports the override keyword)
The virtual keyword shouldn't be necessary, but it is very odd that you aren't getting *any* Extended() calls.

Also I noticed that you're including "reaper_plugin.h", but the only file in the source tree would be "../jmde/reaper_plugin.h" -- are we sure the correct version of reaper_plugin.h is being used? (If you have include paths set, I guess doublecheck that?)

Last edited by Justin; 05-22-2016 at 03:55 PM.
Justin is offline   Reply With Quote
Old 05-26-2016, 02:19 AM   #10
kronihias
Human being with feelings
 
Join Date: Oct 2013
Posts: 26
Default

Quote:
Originally Posted by Justin View Post
Yes, your sink's SetStartTime() will likely get called with the offset.
Thanks, this works. Therefore I am able to get the relative position of the markers.


Quote:
Originally Posted by Justin View Post
Is it not being called at all, or just not for marker info?
I did some more test under OSX and Windows:
Under MacOS Extended(...) is not being called at all.
Unter Windows it is being called, but only with call=PCM_SINK_EXT_VERIFYFMT, PCM_SINK_EXT_GETBITDEPTH and PCM_SINK_EXT_SETCURBLOCKTIME;
not with PCM_SINK_EXT_ADDCUE.

Quote:
Originally Posted by Justin View Post
Hmm, that looks right, but try making it:

Code:
virtual int Extended(int call, void *parm1, void *parm2, void *parm3) override
(assuming your compiler supports the override keyword)
The virtual keyword shouldn't be necessary, but it is very odd that you aren't getting *any* Extended() calls.
Ok, did this but it didn't help.

Quote:
Originally Posted by Justin View Post
Also I noticed that you're including "reaper_plugin.h", but the only file in the source tree would be "../jmde/reaper_plugin.h" -- are we sure the correct version of reaper_plugin.h is being used? (If you have include paths set, I guess doublecheck that?)
Where is the official place to get a recent version of reaper_plugin.h?
I got it now from the SWS repo and put it into my main source directory, but it didn't help either.

Do you have an idea why extended is being called under Windows, but not under MacOS?
What compiler settings would you recommend for OSX?
(I'm generating my makefile using CMake, and I use the Command Line Tools 6.2)

Best, Matthias
kronihias is offline   Reply With Quote
Old 05-26-2016, 09:04 PM   #11
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,737
Default

OK, I finally got it to compile and sort of function (without having to try to get libambix to build, bleh).

To fix the issue:
Code:
   void WriteDoubles(ReaSample **samples, int len, int nch, int offset, int spacing)
   {
+    m_lensamples += len;
     // printf("i am writing %d samples, my samples are %d, spacing %d, offset %d \n", len, sizeof(ReaSample), spacing, offset);
     if (m_peakbuild)
       m_peakbuild->ProcessSamples(samples,len,m_in_ch,offset,spacing);
(explanation: REAPER will only pass cues that are within the valid range of the sink, and the current code always returns 0 for length)


Something I noticed:
Code:
        char buf[2];
        wsprintf(buf,"%d", i);
That buffer is far too small! Also if you copied/pasted wsprintf() from ancient example code I'm sorry, we all use snprintf() these days.
Justin is offline   Reply With Quote
Old 05-27-2016, 01:09 PM   #12
kronihias
Human being with feelings
 
Join Date: Oct 2013
Posts: 26
Default

Thanks Justin for looking into the code and helping me out here! I wouldn't have found that on my own.

Updating the number of written samples fixed the problem for both OSX and Windows.

Thanks for the comment on deprecated functions. I'll try to clean up the code so it can also function as not-so-ancient example for other people

Best, Matthias
kronihias 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 12:10 PM.


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