Important alert: (current site time 7/15/2013 5:31:31 PM EDT)
 

VB icon

^!Play music directly to PC's Internal Speaker

Email
Submitted on: 2/6/2004 5:24:01 AM
By: my name is Nitin Jindal (from Panchkula,Haryana)  
Level: Intermediate
User Rating: By 17 Users
Compatibility: C, C++ (general)
Views: 50424
(About the author)
 
     Play music directly to PC's Internal Speaker
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: ^!Play music directly to PC's Internal Speaker
// Description:Play music directly to PC's Internal Speaker
// By: my nameis Nitin Jindal (from Panchkula,Haryana)
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=7587&lngWId=3//for details.//**************************************

/** Play music directly to PC's Internal Speaker PLEASE VOTE FOR ME ! Nitin Jindal */
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <conio.h>
main()
{
float octave[7]={130.81,146.83,164.81,174.61,196.220,246.94};
int adn;
while(!kbhit())
{
adn=random(7);
sound(octave[adn]*10);
delay(190);
nosound();
}}


Other 5 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

3/15/2004 1:59:36 AM

While compling the program I got three error messages :-
1) Call to undefined function 'sound'
2) Call to undefined function 'delay'
3) Call to undefined function 'nosound'

I'm new to programming. Can anyone help me to run this program ??
(If this comment was disrespectful, please report it.)

 
4/25/2004 11:28:57 AMEric Gilbert Sondraal

doesn't work for me too.
(If this comment was disrespectful, please report it.)

 
6/6/2004 4:07:03 AM

this code is written for djgpp compiler only. by the way, the array doesn´t have a length of 7. you can use the windows function Beep(freq, duration) instead.
(If this comment was disrespectful, please report it.)

 
7/9/2004 6:06:06 PM

In which file is the Beep function,so that i include it?
(If this comment was disrespectful, please report it.)

 
8/28/2004 6:57:45 PM

this is old dos code, the Beep() function only works properly on windows NT and some XP machines. for the proper way to do this check out http://invisionfree.com/forums/CPPlearningcommunity/index.php?showtopic=294
(If this comment was disrespectful, please report it.)

 
11/10/2004 1:21:12 AM

Hi Nitin I'm also from panchkula U have worked very well on C and I really appreciate ur work
(If this comment was disrespectful, please report it.)

 
12/31/2004 12:15:58 AM

it was good
(If this comment was disrespectful, please report it.)

 
5/7/2005 2:31:00 PM

I have submitted another file- Music.h get it: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=9354&lngWId=3
(If this comment was disrespectful, please report it.)

 
7/31/2005 11:25:59 AMVaibhav

Coooool! real cooool!
i like it.
(If this comment was disrespectful, please report it.)

 
9/7/2006 7:32:43 AMbalaji

good
(If this comment was disrespectful, please report it.)

 
12/10/2006 6:37:41 AMchhuong

I think you are clever.I hope you will be a best programmer.
(If this comment was disrespectful, please report it.)

 
5/3/2007 6:30:07 PMzerocool

thank you..
but it will be more interesting if you change random by a real song

(If this comment was disrespectful, please report it.)

 
12/2/2007 8:05:35 PMsam

The Beep function is in the windows.h
If you use it, remember it starts with a capital B.
syntax(frequency in Hz, duration in ms);
frequency range is 37 Hz to 32767 Hz.
(If this comment was disrespectful, please report it.)

 
12/20/2007 1:28:43 AMbiren

send c,c++,vb,vb.net programs will be send on my email id ,please
(If this comment was disrespectful, please report it.)

 
3/3/2008 4:12:15 PMonur

hi

(If this comment was disrespectful, please report it.)

 
10/9/2008 12:03:33 AMramesh

yes it's nice and simple
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.