diff --git a/INSTALL b/INSTALL index d9f4de29..e8c1f2fc 100644 --- a/INSTALL +++ b/INSTALL @@ -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: diff --git a/pokerth.pro b/pokerth.pro index 50e8510f..d68c7054 100755 --- a/pokerth.pro +++ b/pokerth.pro @@ -256,7 +256,7 @@ win32{ } unix{ - LIBS += -lboost_thread -lcrypto + LIBS += -lboost_thread -lcrypto -lSDL_mixer } macx{ diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index 9bf62ce2..5f80e034 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -49,10 +49,17 @@ #include +//SOUND TESTING +// #include "SDL.h" +// #include "SDL_mixer.h" +//SOUND TESTING + #define FORMATLEFT(X) "

(X)" #define FORMATRIGHT(X) "(X)

" + + 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); + + } + + diff --git a/src/gui/qt/mainwindow/mainwindowimpl.h b/src/gui/qt/mainwindow/mainwindowimpl.h index 094076cd..65febae6 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.h +++ b/src/gui/qt/mainwindow/mainwindowimpl.h @@ -30,6 +30,9 @@ #include #include +#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 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; }; diff --git a/src/gui/qt/resources.qrc b/src/gui/qt/resources.qrc index 77eea62d..ee731066 100755 --- a/src/gui/qt/resources.qrc +++ b/src/gui/qt/resources.qrc @@ -72,6 +72,7 @@ resources/data/preflopValues resources/data/flopValues + resources/data/beep.ogg resources/fonts/VeraBd.ttf diff --git a/src/gui/qt/resources/data/beep.ogg b/src/gui/qt/resources/data/beep.ogg new file mode 100644 index 00000000..1c8d2741 Binary files /dev/null and b/src/gui/qt/resources/data/beep.ogg differ