add sound-system SDL_mixer
This commit is contained in:
@@ -7,6 +7,7 @@ Linux:
|
|||||||
- Qt version >= 4.2.3 --> http://trolltech.com/
|
- Qt version >= 4.2.3 --> http://trolltech.com/
|
||||||
- libcrypt (e.g. version 0.9.7) --> http://www.openssl.org/
|
- libcrypt (e.g. version 0.9.7) --> http://www.openssl.org/
|
||||||
- libboost_thread (e.g. version 1.33) --> http://www.boost.org/
|
- libboost_thread (e.g. version 1.33) --> http://www.boost.org/
|
||||||
|
- libSDL_mixer, libSDL --> http://www.libsdl.org/
|
||||||
|
|
||||||
Windows:
|
Windows:
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -256,7 +256,7 @@ win32{
|
|||||||
}
|
}
|
||||||
|
|
||||||
unix{
|
unix{
|
||||||
LIBS += -lboost_thread -lcrypto
|
LIBS += -lboost_thread -lcrypto -lSDL_mixer
|
||||||
}
|
}
|
||||||
|
|
||||||
macx{
|
macx{
|
||||||
|
|||||||
@@ -49,10 +49,17 @@
|
|||||||
|
|
||||||
#include <net/socket_msg.h>
|
#include <net/socket_msg.h>
|
||||||
|
|
||||||
|
//SOUND TESTING
|
||||||
|
// #include "SDL.h"
|
||||||
|
// #include "SDL_mixer.h"
|
||||||
|
//SOUND TESTING
|
||||||
|
|
||||||
#define FORMATLEFT(X) "<p align='center'>(X)"
|
#define FORMATLEFT(X) "<p align='center'>(X)"
|
||||||
#define FORMATRIGHT(X) "(X)</p>"
|
#define FORMATRIGHT(X) "(X)</p>"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
|
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()));
|
// 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() {
|
mainWindowImpl::~mainWindowImpl() {
|
||||||
|
|
||||||
delete myConfig;
|
delete myConfig;
|
||||||
myConfig = 0;
|
myConfig = 0;
|
||||||
|
|
||||||
|
//SOUND TESTING
|
||||||
|
Mix_CloseAudio();
|
||||||
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void mainWindowImpl::callNewGameDialog() {
|
void mainWindowImpl::callNewGameDialog() {
|
||||||
@@ -2468,7 +2497,7 @@ void mainWindowImpl::keyPressEvent ( QKeyEvent * event ) {
|
|||||||
if (event->key() == Qt::Key_F10) { switchLeftToolBox(); }
|
if (event->key() == Qt::Key_F10) { switchLeftToolBox(); }
|
||||||
if (event->key() == Qt::Key_F11) { switchRightToolBox(); }
|
if (event->key() == Qt::Key_F11) { switchRightToolBox(); }
|
||||||
// if (event->key() == Qt::Key_F) { switchFullscreen(); } //f
|
// 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) {
|
if (event->key() == 16777249) {
|
||||||
pushButton_break->click();
|
pushButton_break->click();
|
||||||
ctrlPressed = TRUE;
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,9 @@
|
|||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
|
||||||
|
#include "SDL/SDL.h"
|
||||||
|
#include "SDL/SDL_mixer.h"
|
||||||
|
|
||||||
class Log;
|
class Log;
|
||||||
class Chat;
|
class Chat;
|
||||||
class ConfigFile;
|
class ConfigFile;
|
||||||
@@ -250,6 +253,11 @@ public slots:
|
|||||||
void localGameModification();
|
void localGameModification();
|
||||||
void networkGameModification();
|
void networkGameModification();
|
||||||
|
|
||||||
|
//SOUND TESTING
|
||||||
|
void playSound();
|
||||||
|
void musicDone();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
boost::shared_ptr<GuiInterface> myServerGuiInterface;
|
boost::shared_ptr<GuiInterface> myServerGuiInterface;
|
||||||
@@ -379,6 +387,13 @@ private:
|
|||||||
// statistic testing
|
// statistic testing
|
||||||
int statisticArray[15];
|
int statisticArray[15];
|
||||||
|
|
||||||
|
//sound testing
|
||||||
|
int audio_rate;
|
||||||
|
Uint16 audio_format;
|
||||||
|
int audio_channels;
|
||||||
|
int audio_buffers;
|
||||||
|
Mix_Music *music;
|
||||||
|
|
||||||
friend class GuiWrapper;
|
friend class GuiWrapper;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@
|
|||||||
<qresource prefix="/data" >
|
<qresource prefix="/data" >
|
||||||
<file>resources/data/preflopValues</file>
|
<file>resources/data/preflopValues</file>
|
||||||
<file>resources/data/flopValues</file>
|
<file>resources/data/flopValues</file>
|
||||||
|
<file>resources/data/beep.ogg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/fonts" >
|
<qresource prefix="/fonts" >
|
||||||
<file>resources/fonts/VeraBd.ttf</file>
|
<file>resources/fonts/VeraBd.ttf</file>
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user