|
09-28-2017, 05:36 AM
|
#1
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
Input buffer of type char*
Hi,
I'm working on a VST plugin with an SDK which provides buffers of type char* as :
"] ZP=V *B-{;(x&QPy q}m?Qx9c81ZX
W SPI*a}mt`ekv hjGa " (this is an example of buffer I can get)
which is first, completely weird and second, I don't know how to make it working with WDL-Ol's IPlug. Have you already seen something of this kind ? I would prefer not to rewrite the SDK haha
|
|
|
09-28-2017, 01:39 PM
|
#2
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Well, doesn't the SDK say what kind of data is in the char* buffers? Obviously it's not text, as shown by your text dump of it. If I had to guess, it's 8 bit audio samples? (char being an 8 bit number type...)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
10-02-2017, 02:16 AM
|
#3
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
Quote:
Originally Posted by Xenakios
Well, doesn't the SDK say what kind of data is in the char* buffers? Obviously it's not text, as shown by your text dump of it. If I had to guess, it's 8 bit audio samples? (char being an 8 bit number type...)
|
Yup that was it, an 8 bit audio sample, so I've made a DoubleToBuffer function and now it works like a charm.
|
|
|
10-04-2017, 02:31 AM
|
#4
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
Well it works but it brings more problems than advantages, do you think that I could refactor WDL for char* buffers ?
|
|
|
10-04-2017, 03:58 AM
|
#5
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by JonOsterman
Well it works but it brings more problems than advantages, do you think that I could refactor WDL for char* buffers ?
|
Plugins work with 32 or 64 bit floating point samples, so you are stuck with dealing with those. What are the problems you are having?
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
10-04-2017, 06:58 AM
|
#6
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
Quote:
Originally Posted by Xenakios
Plugins work with 32 or 64 bit floating point samples, so you are stuck with dealing with those. What are the problems you are having?
|
Thing is that I got my double *input;
Then I declare and malloc my char *out;
I call my convertDoubleToBuffer() which is
Quote:
int AWM_VST_Plugin::convertDouble2Buffer(void* bufferIn, int sizeBufferIn, void *bufferOut)
{
int numBytes = 2; //BufferOut Nb bytes
long long int factorConversion_32 = ((long long int)1) << 31;
const int num_bits_conv_32_bits = 32 - numBytes * 8;
const float conv_32_bits = (float)(1 << num_bits_conv_32_bits);
for (int i = 0; i < sizeBufferIn; i++)
{
float val_float = (float)((float*)bufferIn)[i] * factorConversion_32 + 0.5f * conv_32_bits;
long long int val = (long long int)floor(val_float);
if (val >= factorConversion_32)
val = factorConversion_32 - 1;
else if (val <= -factorConversion_32)
val = (-factorConversion_32);
val >>= num_bits_conv_32_bits;//on 16 bits again.
((short*)bufferOut)[i] = (short)(val);
}
return 0;
}
|
(I've got another version for a 32bits output which doesn't work either)
And then even before using the sdk if I record my result in a wave file to test it I can hear my stream in the background and over it some random noise (and my file is twice as long as the stream I recorded originally)
|
|
|
10-04-2017, 07:56 AM
|
#7
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Sorry, I am having a too hard time understanding what you are actually trying to do that I can't offer further advice. Maybe someone else can chime in...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
10-04-2017, 08:53 AM
|
#8
|
Administrator
Join Date: Mar 2007
Location: NY
Posts: 15,823
|
Why is numbytes 2, if you are converting to 8 bits?
If I were converting a buffer of doubles to 8 bits, I'd just do this.
Code:
for (i=0; i < buflen; ++i)
{
double v=dbuf[i];
if (v < 0.0)
{
if (v < -1.0) v=-1.0;
cbuf[i]=(char)(-v*SCHAR_MIN);
}
else if (v > 0.0)
{
if (v > 1.0) v=1.0;
cbuf[i]=(char)(v*SCHAR_MAX);
}
else
{
cbuf[i]=0; // not necessary if memset(cbuf) upstream
}
}
|
|
|
10-10-2017, 02:35 AM
|
#9
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
Hi schwa,
I tried your loop but it gave me a Heap Corruption, so I might have misunderstood something :
- Can I assume that nFrames is the double buffer's size ?
- Maybe it's normal but nFrames takes values like 212, 33, 179 (which makes 212), 91, 121, 212, ... you got the point. Is it normal or could it be an ASIO problem or something else ?
EDIT : I solved the Heap Corruption, but my questions are still relevant if someone got the answers
Last edited by JonOsterman; 10-10-2017 at 05:41 AM.
|
|
|
10-10-2017, 05:22 AM
|
#10
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by JonOsterman
- Maybe it's normal but nFrames takes values like 212, 33, 179 (which makes 212), 91, 121, 212, ... you see the idea. Is it normal or could be an ASIO problem or something else ?
|
nFrames is the number of 64 bit floating point sample "frames". The number of "frames" is the same no matter if the signal is mono or stereo etc.
What nFrames you get depends on the host. Some will always give you one number for that, some will mostly give you one number and occasionally something else and some hosts like FL Studio can give you very different numbers for that each time. You will just need to be prepared to deal with that. If your external algorithm uses buffer sizes that don't fit with the nFrames number you get in IPlug, you will need to yourself come up with some method to accommodate that. (Use a queue or ring buffer etc...)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
10-10-2017, 05:41 AM
|
#11
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
Quote:
Originally Posted by Xenakios
nFrames is the number of 64 bit floating point sample "frames". The number of "frames" is the same no matter if the signal is mono or stereo etc.
What nFrames you get depends on the host. Some will always give you one number for that, some will mostly give you one number and occasionally something else and some hosts like FL Studio can give you very different numbers for that each time. You will just need to be prepared to deal with that. If your external algorithm uses buffer sizes that don't fit with the nFrames number you get in IPlug, you will need to yourself come up with some method to accommodate that. (Use a queue or ring buffer etc...)
|
Thanks, so it depends on how the hosts treat the data ? I'm working on that kind of solution at this very moment
|
|
|
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 01:14 PM.
|