Results 1 to 5 of 5

Thread: How to create sound files with C++

  1. #1
    Join Date
    Feb 2008
    Location
    readlink("/proc/self/exe"
    Beans
    1,120
    Distro
    Ubuntu Development Release

    Arrow How to create sound files with C++

    To create (=not play) sound files in Linux from your C++ program, you need to read the specification for each sound file, implement the usage of the specificatiion and then you're done.

    However, this is difficult and needs much time.

    Much simpler is the use of an audio library.
    For example: libsndfile

    You can find it here:
    http://www.mega-nerd.com/libsndfile/

    alsong with some sample programs:
    http://www.mega-nerd.com/libsndfile/tools/


    Usage it simple:
    install fftw (fast fourier transformation)
    Code:
     apt-get -y install fftw-dev libfftw3-dev
    ./configure
    make
    make install

    then the same for the tools
    In a world without walls and fences, who needs Windows and Gates?
    Linux is like a wigwam.... no Gates, no Windows but Apache inside!
    http://www.debianadmin.com
    apt-get install libstdc++6-4.3-doc

  2. #2
    Join Date
    Oct 2007
    Beans
    Hidden!

    Re: How to create sound files with C++

    How would you then use this library, say, to create a simple recording or to read a file to create a wave graph?

  3. #3
    Join Date
    Oct 2007
    Beans
    Hidden!

    Re: How to create sound files with C++

    I tried some examples included in source and got errors:

    Code:
    $ gcc sndfile-to-text.c
    /tmp/ccQcE1bj.o: In function `convert_to_text':
    sndfile-to-text.c:(.text+0x109): undefined reference to `sf_readf_float'
    /tmp/ccQcE1bj.o: In function `main':
    sndfile-to-text.c:(.text+0x26d): undefined reference to `sf_open'
    sndfile-to-text.c:(.text+0x295): undefined reference to `sf_strerror'
    sndfile-to-text.c:(.text+0x2cc): undefined reference to `sf_strerror'
    sndfile-to-text.c:(.text+0x334): undefined reference to `sf_close'
    collect2: ld returned 1 exit status
    I'm new with C/C++ but would like to get started.

  4. #4
    Join Date
    Oct 2007
    Beans
    Hidden!

    Re: How to create sound files with C++

    Had to compile differently.

    This configuration is sometimes needed:

    Code:
    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
    Compiling:

    Code:
    gcc sndfile-to-text.c `pkg-config --cflags sndfile` `pkg-config --libs sndfile` -o sndfile-to-text
    Then i could run:

    Code:
    ./sndfile-to-text somefile.wav somefile.txt
    Last edited by raulih; October 13th, 2009 at 11:52 AM.

  5. #5
    Join Date
    Feb 2008
    Location
    readlink("/proc/self/exe"
    Beans
    1,120
    Distro
    Ubuntu Development Release

    Wink Re: How to create sound files with C++

    Quote Originally Posted by raulih View Post
    How would you then use this library, say, to create a simple recording or to read a file to create a wave graph?
    It has a sample program that does just that...
    In a world without walls and fences, who needs Windows and Gates?
    Linux is like a wigwam.... no Gates, no Windows but Apache inside!
    http://www.debianadmin.com
    apt-get install libstdc++6-4.3-doc

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
  •