Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: PwmOutSpeaker.cpp
- Revision:
 - 2:436529700217
 - Parent:
 - 1:8ec133daca4c
 - Child:
 - 3:37a886d77bae
 
--- a/PwmOutSpeaker.cpp	Fri Mar 24 03:22:57 2017 +0000
+++ b/PwmOutSpeaker.cpp	Fri Mar 24 06:55:24 2017 +0000
@@ -102,8 +102,8 @@
                 Thread::wait(1);
             }
             wk_vol = _speaker_vol;
+            wk_ofs = (1.0f - wk_vol) / 2;
             if (_length == 8) {
-                wk_ofs = (1.0f - wk_vol) / 2;
                 _pwm_duty_buf[_bottom] = ((float)p_data[i++] / (float)0xff) * wk_vol + wk_ofs;
                 if (_channel == 1) {
                     _pwm_duty_buf[_bottom + 1] = _pwm_duty_buf[_bottom];