Hello,
I am trying to create and read wav files. Does anyone know of a good c++ library (that will work on Qt creator) or tutorial on this?
Thank you
Hello,
I am trying to create and read wav files. Does anyone know of a good c++ library (that will work on Qt creator) or tutorial on this?
Thank you
Hi,
I used libsndfile libsndfile with c++ interface.
It's simple to use and has good performance!
A camel can go 14 days without drink,
I can't!!!
Maluko_Da_Tola (17th September 2010)
Thanks for the posting!
One more question:
I tried to run the following c++ example code from http://parumi.wordpress.com/2007/12/...g-libsndfile/:
#include <sndfile.hh>
02 #include <iostream>
03 #include <cmath>
04 int main()
05 {
06 const int format=SF_FORMAT_WAV | SF_FORMAT_PCM_16;
07 // const int format=SF_FORMAT_WAV | SF_FORMAT_FLOAT;
08 const int channels=1;
09 const int sampleRate=48000;
10 const char* outfilename="foo.wav";
11
12 SndfileHandle outfile(outfilename, SFM_WRITE, format, channels, sampleRate);
13 if (not outfile) return -1;
14
15 // prepare a 3 seconds buffer and write it
16 const int size = sampleRate*3;
17 float sample[size];
18 float current=0.;
19 for (int i=0; i<size; i++) sample[i]=sin(float(i)/size*M_PI*1500);
20 outfile.write(&sample[0], size);
21 return 0;
22 }
but it gives an errors: undefined reference to 'sf_close' and undefined reference to 'sf_open'! I have added the sndfile.h file to the project folder. Do you know what is wrong?
Thank you
You have to link the libsndfile library
A camel can go 14 days without drink,
I can't!!!
How do I link it? Is it not enough to include the libsndfile.h in the project folder?
Cheers
If you use qmake you have to add this line to your .pro file
If you are compiling by hand with GCC you have to add "-lsndfile" to command line.
If you using other compiler refer to documentation for linking libraries.
A camel can go 14 days without drink,
I can't!!!
When I do so, Qt displays the following error:
: error: cannot find -lsndfile
Why is it happening?
Cheers
Please show us all relevant parts of your pro file.
It does not work. The project is running on a folder "C:\Qt\2010.04\qt\untitled2". I have added the .lib and the .h files to this folder. My .pro file is the following:
SOURCES += \
main.cpp
HEADERS += \
sndfile.h
LIBS += \
C:\Qt\2010.04\qt\untitled2\libsndfile-1.lib
It seems that Qt compiles the program well, but the application crashes imediatly, without doing anything. The messages left by the compiler are:
At the Application output:
"Starting C:\Qt\2010.04\qt\untitled2-build-desktop\debug\untitled2.exe...
C:\Qt\2010.04\qt\untitled2-build-desktop\debug\untitled2.exe exited with code -1073741515"
At the compile output:
"Running build steps for project untitled2...
Configuration unchanged, skipping qmake step.
Starting: "C:/Qt/2010.04/mingw/bin/mingw32-make.exe" -w
mingw32-make: Entering directory `C:/Qt/2010.04/qt/untitled2-build-desktop'
C:/Qt/2010.04/mingw/bin/mingw32-make -f Makefile.Debug all
mingw32-make[1]: Entering directory `C:/Qt/2010.04/qt/untitled2-build-desktop'
mingw32-make[1]: Nothing to be done for `all'.
mingw32-make[1]: Leaving directory `C:/Qt/2010.04/qt/untitled2-build-desktop'
C:/Qt/2010.04/mingw/bin/mingw32-make -f Makefile.Release all
mingw32-make[1]: Entering directory `C:/Qt/2010.04/qt/untitled2-build-desktop'
mingw32-make[1]: Nothing to be done for `all'.
mingw32-make[1]: Leaving directory `C:/Qt/2010.04/qt/untitled2-build-desktop'
mingw32-make: Leaving directory `C:/Qt/2010.04/qt/untitled2-build-desktop'
The process "C:/Qt/2010.04/mingw/bin/mingw32-make.exe" exited normally."
Is this an error with the code or is the libsndfile.lib not linked correctly?
Thank you
Hello,
I am having the exact same problem. I am trying to use libsndfile in a Qt project under windows. It seems to build fine but crashes on startup. Debugging doesnt seem to help because the crash occurs before entering the first line of the program. Very strange. Did you or anyone find a solution or figure out more about the cause?
Thanks,
Stijn.
Added after 25 minutes:
Hi again,
I went to
http://www.mega-nerd.com/tmp/
and downloaded the pre-release of libsndfile. That solved this problem for me!
Hope it will help you too.
Stijn.
Last edited by stijn; 26th November 2010 at 16:22.
Bookmarks