The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Need your advice on Windows Audio/Music APIs

Hi folks,

I am working on a c++ windows app.
I need to play music files.
It is a normal desktop app (NOT a game).

The user selects a couple of music files and I should play them. I should be able to
- control the volume
- start and stop (in the middle of) the music

It is important to support the usual audio formats (the more the better). Because the user may select any music file and I have no control.

I support vista and xp (nice to have 2000)

Which api(s) do you recommend?

I appreciate your help.
Thursday, June 26, 2008
Ease of deployment is also important.

The application is downloadable so I prefer to keep it as small as possible.
Thursday, June 26, 2008

The de facto multimedia API for windows is DirectShow.

This is a subcomponent of DirectX that handles all multimedia stuff like encoding, decoding, rendering etc etc.

An extended version of this API is called DES ( DirectShow Editing Services ) that lets you do just about anything that Windows Movie Maker does.

Its all COM based and has a "filter graph" model ...
You have com objects called filters which have any number of output or input "Pins". You connect these filters together like components of an electornic circuit and set it in motion to do the task at hand.

So for example , lets say you need to play an mp3 sound file...
You start by creating a "Filter Graph" COM object. Then you ask the system to add a filter that can read the file.
This causes a Filter with one output pin to get added to the graph, the pin supplies data in whatever format the file happens to specify. You can then instruct the system to "render" the output pin of that source filter, The system will look in the registry for the right kind of decoders etc ( in this case it will put in an MPEG parser filter, followed by a MPEG audio decoder and finally a default directsound renderer filter ).
Now you have a graph built up, you can start stop, pause, and seek the graph.
Many formats are decodable by default ( Windows comes built in with many filters ) and there are zillions of 3rd party encoders decoders etc etc.

There is a tool called "graphedit" that lets you do this graph building in a visual way. Once you have the hang of how filter graphs work, you can easily write a program that does all kinds of multimedia tasks very simply.

Its a nice API and model , the only learning curve factor is because of COM. In fact I have a nice little wrapper library (free) that takes the teething pains out of directshow programming.
Available at

tmhare's site is a great resource for directshow programmers of all levels.

I've been doing mostly directshow based work for the past 3 years.

email me if you want more information or help
Vivek N Send private email
Saturday, June 28, 2008
I've used the bass library successfully in the past:
Joel Coehoorn Send private email
Monday, June 30, 2008

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz