Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange issue with Sound Component with variable based duration #2446

Closed
frankgasking opened this issue May 9, 2019 · 6 comments

Comments

Projects
None yet
2 participants
@frankgasking
Copy link
Contributor

commented May 9, 2019

Testing on PsychoPy 3.1.0 Win 32 Py2.7 edition (Running on Windows 10, 64-bit)

I've found a very strange and critical bug with the Sound Component which has been introduced in the 3.1.0 release (as detailed above).

Basically, if you set the actual duration of the sound as an actual number, then everything works fine. But if you attempt to set the duration with a variable/python code, then it seems to not generate the "frameRemains" attribute and check against this to see if the sound should stop. It just checks against the duration, which means if the duration and start is the same, then it seems to start and stop the sound at the same time.

It's not noticeable if the sound starts from 0 seconds, as the calculation works fine and has enough time to play before stopping, but if you bump it up to 2 on the start time - then you'll notice it.

Attached is a demonstration - first part is with the variable and a 2 second starting point. Second part shows the same, but with the duration hard-coded.

AudioTest.zip

@peircej

This comment has been minimized.

Copy link
Member

commented May 10, 2019

OK, digging around and this dates back to pull request #1710

Briefly, some code was added by @dvbridges to not force-stop sounds at very brief durations (I believe there was an issue with stopping sounds before they were started, or shorter than the hanning window?) but inserted a fix to check this duration at compile time not during the run. Then in #1858 this was fixed so that you could at least use a duration without an error (by excluding the stop command again at compile time.

The better solution is that we check the duration value at run time not compile time. I'll try and make that fix

@peircej

This comment has been minimized.

Copy link
Member

commented May 10, 2019

Fixed in commit 825bfdb

@peircej peircej closed this May 10, 2019

@frankgasking

This comment has been minimized.

Copy link
Contributor Author

commented May 10, 2019

Awesome, thanks Jon! Will keep an eye out for the next release.

@frankgasking

This comment has been minimized.

Copy link
Contributor Author

commented May 15, 2019

Apologies Jon, unfortunately its still broken in release 3.1.1 Py2 Win32.

I realised my demo didn't start at 2 seconds, so attached is an updated copy
AudioTest.zip
. The sounds don't play on the first loop, only a bit of the first sound plays towards the end of the second trial.

If you compile the code, and compare "play_sound" (Line 302) to "playing_sound_two" (Line 499), you'll see the latter has the frameRemains calculation added in correctly, but it hasn't been for the first part.

@peircej

This comment has been minimized.

Copy link
Member

commented May 15, 2019

Sorry Frank. My bad. I found the fix and applied it to the master branch but failed to copy it over to the release branch for 3.1.1

I have now included it for 3.1.2 which is currently building (and fixes some additional problems with the new Keyboard class). So should be there for you this afternoon.

@frankgasking

This comment has been minimized.

Copy link
Contributor Author

commented May 16, 2019

No worries Jon - and thanks! I'll test out the build tomorrow and will let you know if there are any problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.