• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

A Couple Questions in One!

I have a few questions that I would like to be answered:

1.)  Is there a way to make sound in Visual C++ and if so, is there some sort of guide anywhere that would show me what to put in my program to play certain notes, and another follow up question, is it possibly to play more than one note at once or put pauses between notes so i can make an actual song?

-Wow.  That was a mouthfull.-

2.)  Is there anywhere that I could download Visual C++ so that I could work on projects at my house and not just at school?

Thanks

Mark
0
simpsons17371
Asked:
simpsons17371
  • 5
  • 5
  • 2
  • +2
1 Solution
 
ExceterCommented:
>> Is there anywhere that I could download Visual C++ so that I could work on projects at my house and not just at school?

I'm afraid that would be a VERY illegal activity and it is therefore, a direct violation of the EE membership agreement.

Exceter
0
 
DarthNemesisCommented:
There's a version of Visual packaged with some textbooks called the Introductory Edition; it allows you to run programs through the compiler but not to generate executable files, and is legal to use at home. I don't know if you could find it online, but it's possible that your school may have received it. Only your teacher would know.
0
 
ExceterCommented:
>> There's a version of Visual packaged with some textbooks called the Introductory Edition; it allows you to run programs through the compiler
>> but not to generate executable files

Actually, it does allow you to build executable files. It simply pops up a little window stating the this program was compiled using the Introductory Edition and that it is illegal to distribute files generated with it. I know because that is what I use. It comes packaged with deitel and deitel's C++ How to program,

http://www.amazon.com/exec/obidos/tg/detail/-/0130384747/qid=1047707574/sr=8-1/ref=sr_8_1/002-3204003-0972054?v=glance&s=books&n=507846#product-details

Exceter
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
DarthNemesisCommented:
As for sounds, you have two options: either play sounds through the sound card, or beeps through the PC speaker. Either way, this site appears to have a plethora of examples:
http://www.synchrondata.com/pheaven/www/area25.htm#sub2
If you follow the link to Programmers Heaven, you can search for the actual files:
http://www.programmersheaven.com/search/advsearch.asp?SearchMode=1&SearchTxt1=pc+speaker
0
 
RihamCommented:
As for sounds, u can check the following SDK function BOOL PlaySound(
  LPCSTR pszSound,  
  HMODULE hmod,    
  DWORD fdwSound    
);

the first paramater will be your file name, the second "NULL" the third will be your flags.

SND_ASYNC The sound is played asynchronously and PlaySound returns immediately after beginning the sound. To terminate an asynchronously played waveform sound, call PlaySound with pszSound set to NULL.

SND_FILENAME The pszSound parameter is a filename.

SND_LOOP The sound plays repeatedly until PlaySound is called again with the pszSound parameter set to NULL. You must also specify the SND_ASYNC flag to indicate an asynchronous sound event.

SND_NODEFAULT No default sound event is used. If the sound cannot be found, PlaySound returns silently without playing the default sound.

SND_NOSTOP The specified sound event will yield to another sound event that is already playing. If a sound cannot be played because the resource needed to generate that sound is busy playing another sound, the function immediately returns FALSE without playing the requested sound.
If this flag is not specified, PlaySound attempts to stop the currently playing sound so that the device can be used to play the new sound.
 
SND_PURGE Sounds are to be stopped for the calling task. If pszSound is not NULL, all instances of the specified sound are stopped. If pszSound is NULL, all sounds that are playing on behalf of the calling task are stopped.
You must also specify the instance handle to stop

SND_SYNC Synchronous playback of a sound event. PlaySound returns after the sound event completes.
0
 
SalteCommented:
first off,

There's no support for sound in C++. The point is that this question is not a question about language it is a question about platform.

On any platform that support sound and also support a C++ compiler there is also most likely support for sound for that C++ compiler for that platform.

In Windows there's DirectX which gives you total access to sound card. If you want only the PC speaker the OS also have - or had - some support for that. YOu can still access the PC speaker by sending codes to it. It might be a problem though that in Win2000 or WinXP or WinNT you are not allowed to do IN and OUT but I do believe there is a PC speaker driver that you can use to communicate with it and send tones.

In Linux on PC both sound cards and the PC speaker are available through drivers so by sending commands to drivers you can get sound on your computer.

In non PC computers there's also often either a sound card or a simple speaker or both which can be accessed through sending commands to a driver.

How you send commands to a driver is also platform specific, under Unix/Linux/FreeBSD etc you do that by the system call ioctl(). Under windows you can do it using the Win32 function call DeviceIoControl(). Other systems have similar manners to send commands to drivers.

Your question is very much platform specific and it therefore also follows that your other questions cannot be answered either. If you can play two or more notes at the same time depends on the platform. If you have only a simple speaker you cannot do that but with a soundcard you typically can.

Also, using a speaker you can make it sound as if you play two or more notes at the same time. It requires ingenious use of the speaker and the ability to rapidly sending it a bunch of commands in a sequence. If you make it alternate between two frequencies very fast it will sound as if it is playing two separate notes at the same time to a human ear.

Also, assuming that people who ask platform specific questions to a forum which isn't platform specific are people who use PC and windows (a likely assumption - most people who use other systems are usually aware of what is platform specific and what isn't - for some reason PC users are surprisingly often not aware of such a distinction). I can assume you're using windows and in that case the answers to your questions is:

Use DirectX if you want full control of the soundcard. This is what games and multi media software uses.

Use simple Win32 functions if you want simple control to play system sounds or beeps.

Use PC speaker if you want the speaker to sound. On WinNT, Win2000 or WinXP you need to use a driver since you can't do IN and OUT instructions directly. Use DeviceIoControl to send commands to the driver.

Hope this answers your question.

Alf
0
 
simpsons17371Author Commented:
so i guess that clears everything up...thanks guys!!!
0
 
simpsons17371Author Commented:
i went and i got Microsoft Visual C++ and i installed it on my computer but when i did that i tried to write just a simple program and run it...but ever time i do that it says:

Compiling...
Error spawning cl.exe

what does that mean and how can i fix it, i have tried everything
0
 
DarthNemesisCommented:
This question has been asked before - here's a link to it:
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_10228022.html

Microsoft also has some advice concerning it:
http://support.microsoft.com/default.aspx?scid=KB;en-us;q188720

From what I read it may come down to reinstalling Visual C++, so have that CD ready (assuming you did obtain a legal copy... o¿ô ).
0
 
DarthNemesisCommented:
The site apparently doesn't like my ascii values... oh well, disregard the last word.
0
 
simpsons17371Author Commented:
i did get the version legally if u are implying that i didnt... that is why i asked if there was a way to get it without paying, noticing there was none, i went and bought it that day

those sites didnt do much for me but thanks anyway, i will uninstall and then re-install and get back to all of you guys

Mark
0
 
DarthNemesisCommented:
Okay, okay, sorry for implying anything. =)

Anyway, hope reinstalling will work out.
0
 
simpsons17371Author Commented:
yeah so do i... i m starting the process like right now because i felt like eating dinner first, if it doesnt work i m gonna ask my teacher if he knows anything about it.

Mark
0
 
simpsons17371Author Commented:
Oh my God it worked!!!!!!!!!!!!! I am so happy it took me a long time to do it but it finally works.

Thank you for the help I am most grateful.

If I have anymore problems I will probably post them here, I dont have enough points to post another question...lol

Mark
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 5
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now