DSPRelated.com
Forums

HELP!!! read/write WAV files for pitch shifting

Started by Unknown June 29, 2007
Hi,

i'm currently working on this project which involves reading a wave
file, converting the data into a range of [-1,+1), then using STFT to
do pitch shifting, then play the pitch-shifted wav file. I have
already found information on STFT but it requires .wav being read into
integer arrays, then FT it into another array. Where can i find source
codes or examples on reading, writing and playing wave files from
integer arrays? I've done some research, it seems that most people are
suggesting two ways:
1. DirectX SDK consists of examples of CSound CWaveFiles...etc. that
reads and play wave files, but how does it do that? the tutorials are
very complicated and i am currently using DirectMIDI to play
instrument sounds in my project(another part of the project other than
the wav) so I dont want to import all the DirectMusic files again
2. using mmioXXX functions seems to be another solution but again is
there any examples? Ive looked at the MSDN website, but im not really
sure wat to, how to and when to use the mmoiOpen, Read, Write...etc.
functions, how does this related to the integer arrays that i need for
my project? some people also mentioned about the MSDN LOWPASS sample,
but where can u find it online?
So which one of these two method is better? or is there another way?
actually the only thing i need is something similar to the miniAIFF
library on
http://www.dspdimension.com/index.html?miniaiff.html
but this library only read AIFF files, is there a similar WAV library?

Thanks very much

On Jun 29, 4:40 pm, jin_ge_l...@hotmail.com wrote:
> Hi, > > i'm currently working on this project which involves reading a wave > file, converting the data into a range of [-1,+1), then using STFT to > dopitchshifting, then play thepitch-shiftedwavfile. I have > already found information on STFT but it requires .wavbeing read intointegerarrays, then FT it into another array. Where can i find source > codes or examples on reading, writing and playing wave files fromintegerarrays? I've done some research, it seems that most people are > suggesting two ways: > 1. DirectX SDK consists of examples of CSound CWaveFiles...etc. that > reads and play wave files, but how does it do that? the tutorials are > very complicated and i am currently using DirectMIDI to play > instrument sounds in my project(another part of the project other than > thewav) so I dont want to import all the DirectMusic files again > 2. using mmioXXX functions seems to be another solution but again is > there any examples? Ive looked at the MSDN website, but im not really > sure wat to, how to and when to use the mmoiOpen,Read, Write...etc. > functions, how does this related to theintegerarraysthat i need for > my project? some people also mentioned about the MSDN LOWPASS sample, > but where can u find it online? > So which one of these two method is better? or is there another way? > actually the only thing i need is something similar to the miniAIFF > library onhttp://www.dspdimension.com/index.html?miniaiff.html > but this library only read AIFF files, is there a similarWAVlibrary? > > Thanks very much
oopss....forgot, im working on VC++, so sample codes in VC++ would be helpful
 jin_ge_ling@hotmail.com wrote:

> 1. DirectX SDK consists of examples of CSound CWaveFiles...etc. that
I've seen some example code using CWaveFile and it was pretty horrible.
> 2. using mmioXXX functions seems to be another solution but again is
Those mmioXXX functions are even worse. Try libsndfile: http://www.mega-nerd.com/libsndfile/ which reads much more than just WAV files and works on unix, Linux, MacOSX and windows.
> oopss....forgot, im working on VC++, so sample codes in VC++ would be > helpful
Download the precompiled windows binaries of libsndfile at the above URL. Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- "life is too long to know C++ well" -- Erik Naggum
Erik de Castro Lopo <erikd@mega-nerd.com> writes:
> [...] > Try libsndfile: > > http://www.mega-nerd.com/libsndfile/ > > which reads much more than just WAV files and works on unix, Linux, > MacOSX and windows.
That reminds me of a long-standing question I've had: does wxWidgets have a cross-platform sound API? -- % Randy Yates % "She tells me that she likes me very much, %% Fuquay-Varina, NC % but when I try to touch, she makes it %%% 919-577-9882 % all too clear." %%%% <yates@ieee.org> % 'Yours Truly, 2095', *Time*, ELO http://home.earthlink.net/~yatescr
Erik de Castro Lopo wrote:
> Try libsndfile: > which reads much more than just WAV files
Reading and writing WAV files is the easy bit - and frequently you can do very much better than professionally, written software which often fails to read a file containing application specific chunks, rather than simply ignoring them as it should. I have the same requirement as the OP and want to be able to play selected fragments of sound from data stored in an array. As far as I can see routines in toolboxes written for Octave/Matlab etc generally seem to cheat by writing a temporary WAV file and launching the default media player. There must be a more elegant way of playing the sound directly from the program. David
Randy Yates wrote:

>> which reads much more than just WAV files and works on unix, Linux, >> MacOSX and windows. > > That reminds me of a long-standing question I've had: does wxWidgets > have a cross-platform sound API?
WxWidgets originated on Unix. Unix libraries usually only try to do one thing and do that well.For WxWidgets thats GUIs. For a cross-platform sound API I would suggest PortAudio (Google it :-)). Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- "Unix, is novice hostile... Windows, is expert hostile." -- BCS on digitalmars.D