Attachment 'testfmod.c'

Download

   1 /***************************************************************************
   2  *   Copyright (C) 2009 by Salokine Terata   *
   3  *   salokine.terata@free.fr   *
   4  *                                                                         *
   5  *   This program is free software; you can redistribute it and/or modify  *
   6  *   it under the terms of the GNU General Public License as published by  *
   7  *   the Free Software Foundation; either version 2 of the License, or     *
   8  *   (at your option) any later version.                                   *
   9  *                                                                         *
  10  *   This program is distributed in the hope that it will be useful,       *
  11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
  12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
  13  *   GNU General Public License for more details.                          *
  14  *                                                                         *
  15  *   You should have received a copy of the GNU General Public License     *
  16  *   along with this program; if not, write to the                         *
  17  *   Free Software Foundation, Inc.,                                       *
  18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  19  ***************************************************************************/
  20 
  21 
  22 #include <stdlib.h>
  23 #include <stdio.h>
  24 //Inclusion de la librairie FMOD nouvellement installée
  25 #include <fmod.h>
  26 
  27 int main ()
  28 {
  29 	/*******************************************
  30   DECLARATION DES VARIABLES
  31         *******************************************/
  32 	// $sound est le sample que nous allons essayer de lire
  33   FSOUND_SAMPLE *$sound = NULL;
  34 
  35 	// $isFmodInit permet de savoir si le système de son FMOD à pu correctement s'initialiser
  36   int $is_fmod_init = 0;
  37 
  38 	// Sous Debian, il est recommandé de redéfinir la sortie audio par défaut de FMOD.
  39 	// Sinon, il y a risque de conflit sur l'accès matériel avec d'autre système de son.
  40 	// Ici on dit à FMOD de travailler sur la couche ALSA et non directement sur le matériel audio
  41   FSOUND_SetOutput ( FSOUND_OUTPUT_ALSA );
  42 
  43 	/*******************************************
  44   TEST D'INITIALISATION
  45         *******************************************/
  46 	// $is_fmod_init récupére le résultat de l'initialisation de FMOD
  47   $is_fmod_init = FSOUND_Init ( 44100, 32, 0 );
  48   if ( $is_fmod_init )
  49   {
  50     fprintf ( stderr, "FMOD initialisé\n" );
  51   }
  52   else
  53   {
  54     fprintf ( stderr, "FMOD n'a pas pu démarrer:\n" );
  55     fprintf ( stderr, " - Contrôler votre système de son\n" );
  56     fprintf ( stderr, " - Votre matériel audio ne serait-il pas utilisé par un autre logiciel ? \n" );
  57     exit ( EXIT_FAILURE );
  58   }
  59 
  60 	/*******************************************
  61   TEST DE LECTURE
  62         *******************************************/
  63 	// $sound récupère le chargement du fichier audio.
  64 	// Veillez à ce que ce fichier soit présent dans le même répertoire que le binaire
  65   $sound = FSOUND_Sample_Load ( FSOUND_FREE, "test.wav", 0, 0, 0 );
  66   if ( $sound == NULL )
  67   {
  68     fprintf ( stderr, "Impossible de lire test.wav\n" );
  69     fprintf ( stderr, " - Vérifier la présence du fichier dans le même répertoire que le programme\n" );
  70     exit ( EXIT_FAILURE );
  71   }
  72   else
  73   {
  74     fprintf ( stderr, "Lecture en cours de test.wav ...\n" );
  75     FSOUND_PlaySound ( FSOUND_FREE, $sound );
  76   }
  77   fprintf ( stderr, "Arret du test dans 5 secondes ...\n" );
  78 
  79 	// On laisse 5 secondes d'écoute
  80   sleep ( 5 );
  81 
  82 	/*******************************************
  83   LIBERATION DES RESSOURCES
  84         *******************************************/
  85   FSOUND_Sample_Free ( $sound );
  86   FSOUND_Close();
  87 
  88   return EXIT_SUCCESS;
  89 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-01-07 21:26:59, 3.7 KB) [[attachment:testfmod.c]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.