C++/c++ coding to control all hardware
coming to my question directly-
can i give any beep sound to my audio out put(speakers, not the one on mother board) and scan a beep signal from audio input(Mick) by coding in c++?
or suggest me any other language to do this.
I presume that you mean via your audio hardware - sound card or integrated audio on the motherboard.
The answer is:
a) No. Not using ISO standard C++ as it has no idea what hardware will be available on all the types of system that C++ is designed to be used on - telephone exchange hardware for example probably has no such audio requirements. Hence the standard library supports general utilities such as collection types, maths functions, and stream IO with support for memory and file streams.
On the other hand there is an alert (or bell) escape code for C and C++ character and string literals which you may be able to get to beep through your main audio speakers. It is output using the C/C++ literal character escape code '\a' (a for alert), so you could try:
std::cout << '\a' << std::endl;
(it did not work using Visual C++ 2008 under Vista 64 bit but did using g++ 4.2.4 under Ubuntu 8.04 64 bit running in a virtual machine on the same system - go figure. So your mileage may vary.)
b) Yes if you have operating system support, the development files required to access these facilities or a third party library that wraps them for you. E.g. on a PC running a MS Windows operating system you could look at the DirectSound portion of the DirectX libraries or maybe the older audio multimedia APIs (Application Program Interface) or even the Beep Win32 API function (although this did not work on my system and might beep through the PC speaker!). In order to utilise the DirectX API you would require the DirectX SDK (Software Development Kit). To do general Windows programming you require the Windows Platform SDK (or a third party equivalent - such as the header files and libraries provided by the MinGW project).
For more on the various Microsoft support options for audio see the Microsoft developer network (MSDN) and the MSDN library. This can be found online at:
( you might like to try searches like: "audio recording". I found I had to add refinements to restrict the results to:
Win32 & COM Windows, Graphics and Multimedia Library, Documentation & Articles
to get an initial useful set of results. You might like to try "audio directx" as another starter.
Note: b) also requires you to have device driver support for the hardware and operating system in question, and have it successfully installed and operating.
You will notice that in order to do what you want from a modern desktop operating system you do not hit the hardware directly but go through operating system APIs and a device driver:
[Application Program]- uses ->[operating system audio APIs]- uses ->[device driver]- accesses ->[hardware]
In some cases you may find that the hardware manufacturer will provide their own SDK that has additional features specific to their hardware. Hopefully this is less needed these days.
As to possible other languages - C is an obvious first thought as many operating systems have C APIs anyway. Then of course any language that can use system C APIs - which could include FORTRAN, Visual Basic etc. or newer managed environments such as Java which seems to have a sound API (http://java.sun.com/products/java-media/sound/
) and .NET which may have some audio support in the framework (I noticed references to managed DirectX articles in some of the search results I got on MSDN). For .NET C# would be an obvious choice of language but there are now quite a few languages built around .NET. I would not be surprised if there are ways to access such base system audio facilities from most languages - however you would have to check first how easy it is (e.g. has someone done the work to interface the facilities to the language in question already? Is there an easy way to access such facilities from within the language in question? Etc.)
If you have no operating system or an operating system that lets you have direct access to the hardware such as MS-DOS then you can of course hit the hardware directly - but you _will_ have to have a very intimate knowledge of the exact specification of the hardware and its setup on your motherboard to do this and you may need to use assembler as well as C or C++ to get things up and running (some C and C++ implementations have extra features to support hardware access and maybe even inline assembler). If you change your motherboard for one with different hardware or wish to use a shiny new sound card's capabilities then you will have to learn the specifics of the new hardware and re-work your code to work with it. Basically you will have to have the knowledge that is used by device driver writers - and this level of information may not be made publicly available by the audio hardware vendor. Either that or use vendor supplied libraries / drivers (in case of some operating system support).
All in all I would say it is much easier to let an operating system and device driver for your hardware take care of much of these details for you and concentrate on coding to operating system APIs directly or through an even easier to use (depending on what you are trying to do) library.
Hope this has helped a bit.