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; Sadly, many mobo's and cases don't have much for built in speakers. Mine has a tiny "speaker" type of thing ...

  1. #16
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Sadly, many mobo's and cases don't have much for built in speakers. Mine has a tiny "speaker" type of thing about 1/2 inch around on the mobo. (no internal speaker on the case). When I run this program on it, it does play the sound, but it sounds faint, and rather tinny, reflecting the tiny size of the mobo speaker.

    But that's the speaker's limitation, not the program's. This is on a WindowsXP box, btw.

    For better sound, you'll have to either get a real internal PC speaker (about 3 inches across), and connect it to your mobo, or get the output of the program routed out to your external speakers.

    Does anyone know how to do the latter?

  2. #17
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    > rob, I have seen what you wrote somewhere but how do i control the sound? (if you can give me more details).
    Code:
    void beep_num_times(int num)
    {
        int i;
        for (i=0; i<num; i++)
            putchar('\a');
        return;
    }
    That's about as much control as you're gonna get.

  3. #18
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    ok thanks.
    humm first of all mat, the speaker do was connected (I am not so fool XD)
    ya I know.
    have I mantioned that I want my program to run on linux too (I forgot the word)

    Adak, you are a little bit complicated XD

    rob, I got you.
    by the way it's better to use delay instead of the "for"

    ohh and the sound doesn't have to be heard trough the speakers, It can be heard trough the processor..

  4. #19
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    by the way it's better to use delay instead of the "for"
    Erm, a delay does something different from a loop. If you want to play more than one beep you will need a loop. Maybe with varying delay times.

  5. #20
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by gavra View Post
    ohh and the sound doesn't have to be heard trough the speakers, It can be heard trough the processor..
    The processor doesn't emit sounds... unless you blow it up.

  6. #21
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by gavra View Post
    ok thanks.
    humm first of all mat, the speaker do was connected (I am not so fool XD)
    ya I know.
    have I mantioned that I want my program to run on linux too (I forgot the word)

    Adak, you are a little bit complicated XD

    rob, I got you.
    by the way it's better to use delay instead of the "for"

    ohh and the sound doesn't have to be heard trough the speakers, It can be heard trough the processor..
    In the early days of PC's , they had a small 2 or 3 inch speaker inside the case, which connected to your motherboard. It wasn't great for music, but you could play monaural (1 channel, no stereo), music on it. I still remember the great sounds of the game "Prince of Persia" on it.

    Today, they have a VERY small speaker on the mobo, itself. It's about 1/2 around with a small hole in the middle for the sound to get out. It plays music, but it doesn't equal the sound of the old PC internal speakers. It WILL still play music at low or high frequencies, and for different lengths of time, though.

    So with the right programming, you could have it play your favorite music, but it wouldn't sound like a good stereo would sound, believe me.

    Your processor sends the stream of commands to the speaker, so it can play sounds, but the cpu itself, can not play any sounds.

    A "beep" or '\a' in C, is just a beep - it is not sound that can be used to play music. It's just noise. Beep and sound should not be confused, or mentioned together, except to note that a beep is not a single pitch (frequency), of sound. Sound and beep are very different things.
    Last edited by Adak; 06-02-2008 at 04:44 PM.

  7. #22
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > It plays music, but it doesn't equal the sound of the old PC internal speakers.
    In other words, the world of technology is traveling backwards

    If you want to play sounds I suggest you use normal speakers -- the Beep() API isn't supported in Vista x64 anyway.

    Bubba has already suggested OpenAL, which I'd recommend -- or libbass or fmod.

  8. #23
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    why the program that Adak brought me and the program that Rob brought me doesn't work?!

    "A "beep" or '\a' in C, is just a beep - it is not sound that can be used to play music"
    that's what I am traing to do, I don't wanna play music..

    zac what you brought me isn't simple at all, I just want to "play" frequency.

  9. #24
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by gavra View Post
    why the program that Adak brought me and the program that Rob brought me doesn't work?!
    Because there is something missing in your hardware setup? If your system doesn't have a speaker (or the speaker is not connected, broken, etc), then you are not going to get a sound out of it.

    If your system has a sound card [or in a modern system, more likely built in equivalent of] (speakers connected to the back of the machine), then you could perhaps use MessageBeep with -1 as the input. No control over frequency here, tho'.

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

  10. #25
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    yo dude I got confused @_@
    Everything seems to be ok, I use my speakers everyday..
    and what is the difference between "beep" and "messagebeep"?

  11. #26
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    There is a difference between "the speakers" and "the PC speaker". The latter is a speaker inside your PC case. the former is where the sound comes from when playing an Audio CD or an MP3.

    The main difference between MessageBeep is that it plays the sound in "the speakers" (except if you don't have a sound card and you use -1 for input - in which case it uses "the PC speaker"). Beep on the other hand is using "the PC speaker" all the time.

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

  12. #27
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    Thank you for the patients.
    So I need the "beep" function.
    but as I mentioned in my last post - it doesn't work

  13. #28
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    You don't have Vista x64 do you? If so then it won't work.

    Otherwise you could be playing a frequency that you can't hear or the speaker can't play.

  14. #29
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    Beep() is definitely the wrong path to take. You've been told how to do what you want. Perhaps heeding some of the suggestions and trying them out would be better than insisting they are not right for you....without having tried them.

  15. #30
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    Nope, I don't use vista at all, I use XP but I am planning to stop this "bad habbit" and use linux.
    Give me a frequency that I can hear, so I'll try again.

    I need the whole code for an example so I could understand, cause as I said I don know API or what ever you wrote.

    thanks again.

Page 2 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, 11: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, 05:02 AM
  3. DirectX Question
    By bladerunner627 in forum Game Programming
    Replies: 2
    Last Post: 04-04-2005, 12:55 PM
  4. Game Programming FAQ
    By TechWins in forum Game Programming
    Replies: 5
    Last Post: 09-29-2004, 03:00 AM
  5. graphics and sound
    By gcn_zelda in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2003, 08:23 PM

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