can I play a wav file in c++

Hello all,
I am trying to find out if I can play a wav file in my program,
I am using C++ in VI on SunOS.
Thanks for your help
It's easiest to use an external library to interface with your sound card. Look up OpenAL for a good audio library.
why not try mp3 to stay current. Of course I too would like to see the cpp command line/function call to make the LinuxPC play all my guitarRecordings(now all wma because Windows assimilates them.) Is VI? VIM or GVIM like- Developement?
I really hate mp3. It's such a hassle and confusing thing to figure out the legal implications of adding mp3 encoding and decoding functionality to a program due to software patents.

You can use libsndfile to read most file types with the exception of mp3 (due to legal issues) into PCM data which you can then play with openAL.

If you want mp3 functionality, you can use mpg123 to decode, and lame to encode, but in a commercial application, you need to comply with mp3 law or else they might go after you.

Or you could use a library like BASS or FMOD, which I think have mp3 functionality although they are not free for commercial use.

I wish ogg would become the standard.

Ogg Vorbis is a free and open audio encoding format.


The designers of the MP3 format claim that they can charge royalties for any software or file that uses their format.In the US, the last patent will expire in 2017.


Many claim that the 128kbps encoding for MP3 and Ogg Vorbis are similar in quality while Ogg Vorbis is better than MP3 at 192kbps. Ogg Vorbis is much better than MP3 at very low bitrates (64kbps, etc).


Ogg supports more than 2 channels - up to 256. Mp3 supports 2 discrete channels, as well as "Joint Stereo" which, briefly stated, seeks to use commonalities of the two stereo channels to reduce the amount of data needed to store the audio stream.

So you can see Ogg is better than mp3 in pretty much every way. I would encourage people to use mp3 formats as little as possible.

Licensing and patent issues

Many organizations have claimed ownership of patents related to MP3 decoding or encoding. These claims have led to a number of legal threats and actions from a variety of sources, resulting in uncertainty about which patents must be licensed in order to create MP3 products without committing patent infringement in countries that allow software patents.
The various MP3-related patents expire on dates ranging from 2007 to 2017 in the U.S.[52] The initial near-complete MPEG-1 standard (parts 1, 2 and 3) was publicly available on December 6, 1991 as ISO CD 11172.[53][54] In the United States, patents cannot claim inventions that were already publicly disclosed more than a year prior to the filing date, but for patents filed prior to June 8, 1995, submarine patents made it possible to extend the effective lifetime of a patent through application extensions. Patents filed for anything disclosed in ISO CD 11172 a year or more after its publication are questionable; if only the known MP3 patents filed by December 1992 are considered, then MP3 decoding may be patent free in the US by September 2015 when U.S. Patent 5,812,672 expires which had a PCT filing in Oct 1992.[55][56][57]
Technicolor (formerly called Thomson Consumer Electronics) claims to control MP3 licensing of the Layer 3 patents in many countries, including the United States, Japan, Canada and EU countries.[58] Technicolor has been actively enforcing these patents.[59]
MP3 license revenues generated about €100 million for the Fraunhofer Society in 2005.[60]
In September 1998, the Fraunhofer Institute sent a letter to several developers of MP3 software stating that a license was required to "distribute and/or sell decoders and/or encoders". The letter claimed that unlicensed products "infringe the patent rights of Fraunhofer and Thomson. To make, sell and/or distribute products using the [MPEG Layer-3] standard and thus our patents, you need to obtain a license under these patents from us."[61]
However, there exist both free and/or proprietary alternatives, with free formats such as Vorbis, FLAC, and others. Microsoft's usage of its own proprietary Windows Media format allows it to avoid licensing issues associated with these patents by avoiding usage of the MP3 format entirely. Until the key patents expire, unlicensed encoders and players could be infringing in countries where the patents are valid.
In spite of the patent restrictions, the perpetuation of the MP3 format continues. The reasons for this appear to be the network effects caused by:
familiarity with the format
the large quantity of music now available in the MP3 format
the wide variety of existing software and hardware that takes advantage of the file format and does not support the alternatives
the lack of DRM restrictions, which makes MP3 files easy to edit, copy and play in different portable digital players (Apple, Creative, Samsung, etc.)
the majority of home users not knowing or not caring about the patents' existence and often not considering such legal issues when choosing their music format for personal use
Additionally, patent holders declined to enforce license fees on free and open source decoders, which allows many free MP3 decoders to develop.[citation needed]
Sisvel S.p.A. and its U.S. subsidiary Audio MPEG, Inc. previously sued Thomson for patent infringement on MP3 technology,[62] but those disputes were resolved in November 2005 with Sisvel granting Thomson a license to their patents. Motorola also recently signed with Audio MPEG to license MP3-related patents.
In September 2006, German officials seized MP3 players from SanDisk's booth at the IFA show in Berlin after an Italian patents firm won an injunction on behalf of Sisvel against SanDisk in a dispute over licensing rights. The injunction was later reversed by a Berlin judge,[63] but that reversal was in turn blocked the same day by another judge from the same court, "bringing the Patent Wild West to Germany" in the words of one commentator.[64]
In February 2007, Texas MP3 Technologies sued Apple, Samsung Electronics and Sandisk in eastern Texas federal court, claiming infringement of a portable MP3 player patent that Texas MP3 said it had been assigned. Apple and Sandisk both settled the claims against them in January 2009.[65] Samsung settled as well.[66]
Alcatel-Lucent has asserted several MP3 coding and compression patents, allegedly inherited from AT&T-Bell Labs, in litigation of its own. In November 2006, before the companies' merger, Alcatel sued Microsoft for allegedly infringing seven patents. On February 23, 2007, a San Diego jury awarded Alcatel-Lucent US $1.52 billion in damages for infringement of two of them.[67] The court subsequently tossed the award, however, finding that one patent had not been infringed and that the other was not even owned by Alcatel-Lucent; it was co-owned by AT&T and Fraunhofer, who had licensed it to Microsoft, the judge ruled.[68] That defense judgment was upheld on appeal in 2008.[69] See Alcatel-Lucent v. Microsoft for more information.
Last edited on
Topic archived. No new replies allowed.