473,699 Members | 2,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reading wave file data

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 suggestion as to how to extract wave data (and put it
for example in an array of ints) from a wav file is appreciated

Thanks for your time
Jakub
Jul 19 '05 #1
1 9385
On Tue, 2 Sep 2003 13:56:15 -0500, "Jakub Dudek" <ja*****@yahoo. com>
wrote:
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?
Standard C++ does not include an mmsystems library. You would be better
off posting questions related to it in a newsgroup more closely related
to the compiler or operating system which provides this library.
Alos, any other suggestion as to how to extract wave data (and put it
for example in an array of ints) from a wav file is appreciated


When I needed to do this, years ago, I just found myself a copy of the
..wav spec and wrote my own simple I/O based parser (using only standard
C++ no less). It's basically a matter of understanding the header so
that you know how many bits there are per sample, and whether it is mono
or stereo, and then you just read into your array. My job was a little
easier because I could guarantee that the waves were all in a particular
subset of the spec, but it wouldn't have been much harder to handle the
entire spectrum. It's really a pretty simple format.

--
Greg Schmidt (gr***@trawna.c om)
Trawna Publications (http://www.trawna.com/)
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5336
by: andrea valle | last post by:
Hi to all, I'm using wave module with success. I'm writing data to wave file. Typically I create a list of values (data) and pass it to ..writeframes(data) methods. a = wave.open("/test.wav", "w") a.writeframes() This sets the first sample to 32000 and the 2nd to 0
0
1940
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
4
3230
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
2085
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...
4
12798
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
2607
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>
3
5448
by: rajasekar.karthik | last post by:
Hi Guys I need a php script which will merge two wave files as i have already done a script which will will join the two wave files and play one after the other, can anyone advice me how to merge the two wave file and the two files has to play simultaneously. i have placed my script here <?php $content = joinwavs(array('1.wav','2.wav')); header('Content-Type: audio/x-wav'); //echo $content;
0
2021
by: Simrat Kaur Sandhu | last post by:
hello friends can anybody tell me how to read data from a wave file.. i have writen code as ... class file { private: FILE *fp; char id; char *sound_buffer; //four bytes to hold 'RIFF' long int size; //32 bit value to hold file size
6
29139
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. ...
0
8687
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
8615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8883
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
7750
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
6534
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
5874
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
4376
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...
3
2009
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.