How to play an audio in Language C

3

If you can help me, I am doing an Electronic Ballot in the C language, I would like to put that voting noise after a person votes.

I already have that sound in .mp3 and .wav format, how do I reproduce this sound after a vote? Do you have any specific libraries?

    
asked by anonymous 30.11.2016 / 10:55

2 answers

3

You can use a library, which will make it easier to develop.

Example with FMOD

#include <conio.h>
#include "inc/fmod.h"

FSOUND_SAMPLE* handle;

int main ()
{
   // init FMOD sound system
   FSOUND_Init (44100, 32, 0);

   // load and play mp3
   handle=FSOUND_Sample_Load (0,"my.mp3",0, 0, 0);
   FSOUND_PlaySound (0,handle);

   // wait until the users hits a key to end the app
   while (!_kbhit())
   {
   }

   // clean up
   FSOUND_Sample_Free (handle);
   FSOUND_Close();
}

Source: Font

    
30.11.2016 / 12:07
1

In addition to those that have already been mentioned, there are those that make WAV files playback with SDL_mixer:

  • SDL (Simple DirectMedia Layer)
  • SDL_mixer

See more here . / p>     

30.11.2016 / 14:20