CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Aug 2009
    Posts
    27

    Ogg Vorbis encoding

    Dear experts,

    I have an MFC application. I have audio data stored in bytes within a custom file. My question is, how can I encode an array of those bytes into an ogg vorbis format? Is there any example that would help me?

    Thanks.

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Ogg Vorbis encoding

    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Aug 2009
    Posts
    27

    Re: Ogg Vorbis encoding

    Thank you very much for your answer. Could you please tell me or give me an example how this can be integrated into my mfc application?
    I didn't mention that my audio is in wav format.
    Thanks.
    Last edited by dpreznik; March 2nd, 2011 at 08:35 AM.

  4. #4
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Ogg Vorbis encoding

    I'm sorry but I have no ogg vorbis experience but the page has some links to the documentation (like this one http://xiph.org/ogg/doc/) so you should be able to find what you want there.

    Google for "wav format specification" and you get a ton of links. The first one I got is a good start I think https://ccrma.stanford.edu/courses/4...ts/WaveFormat/
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Ogg Vorbis encoding

    Xiph.org provides directshow filters that can be used for compression. So the task ends in building trivial directshow graph, adding filters, connecting pins, etc.
    Best regards,
    Igor

  6. #6
    Join Date
    Aug 2009
    Posts
    27

    Re: Ogg Vorbis encoding

    Thank you SMA and Igor,

    Quote Originally Posted by Igor Vartanov View Post
    Xiph.org provides directshow filters that can be used for compression. So the task ends in building trivial directshow graph, adding filters, connecting pins, etc.
    Alas, all these things are new to me. I don't know what directshow filters, directshow graph, connecting pins, etc. are.
    I found an example:
    http://svn.xiph.org/trunk/vorbis/exa...oder_example.c
    and tried to use it in my application. First, I tried to add it to my project and compile. I had to add files included in the above file, so I found them in the libraries libvorbis and libogg. And still I cannot link:
    Error 4 error LNK2019: unresolved external symbol _oggpack_writetrunc referenced in function _vorbis_bitrate_addblock bitrate.obj
    Error 2 error LNK2019: unresolved external symbol _oggpack_write referenced in function _vorbis_bitrate_addblock bitrate.obj
    Error 8 error LNK2019: unresolved external symbol _oggpack_read referenced in function _vorbis_staticbook_unpack codebook.obj
    Error 10 error LNK2019: unresolved external symbol _oggpack_look referenced in function _decode_packed_entry_number codebook.obj
    Error 7 error LNK2019: unresolved external symbol _oggpack_get_buffer referenced in function _vorbis_bitrate_flushpacket bitrate.obj
    Error 5 error LNK2019: unresolved external symbol _oggpack_bytes referenced in function _vorbis_bitrate_addblock bitrate.obj
    Error 9 error LNK2019: unresolved external symbol _oggpack_adv referenced in function _decode_packed_entry_number codebook.obj
    Error 3 error LNK2001: unresolved external symbol _oggpack_write codebook.obj
    Error 6 error LNK2001: unresolved external symbol _oggpack_bytes codebook.obj

    I could not find where those guys are defined.
    I would appreciate any help.

    Thanks,
    Dmitriy

  7. #7
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Ogg Vorbis encoding

    Did you link with both libOgg & libVorbis?

    Just to be sure I post this as well:
    Project properties / Linker / Input / Additional Dependencies is where you add the name of the libs to be linked.
    Project properties / Linker / General / Additional Library Directories is where you add the search path for the libraries.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  8. #8
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Ogg Vorbis encoding

    Alas, all these things are new to me. I don't know what directshow filters, directshow graph, connecting pins, etc. are.
    So, this only means you have a lot of things to learn.
    Best regards,
    Igor

  9. #9
    Join Date
    Aug 2009
    Posts
    27

    Re: Ogg Vorbis encoding

    Quote Originally Posted by Igor Vartanov View Post
    So, this only means you have a lot of things to learn.
    Do I really have to? For me, it is only one episode, I may never face such a task again. That's why I tried to find just a working example that I could use immediately. I am afraid it may be too time consuming to study a new science.

  10. #10
    Join Date
    Aug 2009
    Posts
    27

    Re: Ogg Vorbis encoding

    I compiled both libogg and libvorbis as static libraries. I created "bin" directory in my project folder and placed there libvorbis_static.lib and libvorbisfile_static.lib. Also, I created in the bin directory libvorbis folder, and an include folder in it, and placed there vorbis (with codec.h, vorbisfile.h, vorbisenc.h) and ogg (with os_types.h and ogg.h) folders. I added libvorbis_static.lib to additional dependencies of my project and the bin folder to Additional Library Directories.
    When I am trying to compile, I get errors:
    1>libvorbis_static.lib(info.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
    1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _free already defined in libcmtd.lib(dbgfree.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _calloc already defined in libcmtd.lib(dbgcalloc.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _malloc already defined in libcmtd.lib(dbgmalloc.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _realloc already defined in libcmtd.lib(dbgrealloc.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _memmove already defined in libcmtd.lib(memmove.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _ldexp already defined in libcmtd.lib(_ldexp_.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _qsort already defined in libcmtd.lib(qsort.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _ceil already defined in libcmtd.lib(_ceil_pentium4_.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _exit already defined in libcmtd.lib(crt0dat.obj)
    1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in libcmtd.lib(typinfo.obj)
    1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info:perator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in libcmtd.lib(typinfo.obj)
    1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
    1>BookDoc.obj : error LNK2001: unresolved external symbol _ogg_stream_clear
    1>BookDoc.obj : error LNK2001: unresolved external symbol _ogg_page_eos
    1>BookDoc.obj : error LNK2001: unresolved external symbol _ogg_stream_pageout
    1>BookDoc.obj : error LNK2001: unresolved external symbol _ogg_stream_flush
    1>BookDoc.obj : error LNK2001: unresolved external symbol _ogg_stream_packetin
    1>BookDoc.obj : error LNK2001: unresolved external symbol _ogg_stream_init
    1>libvorbis_static.lib(info.obj) : error LNK2001: unresolved external symbol _oggpack_readinit
    1>libvorbis_static.lib(info.obj) : error LNK2001: unresolved external symbol _oggpack_bytes
    1>libvorbis_static.lib(info.obj) : error LNK2001: unresolved external symbol _oggpack_writeclear
    1>libvorbis_static.lib(info.obj) : error LNK2001: unresolved external symbol _oggpack_read
    1>libvorbis_static.lib(info.obj) : error LNK2001: unresolved external symbol _oggpack_reset
    1>libvorbis_static.lib(info.obj) : error LNK2001: unresolved external symbol _oggpack_write
    1>libvorbis_static.lib(info.obj) : error LNK2001: unresolved external symbol _oggpack_writeinit
    1>libvorbis_static.lib(bitrate.obj) : error LNK2001: unresolved external symbol _oggpack_writetrunc
    1>libvorbis_static.lib(bitrate.obj) : error LNK2001: unresolved external symbol _oggpack_get_buffer
    1>libvorbis_static.lib(codebook.obj) : error LNK2001: unresolved external symbol _oggpack_adv
    1>libvorbis_static.lib(codebook.obj) : error LNK2001: unresolved external symbol _oggpack_look
    1>.\Debug/Book.exe : fatal error LNK1120: 17 unresolved externals

    I am confused. Could you please help?
    Thanks.
    Last edited by dpreznik; March 7th, 2011 at 11:52 AM.

  11. #11
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Ogg Vorbis encoding

    Do I really have to?
    How could I know?
    For me, it is only one episode, I may never face such a task again.
    ...or may have a lot. Getting along with directshow programming opens such a lot of opportunities (any playback/encoding/transcoding media task commonly used here and there in contemporary apps), of course if you stay stick with Windows. Anyway, right now it's all up to you.

    I am confused. Could you please help?
    Unresolved externals typically means you include not all the libraries needed by the build. Already defined may mean runtime model mismatch.
    Best regards,
    Igor

  12. #12
    Join Date
    Apr 2013
    Posts
    4

    Re: Ogg Vorbis encoding

    Hello.
    To get a ogg vorbis example was difficult but i finely go an example working.
    the example is test.c. The exact location is libvorbis-1.3.3/ test/ test.c .
    The other example was so buggy i gave up on it.
    I did it on linux system at the consul. I compiled with this line:

    gcc test.c -lvorbis -lvorbisenc -lvorbisfile -o test


    And had to add these includes:

    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>

    #include "util.h"
    #include "util.c"
    #include "write_read.h"
    #include "write_read.c"

    and remove the line 66 which is " remove (filename);"
    This program will give a good working example on the encoder.

    I have another example I made my self and will post it if asked.
    It generates two differnt pcm sine waves in memory then encodes it
    and save it to the hard drive. The ogg file will play a 200hz wave out of left head phone
    and 1000hz out the other.
    And now i am working on third example to take a saved wav file on hard drive and on convert
    it to ogg file and save it on the hard drive.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured