473,765 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading Wave File Using C++

tshabza
2 New Member
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 5200
Banfa
9,065 Recognized Expert Moderator Expert
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
tshabza
2 New Member
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

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

Similar topics

0
1943
by: david.kettle | last post by:
Hello Python World! I've been playing with the 'wave' and 'audioop' modules in the library, and I have a question. When I tried to read a "wav" file with samples in 32-bit float, I got the following error: Traceback (most recent call last): File "Play.py", line 111, in ? playWAV(sys.argv) File "Play.py", line 69, in playWAV
1
9392
by: Jakub Dudek | last post by:
Hi, I am trying to read wave date (the 16 bits audio words) from a wave file using c++. I have tried using the mmsystems library. I got to the point where I read the wave data chunk into a character array using mmioread. This array does not make much sense to me however, I don't really understand the format. Anyone has an idea as to how to extract the 16 bit words from the character array returned by mmioread? Alos, any other...
4
3233
by: vikram | last post by:
in a stereo type of wave file i want to know what is this left & right info in a wave file??? how do i read the left & right info from a .wav file to a buffer..
1
2089
by: Nadie | last post by:
Greeting list readers, I noticed that the wave read object has an *implementation dependent* setpos(pos) method. When reading audio files, it is useful to be able to set the position to a specific sample. While setpos(pos) may do this on certain implementations (haven't tried it), it would not be a reliable way to do it in a platform independent manner. Is anyone familiar with an alternative wave package that would let one...
3
2151
by: VenuGopal | last post by:
hi, i want to store the WAVE FILE CONTENTS in an XML. How do i do it? thanks Venugopal
4
12803
by: Erpman | last post by:
I am trying to access the data with in a wav file. I am testing with very small files in order to keep the code simple to start with. Basically, im writing the entire wav file to a byte using a fileStream. The problem is that when reading back the data word by word and printing the results on a general form, once the data chunk header has been read, i.e, "data" and "chunk size", all the rest of the bytes in the array have the value...
5
2614
by: m.topczewski | last post by:
Hello, I'm a beginner in c++, i have to write a program that will take couple of segments from one wave file, and store them in another wave file to be played back later. Here's the code i have written: #include "stdafx.h" #include <cstdlib> #include <iostream>
6
29152
by: homevista | last post by:
PART III: Putting things together In part I we examined the modem to verify that it supported voice. If so, we took a note about the voice data format that we would use. In the second part, we prepared a wave file and implemented a piece of code in C# to be used by HomeZIX to read the wave file into a buffer. Now, it’s time to put things together to send out that buffer as an audio stream over the phone line to a designated phone number. ...
1
1443
by: subhakohila | last post by:
Hi, Can any one help me to read the wave file and pass through the modem to the telephone line....I tried with some set of codings but its returning some garbage values.... The coding i used to read the file is.. public byte ReadWavefile(string filename) { if (filename.Length > 0)
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7378
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.