Stinkstudios / sono

A simple yet powerful JavaScript library for working with Web Audio
http://stinkstudios.github.io/sono/
MIT License
170 stars 15 forks source link

source.volume always reports 1 #34

Closed ogomez92 closed 7 years ago

ogomez92 commented 7 years ago

Hello. I found a very nasty bug, probably in sono.js's volume get function. It's not reporting the right volume, it always reports 1 no matter what the actual volume is. So, changing source.volume-=0.2 will change it, but if you console.log(source.volume) it will report it as being 1. so incremental changes cannot happen.

Can this be fixed?

Thank you.

ianmcgregor commented 7 years ago

Hey @ogomez92, thanks for reporting this. Can you share the code that produces the error and any info on which platform/browser it's occurring on?

ogomez92 commented 7 years ago

Hello: I am doing this under firefox and using the latest version available on npm. I can give you the code but it is part of a custom library called soundObject which exposes the variables from the sono sound source. However it does not interfere with the volume, so I know for a fact that it is a problem in sono.

If you need the code I can try to provide some test code for you. However, try creating a new source, changing the volume and see if it reports correctly.

Thanks.

On 8/17/17, Ian McGregor notifications@github.com wrote:

Hey @ogomez92, thanks for reporting this. Can you share the code that produces the error and any info on which platform/browser it's occurring on?

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/Stinkstudios/sono/issues/34#issuecomment-323066380

ogomez92 commented 7 years ago

OK try this code, it might work for you (soundObject.create returns sono.sound object):

testsound=soundObject.create("g_bgm") testsound.play(); console.log(testsound.volume); Then, make some code that processes an event like pressing a key:

case KeyEvent.DOM_VK_PAGE_UP: testsound.volume+=0.40 console.log(testsound.volume); break;

case KeyEvent.DOM_VK_PAGE_DOWN: testsound.volume-=0.50 console.log(testsound.volume); break;

For me, it reports 0.5 all the time, with further keypressesnot doing anything, even though if you press page down the sound becomes silent and still reports 0.5.

Hth.

On 8/17/17, Oriol Gómez ogomez.s92@gmail.com wrote:

Hello: I am doing this under firefox and using the latest version available on npm. I can give you the code but it is part of a custom library called soundObject which exposes the variables from the sono sound source. However it does not interfere with the volume, so I know for a fact that it is a problem in sono.

If you need the code I can try to provide some test code for you. However, try creating a new source, changing the volume and see if it reports correctly.

Thanks.

On 8/17/17, Ian McGregor notifications@github.com wrote:

Hey @ogomez92, thanks for reporting this. Can you share the code that produces the error and any info on which platform/browser it's occurring on?

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/Stinkstudios/sono/issues/34#issuecomment-323066380

ianmcgregor commented 7 years ago

Thanks for all the info @ogomez92 -- I was able to confirm it was a bug specific to Firefox where the value you get from an AudioParam can get 'stuck' on an old value.

I've added a workaround and a unit test for it. Published in v2.1.2

ogomez92 commented 7 years ago

Hi, thanks very much. can I just do npm update sono? Or what's the procedure? Sorry I'm still quite new.

On 8/18/17, Ian McGregor notifications@github.com wrote:

Thanks for the all the info @ogomez92 -- I was able to confirm it was a bug specific to Firefox where the value you get from an AudioParam can get 'stuck' on an old value.

I've added a workaround and a unit test for it. Published in v2.1.2

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/Stinkstudios/sono/issues/34#issuecomment-323286969

ianmcgregor commented 7 years ago

Yep npm update sono --save will update you to 2.1.2 and save the updated version number in package.json. Thanks again for flagging up this issue.