I'll try and explain the bits of code I've used, but please bear it mind I am relativly new to programming so be gentle
This part of the code is in processReplacing and reads in the PCM file Snare.Wav (I hope)
Code: Select all
void CDrumMajor::processReplacing(float **inputs, float **outputs, long sampleFrames)
{
// NEW : we have no inputs so only evaluate the output buffers
float *out1 = outputs[0];
float *out2 = outputs[1];
FILE* theFile = fopen("e:\\snare.wav", "r"); // open it
fseek(theFile, 0, SEEK_END); //
size = ftell(theFile) >> 1; //
fseek(theFile, 0, SEEK_SET); //
short *tempArray = new short[size]; // alloc up some arrays
float *floatArray = new float[size];
float *leftArray = new float[size];
float *rightArray = new float[size];
int buffercount = 0;
int samplecount = 0;
int play = 0;
// read in the entire file
fread(tempArray, size << 1, 1, theFile);
fclose(theFile);
for(long i = 0; i < size; ++i)
{
// rescale and convert to float
floatArray[i] = (float)tempArray[i] / 32767.f;
//CLAMP(floatArray[i], -1.0f, 1.0f);
}
int count = 0;
for (i = 44 ; i <size; i= i+2)
{
leftArray[count] = floatArray[i];
rightArray[count] = floatArray[i+1];
count++;
}
Code: Select all
while(--sampleFrames >= 0)
{
VstTimeInfo* myTime = getTimeInfo ( kVstPpqPosValid | kVstTempoValid );
MyTempo = myTime->tempo;
MyNumerator = myTime->timeSigNumerator;
SamplePos = myTime->samplePos;
SampleRate =myTime->sampleRate;
PPQPos = myTime->ppqPos;
BarStartPos = myTime->barStartPos;
KickBeatPos = MyNumerator / 16;
// ignore this next bit - not used yet
for (count = 1; count <17; count++)
{
randprob = rand()%99 + 1;
KickBeatProb[count] = randprob;
}
for (count = 1; count < 17; count++)
{ aBarStartPos[count] = BarStartPos + (KickBeatPos * (count-1));
if ((PPQPos >= aBarStartPos[count] && PPQPos <=(aBarStartPos[count] + 0.2) && (KickBeat[count] == 1) && (play == 0)))
{
/* play = 1;
samplecount=0;
}
if (play == 1)
{ */
(*out1++) = leftArray[samplecount]; // replacing
(*out2++) = rightArray[samplecount];
samplecount++;
if ((samplecount * 2) > size) samplecount = 0;
//
}
}
int size;
All of which would be great, except, erm.... well it doesn't work
Any help would mean that I would be able to sleep again at night.
I'll sort you out with some kind of beer related thanks (somehow)
T*