I would like to make a program that would allow the user to make music based on various inputs, including numbers. All my serching of the help system of c++ builder left me with no results on how to play a single sound, or how to tell the computer in one command (preferably) to play this instrument, this pitch, this duration and possibly some other parameters. As far as I remember some older computers and languages used to have a PLAY command which looked something like this: PLAY(x,y,z etc). Is something like that possible in C++? Searching the net it seems that the answer might be in calling a windows API to do that. But which API? Can anyone show me an example, some links or leads? thanks, mosnik PS I do not speak here of making professional music, but not of using standard BEEP function either...
Hi, I think that a long, long, long time ago you could "play" certain frequencies through the PC speaker or serial line, but it was terrible sounding and YOU had to "tune" the interface. Today I think it would be a lot easier to learn to use the API for the MIDI chip on your sound card. There is lots of music in midi files already on the internet.
thanks for the leads, I will try around but something tells me that this is going to be a difficult task since direct manipulation of midi is a very specialised field, as fas as I know.
The documentation for Windows audio can be found at this link: http://msdn2.microsoft.com/en-us/library/aa830466.aspx I've not done any audio/video programming for Windows so I can't offer any help about how to do it, but this info should at least get you started.
Thanks for the lead, I followed it and got a bit scared of the size of the material! Anyway, for some time I will be studying it to see if I will be able to use it. Thanks again,
hello techme, i have answer to your question There is one way which i know .YOu have to use a manipulator for it i.e. \a. cout<<"Beep sound \a"; With the use og \a you can hear a sound YOu can give as many \a you want
I've been playing around with beep - I know you said more than beep, not not professional -- so I think this may work; using beep(freq, time) you can set the frequency and length of time the beep is set - this gives limited control but it's easy. Cheers, Code: #include <iostream.h> #include <windows.h> void scale(void) { Beep(523,400); // 523 hertz (C5) for 400 milliseconds Beep(587,400); Beep(659,400); Beep(698,400); Beep(784,400); Beep(698,400); Beep(659,400); Beep(587,400); Beep(523,400); } int main() { scale(); cout << "Scale completed.\n"; return 0; }
If you are looking for really good stuff of how to deal with sound, consider Microsoft DirectSound. Please get DirectX sdk (use google to find it), install it and see examples of how to use DirectSound.