Results 1 to 14 of 14

Thread: Wav Files

  1. #1
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Wav Files

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Wav Files

    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!!!

  3. The following user says thank you to mcosta for this useful post:

    Maluko_Da_Tola (17th September 2010)

  4. #3
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Wav Files

    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

  5. #4
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Wav Files

    You have to link the libsndfile library
    A camel can go 14 days without drink,
    I can't!!!

  6. #5
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Wav Files

    How do I link it? Is it not enough to include the libsndfile.h in the project folder?

    Cheers

  7. #6
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Wav Files

    If you use qmake you have to add this line to your .pro file
    Qt Code:
    1. LIBS += -lsndfile
    To copy to clipboard, switch view to plain text mode 

    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!!!

  8. #7
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Wav Files

    When I do so, Qt displays the following error:

    : error: cannot find -lsndfile

    Why is it happening?

    Cheers

  9. #8
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Wav Files

    Please show us all relevant parts of your pro file.

  10. #9
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Wav Files

    you also have to add -L/path/to/libsnd/ in your pro file

  11. #10
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Wav Files

    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

  12. #11
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Wav Files

    Quote Originally Posted by Maluko_Da_Tola View Post
    It does not work.
    Please explain

  13. #12
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Wav Files

    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

  14. #13
    Join Date
    Nov 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Wav Files

    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.

  15. #14
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Wav Files

    Quote Originally Posted by Maluko_Da_Tola View Post
    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 did some audio processing projects using without problems fmod.
    It has many features and a very good quality. You can download the ex version here.
    Regards
    Franco Amato

Similar Threads

  1. Replies: 9
    Last Post: 28th April 2010, 09:18
  2. Replies: 1
    Last Post: 11th November 2009, 12:22
  3. Replies: 12
    Last Post: 17th June 2009, 05:34
  4. visual studio project files - adding extra files
    By luf in forum Qt Programming
    Replies: 3
    Last Post: 13th June 2008, 21:05
  5. how to save sequences of text files and sound files
    By nagpalma in forum Qt Programming
    Replies: 8
    Last Post: 3rd July 2007, 00:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.