Sounds in a game

This is a discussion on Sounds in a game within the C Programming forums, part of the General Programming Boards category; Hello everyone! I'm taking a programming class (introduction to C language) and for the final project we are writing the ...

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    1

    Sounds in a game

    Hello everyone!
    I'm taking a programming class (introduction to C language) and for the final project we are writing the code for a game.
    My knowledge is pretty basic since this is a introductory class but still, to get some extra points (IN EXTREME NEED OF THAT ) I have to add some "frills", and one of the things I was thinking about was to add sounds, somehow (I already googled it but couldn't find anything).
    Do you know by any chance if there's any sound function/command in the stdio.h or any other c library and how could I implement that in my code?
    Again, nothing fancy please, I'm just a beginner!
    Thank you in advance for your contribution.

    PS: Feel free to suggest any simple frills that you may know.
    Thanks again!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,505
    The only sound you can get from a standard C program is to ring the terminal bell.
    Code:
    putchar('\a');
    fflush(stdout);
    However, this doesn't always work - terminals (and windows consoles) can be configured to be silent, even when the program emits a \a

    Standard C is very very simple in it's I/O capabilities (no sound, no graphics).
    If you want something fancy, then you need to say which operating system and compiler you're using.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Look up OpenAL or FMOD.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by kikika View Post
    Hello everyone!
    I'm taking a programming class (introduction to C language) and for the final project we are writing the code for a game.
    My knowledge is pretty basic since this is a introductory class but still, to get some extra points (IN EXTREME NEED OF THAT ) I have to add some "frills", and one of the things I was thinking about was to add sounds, somehow (I already googled it but couldn't find anything).
    Do you know by any chance if there's any sound function/command in the stdio.h or any other c library and how could I implement that in my code?
    Again, nothing fancy please, I'm just a beginner!
    Thank you in advance for your contribution.

    PS: Feel free to suggest any simple frills that you may know.
    Thanks again!
    If you are on a Windows machine, and have a set of Windows headers and libs you can do this...

    Code:
    #include <windows.h>
    #include<mmsystem.h>
    
    // beep bop and burble
    Beep(1000,100);  
    
    // play actual music and effects
    Playsound("MyNoise.wav",NULL,SND_FILENAME);
    Read more here --> PlaySound

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. .WAV Sounds
    By C-Compiler in forum Windows Programming
    Replies: 1
    Last Post: 02-04-2009, 10:58 PM
  2. sounds in game
    By Gordon in forum Windows Programming
    Replies: 7
    Last Post: 10-07-2008, 10:14 AM
  3. Ads with sounds
    By ober in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 03-30-2005, 10:38 AM
  4. Sounds
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 04-17-2003, 06:27 AM
  5. sounds?
    By BODYBUILDNERD in forum C++ Programming
    Replies: 6
    Last Post: 12-06-2002, 02:34 PM

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