#include "../../std_lib_facilities.h"
usingnamespace std;
int main()
{
vector<double>xCount;
vector<double>yCount;
vector<double>header;
vector<double>sample;
string searchPattern;
double max;
double min;
double keyMax;
double finalTime;
char * memblock =0;
int size;
ifstream file("c:\\WAV\\BEandDAexp4_22post.wav",ios::ate|ios::binary);
if(file.is_open())
{
int data;
cout<< "Starting Stream" << endl;
size = (int)file.tellg(); // Use's eof operator to see how large the file is.
data = (size-44);
memblock = newchar[data];
file.seekg(44,ios::beg);
file.read(memblock, data); // Reads file using 'size' as the itterator of where to stop, set by ios::ate
max =0;
min =0;
int conv = 0;
for( int i =0; i<data ; ++i ) //For loop that will store the values of the binary vector as double's
{ //by casting and storing in private data member yCount
conv = static_cast<double>(memblock[i]);
yCount.push_back(conv);
if(conv>max)
{ // starting with zero and comparing to our string
max = conv; // Finds new max value and time associated with it.
}
elseif (conv<min)
{ // starting with zero and comparing to our string finds largest negative value
min = conv;
}
}
delete []memblock;
}
for(int i=0; i<200; i+=2)
{
cout<<static_cast<int>((yCount[i]) << " ";
}
file.close();
Out puts the correct single byte decimal values.
I need them in two byte pieces because the sample sizes are two bytes but, the problem is,
.read() that I am using takes a char * as it's argument.