Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2009
    Location
    Lithuania, Europe
    Posts
    66

    How to incorporate sound into console?

    I want to know is there any function in standart c++ to incorporate sound in simple console application. Maybe iwant to do this with my evil monkeys game.

  2. #2
    Join Date
    Mar 2006
    Location
    South Australia
    Posts
    4,521
    No. Remember that the standard library available in C++ is fairly limited compared to .net, java, etc. If you want sound in your C++ program you need to pick a sound API to use (DirectSound, OpenAL, gmixer, SDL, etc).

    There are many sound APIs available on different platforms, and plenty of cross platform ones. But no one C++ standard sound API.

  3. #3
    Join Date
    Aug 2009
    Location
    Lithuania, Europe
    Posts
    66
    But ex.: DirectSound won't work in console?

  4. #4
    Join Date
    Mar 2005
    Posts
    939
    Sound in the console? You can always try this:
    Code:
    #include <stdio.h>
    
    int main(void) {
    
      printf("%c\n", 0x07);
    
      return 0;
    }
    "I don't WANT to pet the chicken."

  5. #5
    Join Date
    Jun 2003
    Location
    Trier, Germany
    Posts
    1,350
    Quote Originally Posted by Kaktusas2598 View Post
    But ex.: DirectSound won't work in console?
    DirectSound needs a window handle, which can be a pain to obtain for a Console application.

    However, there are reasons why you should avoid DirectSound in the first place. I'd strongly recommend the use of OpenAL. We had a discussion on Sound APIs not too long ago in another thread.

  6. #6
    Join Date
    Jan 2006
    Location
    Denmark, Europe
    Posts
    1,446
    I recommend FMOD..

    The samples/tutorials that follows with it has sound files playing of console.
    Mossa "Nova" Merhi

  7. #7
    Join Date
    Apr 2004
    Posts
    224

    Question Different PC Speaker Beep Tones?

    Quote Originally Posted by pellea72 View Post
    Sound in the console? You can always try this:
    Code:
    #include <stdio.h>
    
    int main(void) {
    
      printf("%c\n", 0x07);
    
      return 0;
    }
    Is this the standard PC speaker beep escape character or is the a way to change the printf() parameters to play different PC speaker beep tones?
    DH Software Home Page: http://www12.brinkster.com/dhpc1024/index.html

    DH Game Development Home Page: http://www12.brinkster.com/dhpc1024/dhgd_index.html



    3D Buzz Starcraft 2 Community Tournament Participant. Year: 2011


  8. #8
    Join Date
    Jun 2003
    Location
    Trier, Germany
    Posts
    1,350
    0x07 is the ASCII 'Bell' character, which is interpreted as a single beep by many terminal emulators.
    however, what this line actually does is entirely up to the environment. you cannot tell what sound will be played, whether it will be played through the internal speaker or a sound card, or if it will be played at all.

    the c++ standard does not cover the pc-speaker, so you will have to consider your system's manual. e.g. on windows there exists an api function Beep(), while unix-style system usually offer a virtual device for this purpose.

  9. #9
    Join Date
    Mar 2006
    Location
    South Australia
    Posts
    4,521
    And of course, any Unix user who wants to refrain from throwing something through his monitor has the system bell turned off in his console.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •