Getting digital sound into an accessable array

Started by
2 comments, last by Dwiel 21 years, 7 months ago
How can I take say a wave file, and put it in a large array that hold the wave in a way where you could get the aplitude for any given exact time. Maybe have an array which held the aplitude of the sound for every 1/44,000th of a second. or whatever the frequency is. Thanx tazzel3d ~ Dwiel
Advertisement
do you mean aplitude or amplitude?

You would just load the wave into an array. At the frequency, you would have one sample per second, and then you would just read off the value of that part of the array. Although, you might want to do it a little bit at a time, as even a small sound sample would be several megabytes.

Do not meddle in the affairs of moderators, for they are subtle and quick to anger.ANDREW RUSSELL STUDIOS
Cool Links :: [ GD | TG | MS | NeHe | PA | SA | M&S | TA ]
Got Clue? :: [ Start Here! | Google | MSDN | GameDev.net Reference | OGL v D3D | File Formats | Go FAQ yourself ]

I meant amplitude... my m key on my keyboard is goofed. Anyway, so I have a wav and want to have the height of the wave at every (1/frequency)ths of a second and store it in an array. I guess I am wondering how to load it into an array.

thanx for the response!

tazzel3d ~ dwiel
You find out the file format, read it using file loading functions, allocate the correctly sized array (length depends on duration, data type depends on whether it''s 8, 16, or whatever bits per sample, and you will need 2 arrays for stereo). Then you just read in the values. Try www.wotsit.org to find out file formats. Once you have the file format, loading in a basic wave file is just simple C or C++ code.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]

This topic is closed to new replies.

Advertisement