add sound-system SDL_mixer

This commit is contained in:
doitux
2007-05-29 12:22:05 +00:00
parent 7c147dccc6
commit bc63661d96
6 changed files with 75 additions and 2 deletions
+1
View File
@@ -7,6 +7,7 @@ Linux:
- Qt version >= 4.2.3 --> http://trolltech.com/
- libcrypt (e.g. version 0.9.7) --> http://www.openssl.org/
- libboost_thread (e.g. version 1.33) --> http://www.boost.org/
- libSDL_mixer, libSDL --> http://www.libsdl.org/
Windows:
+1 -1
View File
@@ -256,7 +256,7 @@ win32{
}
unix{
LIBS += -lboost_thread -lcrypto
LIBS += -lboost_thread -lcrypto -lSDL_mixer
}
macx{
+57 -1
View File
@@ -49,10 +49,17 @@
#include <net/socket_msg.h>
//SOUND TESTING
// #include "SDL.h"
// #include "SDL_mixer.h"
//SOUND TESTING
#define FORMATLEFT(X) "<p align='center'>(X)"
#define FORMATRIGHT(X) "(X)</p>"
using namespace std;
mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
@@ -621,12 +628,34 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
// playerNameLabelArray[1]->setText(QString::fromUtf8(myConfig->readConfigString("Opponent1Name").c_str()));
//SOUNDTESTING
audio_rate = 44100;
audio_format = AUDIO_S16; /* 16-bit stereo */
audio_channels = 2;
audio_buffers = 4096;
music = NULL;
SDL_Init(SDL_INIT_AUDIO);
if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) {
printf("Unable to open audio!\n");
exit(1);
}
Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
//SOUNDTESTING
}
mainWindowImpl::~mainWindowImpl() {
delete myConfig;
myConfig = 0;
//SOUND TESTING
Mix_CloseAudio();
SDL_Quit();
}
void mainWindowImpl::callNewGameDialog() {
@@ -2468,7 +2497,7 @@ void mainWindowImpl::keyPressEvent ( QKeyEvent * event ) {
if (event->key() == Qt::Key_F10) { switchLeftToolBox(); }
if (event->key() == Qt::Key_F11) { switchRightToolBox(); }
// if (event->key() == Qt::Key_F) { switchFullscreen(); } //f
if (event->key() == Qt::Key_S) { myChat->checkInvisible(); } //f
if (event->key() == Qt::Key_S) { playSound(); } //s
if (event->key() == 16777249) {
pushButton_break->click();
ctrlPressed = TRUE;
@@ -2561,3 +2590,30 @@ void mainWindowImpl::networkGameModification() {
}
void mainWindowImpl::musicDone() {
Mix_HaltMusic();
Mix_FreeMusic(music);
music = NULL;
}
void mainWindowImpl::playSound() {
cout << "play now" << endl;
/* Actually loads up the music */
music = Mix_LoadMUS("beep.ogg");
/* This begins playing the music - the first argument is a
pointer to Mix_Music structure, and the second is how many
times you want it to loop (use -1 for infinite, and 0 to
have it just play once) */
Mix_PlayMusic(music, 0);
/* We want to know when our music has stopped playing so we
can free it up and set 'music' back to NULL. SDL_Mixer
provides us with a callback routine we can use to do
exactly that */
// Mix_HookMusicFinished(mainWindowImpl::musicDone);
}
+15
View File
@@ -30,6 +30,9 @@
#include <QtGui>
#include <QtCore>
#include "SDL/SDL.h"
#include "SDL/SDL_mixer.h"
class Log;
class Chat;
class ConfigFile;
@@ -250,6 +253,11 @@ public slots:
void localGameModification();
void networkGameModification();
//SOUND TESTING
void playSound();
void musicDone();
private:
boost::shared_ptr<GuiInterface> myServerGuiInterface;
@@ -379,6 +387,13 @@ private:
// statistic testing
int statisticArray[15];
//sound testing
int audio_rate;
Uint16 audio_format;
int audio_channels;
int audio_buffers;
Mix_Music *music;
friend class GuiWrapper;
};
+1
View File
@@ -72,6 +72,7 @@
<qresource prefix="/data" >
<file>resources/data/preflopValues</file>
<file>resources/data/flopValues</file>
<file>resources/data/beep.ogg</file>
</qresource>
<qresource prefix="/fonts" >
<file>resources/fonts/VeraBd.ttf</file>
Binary file not shown.