The most interesting question of the day?

I was wondering how audio and video input/output was possible. Does iostream support this? If not, how would I go upon doing this?
Video is not that important, but I am really interested in learning how to accept audio input/output. Please explain in terms someone relatively new to programming would understand.
If you know any good tutorials, please suggest them.
I am on a Mac and on netbeans, but also have a windows PC, so I can work on both systems, PREFERABLY the Mac.
Thanks for all help, its really appreciated.
The C++ programming language, of which iostream is a part, has no concept of sound or video (or indeed, monitors, keyboards or mice).

As such, ultimately all C++ can do is ask (nicely) the operating system to do it. Having to learn every API for every practical operating system and hardware combination hasn't been necessary, thankfully, since the days of DOS.

These days, many people use a library or framework to handle it for them. You incorporate the library header files into your code, link against the library binaries, and in effect you ask the library/framework to do it for you, and the library/framework handles interacting with the operating system. You could do it yourself directly, by using the operating system's API; this has advantages and disadvantages and if you're juts starting out, I'd recommend using a framework as it will handle much of the fiddly parameter tweaking for you and let you just get on with making sound and video.

Accordingly, pick a library/framework and get coding! Popular around these parts, and for good reason, is the Simple and Fast Multimedia Library http://www.sfml-dev.org/

There are many more.

As an aside, it's possible on some operating systems to interact directly with hardware (such as sound) if that hardware device is represented as a file. On *nix, for example, under the /dev directory you might find something that looks like a file that you can send data to directly. I've never used something like that for anything more than fun jiggery-pokery.
Last edited on
You have to look up your operating system's documentation on how audio and video are done. C++ iostreams are C++ wrappers of file descriptors. Technically, if the operating system presents the audio card as a "special" file, then you could use iostreams to talk to it (linux does it this way for example).

However, iostreams are much more than just wrappers of file descriptors -- they are formatters as well. Formatting audio content doesn't make sense, so you end up paying runtime penalties for features of the iostreams you can't use.
Topic archived. No new replies allowed.