summaryrefslogtreecommitdiff
path: root/dgedit/canvastoollisten.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dgedit/canvastoollisten.cc')
-rw-r--r--dgedit/canvastoollisten.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/dgedit/canvastoollisten.cc b/dgedit/canvastoollisten.cc
index 4254137..f638f93 100644
--- a/dgedit/canvastoollisten.cc
+++ b/dgedit/canvastoollisten.cc
@@ -43,6 +43,8 @@ Player::Player(Canvas *c)
sf.byte_format = AO_FMT_NATIVE;
dev = ao_open_live(ao_default_driver_id(), &sf, 0);
+
+ volume = 1000;
}
Player::~Player()
@@ -57,7 +59,7 @@ void Player::run()
if(playing) {
short s[BUFSZ];
for(size_t i = 0; i < BUFSZ; i++) {
- if(i + pos < canvas->size) s[i] = canvas->data[pos + i] * ((2<<16) - 1);
+ if(i + pos < canvas->size) s[i] = canvas->data[pos + i] * volume;
else {
s[i] = 0;
playing = false;
@@ -75,6 +77,11 @@ void Player::run()
}
}
+void Player::setVolume(double v)
+{
+ volume = v;
+}
+
CanvasToolListen::CanvasToolListen(Canvas *c)
: player(c)
{
@@ -128,3 +135,8 @@ void CanvasToolListen::update()
canvas->update(r);
lastpos = pos;
}
+
+void CanvasToolListen::setVolume(int v)
+{
+ player.setVolume(v);
+}