I have some programs where I play different short soundfiles when pressing buttons or clicking areas on the screen. The problem is that each time I do this there is a noticable clicking or scratching sound when I release the mouse button. Is there anything I can do about this? I am working in C Win Api.
- Varun asked 5 years ago
Thanks for your response!
I think I have found the cause of the problem, but no solution. I don’t believe it has so much to do with the program as such, as I think it is set up as recommended: I first have a play sound command in a paused state, then I set the frequency and possibly the volume and then I have a pause command to start the sound. And right before the last pause command I do a system update.
The sound files I use are each continuous sounds of about 5 to 10 seconds. When I test these sounds in Audacity and set them in a loop with a short fade in at the beginning and a short fade out at the end, there is no clicking sound. However, If I don’t have a fade out in the end, I get the same clicking as in the program in the transition from the end to the beginning of the file. The problem I believe is that when these sound files are played in the program, they normally will be stopped somewhere in the middle when a new play sound command will be issued, and a clicking sound then occurs in the transition by the same reason as above. However, I have no idea how I can resolve this issue, which I need to do. I only know that there are programs that don’t have this problem, so that there must be a solution.
So you’re actually just having the problem that your sounds don’t loop properly?
In your sound editor you should author the sound so that it does loop correctly. You usually do that by making sure the first sample and the last sample are on a zero crossing for example, and make sure if the waveform is ramping up at the end, that it ramps up at the start as well. This isnt always foolproof but there are ways to make sounds loop better by using sound authoring tools that do cross fade looping for you.
The problem is that there is not at one specific point in the sound file that the transitions take place. The sound lasts until I chose to issue another sound, which means a new play sound command and setting another frequency. So the sound file plays 2 milliseconds, half a second, to seconds or whatever for then to be replayed from the beginning, and so on.
Its hard to say without knowing what the code in your app does, but i would possibly expect that your app is in a tight loop and maybe throttling the FMOD mixer thread? Does your app sleep or yield enough or is your update on a timer?
Do the fmod examples that come with the programmer API exhibit the same problem? If not, you could try seeing what is different between the example code and your code.
Please login first to submit.