468,512 Members | 1,338 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

Reading Wave File Using C++

tshabza
Could anyone give me idea on how to read a wave and convert in into an integer array file using C++, for now I can successfullly read text file.
Oct 11 '06 #1
2 5021
Banfa
9,056 Expert Mod 8TB
You will have to open the file in binary mode.

There is a small header which will give the format for the wav file (mono/stero, bits per sample, sample rate etc). After that it's just a long string of binary data that can be read in using fread
Oct 11 '06 #2
This is for example, a small code where i read array in a file. My problem is, i want to read a wave file and convert its binany form to array of integer, Please help....

#include <iostream>
#include <fstream>
using namespace std;

int i(0), array_index(0);
int *p1 = new int[BUFSIZ];
ifstream readfile;

void Read_File(){
readfile.open("file.txt");
while(!readfile.eof()) {
readfile >> p1[array_index];
array_index++;
}
array_index--;
readfile.close();

for(i = 0; i < array_index; i++){
cout<<" "<<p1[i];
}cout<<endl;
}

int main(int argc, char* argv[]){
Read_File();
delete[] p1;
}
Oct 13 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by david.kettle | last post: by
1 post views Thread by Jakub Dudek | last post: by
4 posts views Thread by vikram | last post: by
1 post views Thread by Nadie | last post: by
3 posts views Thread by VenuGopal | last post: by
4 posts views Thread by Erpman | last post: by
5 posts views Thread by m.topczewski | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.