sound and graphics in C - recommandation needed

This is a discussion on sound and graphics in C - recommandation needed within the C Programming forums, part of the General Programming Boards category; In other words you haven't tried... Read the manual, it's pretty straight forward. It's not going to teach you C, ...

  1. #31
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    In other words you haven't tried...

    Read the manual, it's pretty straight forward. It's not going to teach you C, it will tell you how to use the API though.

  2. #32
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    I tried the sound function (borland).
    I'll try this too.

  3. #33
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    The borland code I posted, definitely works on WindowsXP --- if you have an internal speaker. You may need to take off the side of your case and get in a quiet room to hear it though. It is quite soft, if you have one of the modern type of speakers (the 1/2 inch around type).

  4. #34
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    My compiler (dev Cpp) doesn't recogonize the "DWORD"..

    Code:
    #include <windows.h>
    #include <winbase.h>
    
    BOOL WINAPI Beep(
      __in  DWORD dwFreq,
      __in  DWORD dwDuration
    );
    
    int main()
    {
         sound(100);
         delay(2000);
         nosound();
         getchar();
         return 0;
    }

  5. #35
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by gavra View Post
    My compiler (dev Cpp) doesn't recogonize the "DWORD"..

    Code:
    #include <windows.h>
    #include <winbase.h>
    
    BOOL WINAPI Beep(
      __in  DWORD dwFreq,
      __in  DWORD dwDuration
    );
    
    int main()
    {
         sound(100);
         delay(2000);
         nosound();
         getchar();
         return 0;
    }
    That's strange, as they should be declared in windows.h - and you shouldn't need to:
    1. Include winbase.h itself - it is part of windows.h
    2. give a prototype for Beep - it's declared in winbase.h which comes from windows.h

    --
    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.

  6. #36
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Code:
      __in  DWORD dwFreq,
      __in  DWORD dwDuration
    Did you mean to have two spaces before DWORD, or just one?

  7. #37
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Code:
    #include <windows.h>
    
    int main()
    {
         Beep(1000, 500);
         return 0;
    }
    certainly works on XP (I just tested it) when compiled with gcc-mingw 3.4.2.

    If that makes no sound when compiled with dev-c++ using gcc, then you haven't got a speaker inside your PC, or it's not connected correct (or something is broken in some other way).

    --
    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.

  8. #38
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Adak View Post
    Code:
      __in  DWORD dwFreq,
      __in  DWORD dwDuration
    Did you mean to have two spaces before DWORD, or just one?
    Why would that make ANY difference?

    --
    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.

  9. #39
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    ok.
    Humm "sound" "delay" and "no sound" doesn't work at all,I think they need "dos.h" and to be compiled with borland only.

    Anyway I tried this one:
    Code:
    #include <windows.h>
    
    int main()
    {
        int i;
        for (i=0;i<100000;i++)
         beep(i*10,200);
         getchar();
         return 0;
    }
    No errors or warnnings but I didn't hear any sound ):

  10. #40
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by gavra View Post
    ok.
    Humm "sound" "delay" and "no sound" doesn't work at all,I think they need "dos.h" and to be compiled with borland only.

    Anyway I tried this one:
    Code:
    #include <windows.h>
    
    int main()
    {
        int i;
        for (i=0;i<100000;i++)
         beep(i*10,200);
         getchar();
         return 0;
    }
    No errors or warnnings but I didn't hear any sound ):
    beep or Beep - note that C is case-sensitive, so "beep" and "Beep" are not the same function.

    And yes, Borland functions only work in a Borland compiler.

    --
    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.

  11. #41
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    Both of them can make only silence.
    I feel so stupid "><

    Have you tried to compile my code with your compiler?

  12. #42
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by gavra View Post
    Both of them can make only silence.
    I feel so stupid "><

    Have you tried to compile my code with your compiler?
    No, but aside from Beep instead of beep, I don't see anything wrong with it. I'm not going to subject my colleagues with an incrementally increasing frequncy from around 20Hz to 1MHz for several minutes either.

    The code I posted definitely does work on XP. But I suspect the problem is that your PC doesn't have a speaker.

    --
    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.

  13. #43
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    lol
    I don't expect you, me or anyone else to wait till the programm ends.
    When I am using Beep, where should the sound be heard from?
    From inside the comp' speakers or from my regular speakers?

  14. #44
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Inside the computer.

  15. #45
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    So how can I check if I have this speaker?

Page 3 of 4 FirstFirst 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Making great graphics
    By MadCow257 in forum Game Programming
    Replies: 1
    Last Post: 02-20-2006, 10:59 PM
  2. Project Lost Tomorrow recruiting Programmers and Sound Engineers
    By chewtoy in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 12-07-2005, 04:02 AM
  3. DirectX Question
    By bladerunner627 in forum Game Programming
    Replies: 2
    Last Post: 04-04-2005, 11:55 AM
  4. Game Programming FAQ
    By TechWins in forum Game Programming
    Replies: 5
    Last Post: 09-29-2004, 02:00 AM
  5. graphics and sound
    By gcn_zelda in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2003, 07:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21