Old 03-30-2017, 11:39 AM   #1
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default Meaning of "typebuf_sz" ?

I see in reaper_plugin_functions.h:

Code:
// GetMediaSourceType
// copies the media source type ("WAV", "MIDI", etc) to typebuf

  void (*GetMediaSourceType)(PCM_source* source, char* typebuf, int typebuf_sz);
What does typebuf_sz determine here ?
nofish is offline   Reply With Quote
Old 03-30-2017, 11:46 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by nofish View Post
I see in reaper_plugin_functions.h:

Code:
// GetMediaSourceType
// copies the media source type ("WAV", "MIDI", etc) to typebuf

  void (*GetMediaSourceType)(PCM_source* source, char* typebuf, int typebuf_sz);
What does typebuf_sz determine here ?
You need to pass in the size of the typebuf with that. (Because raw C arrays or pointers to arrays do not carry the size information with them.)
Code:
char buf[32];
GetMediaSourceType(src,buf,sizeof(buf));
__________________
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 03-30-2017, 12:15 PM   #3
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Ah...this probably explains why I couldn't get it to work.

Thanks again Xen.
nofish is offline   Reply With Quote
Old 03-30-2017, 12:25 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 nofish View Post
Ah...this probably explains why I couldn't get it to work.

Thanks again Xen.
By the way, if you are writing C++ code, you can get the media source type more directly by just doing :
Code:
const char* srctype = src->GetType();
__________________
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 03-30-2017, 01:07 PM   #5
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Well, actually I tried to do this for determing MIDI items

http://forum.cockos.com/showpost.php...92&postcount=4

but couldn't get it to work for some reason (probably my lack of C++ skills though.)

But then I figured one can also use ->GetSampleRate() (returns 0 for MIDI) whhich is working fine, so all good.
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:17 AM.


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