Thread: gernerating sound from motherboard

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    76

    gernerating sound from motherboard

    Hi fellas ,

    I want to know how to generate sound or ring tone via cpu like the way we did in Borland
    turbo C complier's sound(),delay() and nosound() functions.

    I am using devC++ and want to know libraries by which we can play with motherboard
    and generate ring-tones.


    best regards,
    Chakra
    Last edited by CChakra; 01-30-2009 at 12:36 AM. Reason: forgot to add word 'know'

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Windows Beep(int hz, int duration) will do the combination of sound() and delay().

    http://msdn.microsoft.com/en-us/libr...77(VS.85).aspx

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    76
    thanks for quick reply.

  4. #4
    Registered User QuestionKing's Avatar
    Join Date
    Jan 2009
    Posts
    68
    ...and thanks for the link for those who browse other people's questions for learning new tricks...

  5. #5
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    if you're looking for something besides a simple tone like a beep, the waveout functions are *fairly* straightforward. i'd be happy to share the code i've written for using them, but it's still in a scratchpad kind of state - not elegant whatsoever.

  6. #6
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    Just a warning in case Beep() doesn't work as expected...

    I remember that Beep() has some strange "if" conditions. I seem to remember that if you have a soundcard installed, you'll just get the "Windows default sound" from your soundcard-speakers... But, that may only happen with some Windows versions (maybe it was only a problem with Win98 or WinNT ???).

    The old Turbo C functions won't work because the new Windows versions (newer than Win98) don't allow user mode programs to directly access hardware. (You need to access hardware through a kernel-mode driver.)

  7. #7
    Registered User
    Join Date
    Sep 2008
    Posts
    76
    M37h0d : thank you so much for help.

    please give or pm any code you have regarding generating ring tones.

    DougDbug : thanks for the info.

    However , I did the same way what DougDbug explained here but was not impressive tone.
    I want to create some the movie 'mission impossible' like ring-tones.

    I was wondering how to do calculation to generate sounds.I did some random stuffs.

  8. #8
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    UNTESTED (since I'm not running Windows) -
    Code:
    #include <iostream>
    #include <windows.h>
    
    void b() {
    	std::cout << '\a' << std::endl;
    }
    
    int main() {
    	while (true) {
    		b();
    		Sleep(1500);
    		b();
    		Sleep(1500);
    		b();
    		Sleep(500);
    		b();
    		Sleep(500);
    	}
    }
    Is that Mission Impossible?... either that or Batman or Spiderman.

  9. #9
    Registered User
    Join Date
    Sep 2008
    Posts
    76
    I tried to play with assembly language to generate sounds but it's a big pain in neck.I don't
    want to remember horrible instructions to generate a simple ring tone. LOL

    So I want the calculation tips to generate sounds.Please provide me any charts or something
    like that.

    best regards,
    Chakra

  10. #10
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    Why assembly?...

    If you want to generate "real" music, you'll probably need to use some sort of a sound library.

  11. #11
    Registered User
    Join Date
    Sep 2008
    Posts
    76
    I am on .net bro , I want to have fun with PC internal speaker.I am using Beep() function
    via Dll-import technic of C#.I am not even using c++ .... I am just converting yours
    tips to C#.Currently I have no serious reasons to use c++ exclusively because my job lies
    to web and commercial application development.I love c/c++ but I got no time to play with.Maybe in future ,I will battle with only on c++ grounds.

    Why I tried to play with assembly I don't even know why.Even the program did not compile
    on my system and I don't want to know why. LOL

    best regards,
    Chakra

  12. #12
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    So I can play guitar tones using these 'beep's' ? Like, can I pitch the sound xP that'd be kinda cool, even tho Guitar Pro is already made, and is prolly easier to use than this xD
    Currently research OpenGL

  13. #13
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Quote Originally Posted by Akkernight View Post
    So I can play guitar tones using these 'beep's' ? Like, can I pitch the sound xP that'd be kinda cool, even tho Guitar Pro is already made, and is prolly easier to use than this xD
    Sorry to interrupt this thread, but what the h377 is xP and why does it riddle every post you make????
    Mainframe assembler programmer by trade. C coder when I can.

  14. #14
    Registered User
    Join Date
    Jan 2008
    Posts
    70

    XP

    I think he's doing the emoticon XP with a lower case x so it doesn't look quite right.

  15. #15
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    Quote Originally Posted by cyberfish View Post
    Why assembly?...

    If you want to generate "real" music, you'll probably need to use some sort of a sound library.
    as i said before, the windows wave* functions are really pretty straightforward.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sound lags in multi-thread version
    By VirtualAce in forum Game Programming
    Replies: 23
    Last Post: 08-27-2008, 11:54 AM
  2. Low latency sound effects
    By VirtualAce in forum Game Programming
    Replies: 0
    Last Post: 12-21-2004, 01:58 AM
  3. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  4. DirectSound - multiple sounds
    By Magos in forum Game Programming
    Replies: 9
    Last Post: 03-03-2004, 04:33 PM
  5. sounds?
    By BODYBUILDNERD in forum C++ Programming
    Replies: 6
    Last Post: 12-06-2002, 03:34 PM