Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

C programming - How can we play audio in C console application?

I want to create a simple software that will simulate a piano, but in Dos mode. I'm going to let the user input the notes (C,D,E,F,G,A,B) and associate a different sound file with each note. when user inputs a string of random notes, I want the application to play the sound files accordingly. But I don't know how to use an audio clip in C programming. (Please note that this must be done in C. not in C++)

Can somebody help me with this please?

5 Answers

Relevance
  • ?
    Lv 4
    7 years ago
    Favorite Answer

    I had done that when I was a kid in the programming world :D

    I used sound() and delay() functions. A quick Google search led to the following page.

    http://cprogg.blogspot.com/2011/10/use-of-sound-an...

    If you do not already know about reading/writing binary files then you will need to know that as well. 'b' is one of the mode used with the fopen function.

  • Anonymous
    4 years ago

    C Console Application

  • Anonymous
    5 years ago

    Create an class that has the variables listed above. Declare those variables as public (although in real world applications you wouldn't want to do this). In your main, you would create a new instance of the class that you created. Then using readline and writeline, you would display prompts asking for the information. Save each of the information into the corresponding class variables. Then after all information has been entered, you would use writeline to display all the values of each of the class variables on the screen. The proper way to get and set class variables is to use getter and setter functions. The getter returns the value of the variable and the setter takes in an argument and sets that argument equal to the class variable. I do know how to code this application, but I don't render such services for free.

  • 7 years ago

    C by design has limited default input/output functions. The standard does not include audio or graphics. This is true of C++ as well. For both you need third party libraries. Try allegro:

    http://alleg.sourceforge.net/

  • 5 years ago

    I would like to ask the same question as the person above.

Still have questions? Get your answers by asking now.