Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Test sound button should play sound on press event, not only on change volume event (was: Fails to play the test sound) #3735

Closed
yurivict opened this issue Sep 22, 2016 · 5 comments
Labels
D-easy We estimate that the issue is easy to fix M-audio Affected Module: Audio

Comments

@yurivict
Copy link
Contributor

When I press this button nothing happens.
From the code it appears that this file is supposed to play for the test sound: audio/notification.pcm

qTox-1.5.1
openal-soft-1.16.0_4 - configured to use OSS
FreeBSD 10.3

@Diadlo
Copy link
Member

Diadlo commented Sep 22, 2016

This button not play sound. It's enable sound on volume changing. Can you try again?

@yurivict
Copy link
Contributor Author

yurivict commented Sep 22, 2016

I see, yes it does play sound on volume change.

However, this is not an intuitive feature, it will cause confusion. I think pressing the button also should play the sound once, in addition to how it plays it on volume change.

@yurivict yurivict changed the title Fails to play the test sound Test sound button should play sound on press event, not only on change volume event (was: Fails to play the test sound) Sep 22, 2016
@sudden6 sudden6 added D-easy We estimate that the issue is easy to fix M-audio Affected Module: Audio labels Sep 22, 2016
AliceGrey added a commit to AliceGrey/qTox that referenced this issue Sep 28, 2016
AliceGrey added a commit to AliceGrey/qTox that referenced this issue Sep 29, 2016
@antis81
Copy link
Contributor

antis81 commented Sep 30, 2016

@AliceGrey @Diadlo How about writing a playTestSound() method and add it either to the UI part (a/v settings) or even to the Audio class? What you just did, is producing "spaghetti code" -> you want to avoid creating (strong) code dependencies, which can be quite challenging. In this case, the impact is harmless, but when talking about code, one needs to think like that in general. What I mean by that is:

  1. Uh oh, found duplicate code.
  2. Check, what the two (or more) methods have in common.
  3. Write a method, that reflects the common part.
  4. Think about generalization (in this case it could be part of the audio api).

Fine with that? 😇

@AliceGrey
Copy link
Contributor

AliceGrey commented Oct 1, 2016

@antis81 Would something like this be a better solution?

void AVForm::playTestSound(int value)
{
Audio& audio = Audio::getInstance();
if (audio.isOutputReady())
{
const qreal percentage = value / 100.0;
audio.setOutputVolume(percentage);
audio.playMono16Sound(QStringLiteral(":/audio/notification.pcm"));
}
}

void AVForm::on_playbackSlider_valueChanged(int value)
{
Settings::getInstance().setOutVolume(value);
if (mPlayTestSound)
playTestSound(value);
}

void AVForm::on_btnPlayTestSound_clicked(bool checked)
{
mPlayTestSound = checked;
playTestSound(playbackSlider->value())
}

@antis81
Copy link
Contributor

antis81 commented Oct 1, 2016

Yes. Just don't set the output volume in AVForm::playTestSound and it is fine.

AliceGrey added a commit to AliceGrey/qTox that referenced this issue Oct 5, 2016
AliceGrey added a commit to AliceGrey/qTox that referenced this issue Oct 6, 2016
AliceGrey added a commit to AliceGrey/qTox that referenced this issue Oct 6, 2016
AliceGrey added a commit to AliceGrey/qTox that referenced this issue Oct 8, 2016
AliceGrey added a commit to AliceGrey/qTox that referenced this issue Oct 8, 2016
AliceGrey added a commit to AliceGrey/qTox that referenced this issue Oct 9, 2016
AliceGrey added a commit to AliceGrey/qTox that referenced this issue Oct 9, 2016
AliceGrey added a commit to AliceGrey/qTox that referenced this issue Oct 9, 2016
AliceGrey added a commit to AliceGrey/qTox that referenced this issue Oct 9, 2016
AliceGrey added a commit to AliceGrey/qTox that referenced this issue Oct 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
D-easy We estimate that the issue is easy to fix M-audio Affected Module: Audio
Projects
None yet
Development

No branches or pull requests

5 participants