generate sound in c++

Technical Discussions not Related Directly to MHS. For Example, Coding, Hex Editing, General Hacking, Etc.

Moderators: g3nuin3, SpeedWing, WhiteHat

generate sound in c++

Postby Spleshmen » Thu Feb 18, 2010 8:51 pm

how can i generate a sound at a certain frequency for a certain time using c++.
i dont have a PC speaker so beep() is out of the question :) thanks
Spleshmen
Hackleberry Fin
 
Posts: 24
Joined: Thu Mar 06, 2008 9:01 pm

Re: generate sound in c++

Postby L. Spiro » Fri Feb 19, 2010 6:44 am

Beep() plays through the PC speaker in Windows 7 only.
That means you are on Windows 7.

http://www.windowsreference.com/windows ... old-style/


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Re: generate sound in c++

Postby Spleshmen » Fri Feb 19, 2010 5:33 pm

i am using windows xp sp 3 and i am sayng that i dont have a pc speaker so i can not use beep()
Spleshmen
Hackleberry Fin
 
Posts: 24
Joined: Thu Mar 06, 2008 9:01 pm

Re: generate sound in c++

Postby L. Spiro » Fri Feb 19, 2010 6:36 pm

Replace beep.sys as mentioned before or create an OpenAL library for this purpose.


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Re: generate sound in c++

Postby CoMPMStR » Sun Feb 21, 2010 4:30 am

Well if your motherboard is hooked up right, and has a speaker (which I'm sure it does), it should play just fine without any external speakers. Just like if you hold down all the arrow keys at once on your keyboard, the beep comes from your motherboard and not the speakers. Mine works just fine and I'm using WinXPsp3 as well.

Check out this source and see if it doesn't help. It uses Beep() and for me plays from the motherboard and not my external speakers. Courtesy of Google, second result in the list. ;)
Image

______________________________________________________
My Utilities:
CT <-> LSSAVE Converter
LSS Visual Dialog Designer
.NET Trainer Helper Library

~Whether you think you can or you think you can't, you're right.

L. Spiro wrote:In my left hand is a red pill. If you take it I will show you the truth. I lost my right hand in the war, so I’m afraid you’re stuck with the red pill.
User avatar
CoMPMStR
(P)ot (I)n (M)y (P)ipe
 
Posts: 451
Joined: Thu Mar 06, 2008 7:50 am
Location: Best Place

Re: generate sound in c++

Postby L. Spiro » Sun Feb 21, 2010 8:49 am

I assume by “PC Speaker” he means the motherboard speaker.
Apparently he ripped it off or something, and wants sound through his sound card speakers.


L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Re: generate sound in c++

Postby CoMPMStR » Sun Feb 21, 2010 9:19 am

My mistake, I assumed the opposite. Anytime anyone I know personally refers to a "PC Speaker" they are talking about the speakers plugged into their sound card. :oops:

If this helps any, on this page there are some sources for a MIDI senthesizer and a PlaySound() function that allows playing wav files though the sound card (although it's for Borland, it's still C++). Here's a C++ sound generator for VC2005 that generates sounds from mathematic formulas, it uses DirectSound to play the sound. Also something else that may or may not be of use, if all else fails.
Image

______________________________________________________
My Utilities:
CT <-> LSSAVE Converter
LSS Visual Dialog Designer
.NET Trainer Helper Library

~Whether you think you can or you think you can't, you're right.

L. Spiro wrote:In my left hand is a red pill. If you take it I will show you the truth. I lost my right hand in the war, so I’m afraid you’re stuck with the red pill.
User avatar
CoMPMStR
(P)ot (I)n (M)y (P)ipe
 
Posts: 451
Joined: Thu Mar 06, 2008 7:50 am
Location: Best Place

Re: generate sound in c++

Postby Spleshmen » Mon Feb 22, 2010 8:53 pm

L. Spiro wrote:Replace beep.sys as mentioned before or create an OpenAL library for this purpose.


L. Spiro

ah so you are sayng to replace my windows xp sp3 beep.sys file with the file beep.sys from windows 7 becose in windows 7 the beep function generates sound directly from the speekers and not from the motherboard speaker,right?
CoMPMStR i dont have a motherboard speaker,i did not known the right term for this thats why i was calling it PC speaker :D
my english is bad,sorry
Spleshmen
Hackleberry Fin
 
Posts: 24
Joined: Thu Mar 06, 2008 9:01 pm

Re: generate sound in c++

Postby jungletek » Sat Mar 06, 2010 2:44 pm

Don't apologize... if you ask me, he's got it backwards. I've always known the cheap little speaker on your pc case or motherboard to be the PC speaker. It's the one that makes a beep when you boot.
jungletek
I Have A Few Questions
 
Posts: 5
Joined: Thu May 07, 2009 1:25 am


Return to Technical Unrelated

Who is online

Users browsing this forum: No registered users and 0 guests

cron