diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2014-04-15 14:14:52 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2014-04-15 14:14:52 +0200 |
commit | 1cabb60b318fd831458f937b240b207c21a28ceb (patch) | |
tree | cf915e291f2301049ef912bf2ef0863a0cc4730c /dgedit/player.cc | |
parent | 4aa5b796ba7186892d14e20226d6cef942d0c60d (diff) |
Make CanvasToolListen work again with offsets using the mouse. Clean up Player code some more.
Diffstat (limited to 'dgedit/player.cc')
-rw-r--r-- | dgedit/player.cc | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/dgedit/player.cc b/dgedit/player.cc index cb6b986..782020b 100644 --- a/dgedit/player.cc +++ b/dgedit/player.cc @@ -30,11 +30,15 @@ #define BUFSZ 1024 * 2 -Player::Player(Canvas *c) +Player::Player() { - canvas = c; playing = false; + + peak = 0; pos = 0; + gain_scalar = 1.0; + pcm_data = NULL; + pcm_size = 0; ao_initialize(); @@ -46,10 +50,6 @@ Player::Player(Canvas *c) dev = ao_open_live(ao_default_driver_id(), &sf, 0); - gain_scalar = 1000; - - peak = 0; - connect(&report_timer, SIGNAL(timeout()), this, SLOT(reportTimeout())); report_timer.start(50); // Update 25 times per second } @@ -67,8 +67,8 @@ void Player::run() if(playing) { for(size_t i = 0; i < BUFSZ; i++) { double sample = 0.0; - if(i + pos < canvas->size) { - sample = canvas->data[pos + i] * gain_scalar; + if(i + pos < pcm_size) { + sample = pcm_data[pos + i] * gain_scalar; } else { playing = false; } @@ -105,3 +105,14 @@ void Player::reportTimeout() emit positionUpdate(pos); peak = 0.0; } + +void Player::setPcmData(float *data, size_t size) +{ + pcm_data = data; + pcm_size = size; +} + + void Player::setPosition(size_t position) + { + pos = position; + } |