Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F126726
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/util/music-player.cpp b/util/music-player.cpp
index c658dce7..65fd6e84 100644
--- a/util/music-player.cpp
+++ b/util/music-player.cpp
@@ -1,95 +1,126 @@
#include "music-player.h"
#include "globals.h"
#include <iostream>
+#include "configuration.h"
#ifdef USE_ALLEGRO
#include "dumb/include/aldumb.h"
#ifdef _WIN32
+/* what do we need winalleg for?
+ * reason: ...
+ */
#include <winalleg.h>
#endif
#endif
namespace Util{
+
+static double scaleVolume(double start){
+ return start * Configuration::getMusicVolume() / 100;
+}
MusicPlayer::MusicPlayer(){
}
MusicPlayer::~MusicPlayer(){
}
#ifdef USE_ALLEGRO
static const char * typeToExtension( int i ){
switch (i){
case 0 : return ".xm";
case 1 : return ".s3m";
case 2 : return ".it";
case 3 : return ".mod";
default : return "";
}
}
DumbPlayer::DumbPlayer(const char * path):
volume(1.0){
for (int i = 0; i < 4; i++){
/* the order of trying xm/s3m/it/mod matters because mod could be
* confused with one of the other formats, so load it last.
*/
switch (i){
case 0 : {
music_file = dumb_load_xm_quick(path);
break;
}
case 1 : {
music_file = dumb_load_s3m_quick(path);
break;
}
case 2 : {
music_file = dumb_load_it_quick(path);
break;
}
case 3 : {
music_file = dumb_load_mod_quick(path);
break;
}
}
if ( music_file != NULL ){
Global::debug(0) << "Loaded " << path << " type " << typeToExtension( i ) << "(" << i << ")" << std::endl;
break;
}
}
if (music_file){
int buf = 1 << 11;
- player = al_start_duh(music_file, 2, 0, volume, buf, 22050);
+ player = al_start_duh(music_file, 2, 0, scaleVolume(volume), buf, 22050);
}
}
void DumbPlayer::play(){
al_resume_duh(this->player);
}
void DumbPlayer::poll(){
if (al_poll_duh(this->player) != 0){
}
}
void DumbPlayer::pause(){
al_pause_duh(this->player);
}
-void DumbPlayer::setVolume(int volume){
- al_duh_set_volume(player, volume);
+void DumbPlayer::setVolume(double volume){
+ this->volume = volume;
+ al_duh_set_volume(player, scaleVolume(volume));
}
DumbPlayer::~DumbPlayer(){
al_stop_duh(player);
unload_duh(music_file);
}
#endif
+#ifdef USE_SDL
+DumbPlayer::DumbPlayer(const char * path):
+volume(1.0){
+}
+
+void DumbPlayer::pause(){
+}
+
+void DumbPlayer::play(){
+}
+
+void DumbPlayer::poll(){
+}
+
+void DumbPlayer::setVolume(double volume){
+}
+
+DumbPlayer::~DumbPlayer(){
+}
+
+#endif
+
}
diff --git a/util/music-player.h b/util/music-player.h
index 9608675d..6440a391 100644
--- a/util/music-player.h
+++ b/util/music-player.h
@@ -1,43 +1,43 @@
#ifndef _paintown_music_player_h
#define _paintown_music_player_h
struct DUH;
#ifdef USE_ALLEGRO
struct AL_DUH_PLAYER;
#endif
namespace Util{
class MusicPlayer{
public:
MusicPlayer();
virtual void play() = 0;
virtual void poll() = 0;
virtual void pause() = 0;
- virtual void setVolume(int volume) = 0;
+ virtual void setVolume(double volume) = 0;
virtual ~MusicPlayer();
};
/* interface to DUMB, plays mod/s3m/xm/it */
class DumbPlayer: public MusicPlayer {
public:
DumbPlayer(const char * path);
virtual void play();
virtual void poll();
virtual void pause();
- virtual void setVolume(int volume);
+ virtual void setVolume(double volume);
virtual ~DumbPlayer();
protected:
#ifdef USE_ALLEGRO
AL_DUH_PLAYER * player;
#endif
DUH * music_file;
double volume;
};
}
#endif
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jun 11, 12:44 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
69089
Default Alt Text
(3 KB)
Attached To
Mode
R75 R-Tech1
Attached
Detach File
Event Timeline