Author Topic: Crackling sound  (Read 7968 times)

rancidfrog

  • Posts: 7
Re: Crackling sound
« Reply #25 on: 19 May '17 - 22:22 »
Maybe issues might not be filetype but audio output type:

Quote from: Peter;
For reference, OpenSL is known to be unreliable for music playback on many devices and cannot be enabled by default, but it may help if the default output mode (Android AudioTrack) is behaving incorrectly - at least it avoids piping all your sound thru Java code.

OpenSL does not play well with some devices, the ability to choose audio output with ease might be required.

serkanp

  • Posts: 135
Re: Crackling sound
« Reply #26 on: 22 May '17 - 09:38 »
Maybe issues might not be filetype but audio output type:

Quote from: Peter;
For reference, OpenSL is known to be unreliable for music playback on many devices and cannot be enabled by default, but it may help if the default output mode (Android AudioTrack) is behaving incorrectly - at least it avoids piping all your sound thru Java code.

OpenSL does not play well with some devices, the ability to choose audio output with ease might be required.

we are on raspbian arm linux hardfp and windows all versions..
our coding language is nodejs, therefore its not java, just the syntax is javascript, interpreter is c

serkanp

  • Posts: 135
Re: Crackling sound
« Reply #27 on: 22 May '17 - 09:53 »
If you're unable to try non-MP3 files, could you try the "mp3-free" BASS version instead? Or the standard BASS version if you are currently using the "mp3-free" version. When using the Linux "mp3-free" version, the libmpg123 library needs to be installed for MP3 support. Please also confirm whether you're using BASS_StreamCreateFile to open the files, or your own file routines with BASS_StreamCreateFileUser.

Regarding a debug BASS version, I'm not sure at this stage what events should be logged for this problem. If we can narrow it down to the MP3 decoder, then that would give us a starting point for further investigation.

using mp3-free version of bass on raspberrypi still have the same problem with mp3 files.

rancidfrog

  • Posts: 7
Re: Crackling sound
« Reply #28 on: 22 May '17 - 11:39 »

we are on raspbian arm linux hardfp and windows all versions..
our coding language is nodejs, therefore its not java, just the syntax is javascript, interpreter is c
Bass for android uses OpenSL, as default audio output, which causes crackles and stutters on certain devices.
Other players, not using bass do not have same problem, I believe they use AudioTrack for output.

You should check default audio output type on bass library for your device, linux.
And see if there is an alternative.

For example, for android you can force bass to use audiotrack by: http://www.un4seen.com/forum/?topic=13225.msg118003#msg118003

The issue might be the  default audio output that bass library uses and not file types

Ian @ un4seen

  • Administrator
  • Posts: 26252
Re: Crackling sound
« Reply #29 on: 22 May '17 - 16:50 »
using mp3-free version of bass on raspberrypi still have the same problem with mp3 files.

OK, it doesn't appear to be an MP3 decoder issue then. You mentioned that the problem stops when you move to the next file. What about if you re-open the same file? Also, are you using any DSP/FX, eg. BASS_ChannelSetDSP/FX? If so, please try removing that, and see if the problem still happens then.

Bass for android uses OpenSL, as default audio output, which causes crackles and stutters on certain devices.

BASS uses ALSA on Linux and DirectSound on Windows. They are very different systems, so if the problem is happening with both, then it wouldn't appear to be related to the output system.

serkanp

  • Posts: 135
Re: Crackling sound
« Reply #30 on: 23 May '17 - 13:09 »
using mp3-free version of bass on raspberrypi still have the same problem with mp3 files.

OK, it doesn't appear to be an MP3 decoder issue then. You mentioned that the problem stops when you move to the next file. What about if you re-open the same file? Also, are you using any DSP/FX, eg. BASS_ChannelSetDSP/FX? If so, please try removing that, and see if the problem still happens then.

Bass for android uses OpenSL, as default audio output, which causes crackles and stutters on certain devices.

BASS uses ALSA on Linux and DirectSound on Windows. They are very different systems, so if the problem is happening with both, then it wouldn't appear to be related to the output system.


there is no dsp or fx on system

var result = this.basswrapper.BASS_Init(this.soundCard, 44100, this.basswrapper.BASS_Initflags.BASS_DEVICE_SPEAKERS);
var flags = this.basswrapper.BASSFlags.BASS_STREAM_DECODE | this.basswrapper.BASSFlags.BASS_SAMPLE_FLOAT ;
this.channel = this.basswrapper.BASS_StreamCreateFile(0, FileName, 0, 0, flags);

then we are adding the channel to a mixer .. (there are some other parts for announces etc..)

we use BASS_ChannelSetSync to get event for last xxxx second with BASS_SYNC_POS
and BASS_ChannelSlideAttribute to slide volume down or up using BASS_ATTRIB_VOL


also i tried usb sound cards and hifi-berry sound card (on raspberry pi 3). still we have the same problem. this means its not related to sound card.

let me describe the problem again, here are some investigations:
1- sometimes on any position of song, crackling begins and remains till the end of song. when we get to the next song it works as normal.
2- sometimes on any position of song, crackling begins and after random seconds on still the same song, playbacks returns to normal.

these 2 problems happens any time.. sometimes after 4-5 hours of playback, sometimes after 20 minutes of playback, sometimes never..
but i have now 2 raspberry pi devices having the problem in a day more then 2-3 times. so whenever you like, i can give you access to connect to device and see whats going on in it..

ps: one interesting issue i found is, when there is a mixer channel and a streamcreatefile channel, and channel added to mixer, when you get vumeter values from channel (not from mixer), the playback becomes faster. but when you get vumeter values from mixer channel, the playback is normal. i dont know if this is a problem or not, but accidently we found this.


Ian @ un4seen

  • Administrator
  • Posts: 26252
Re: Crackling sound
« Reply #31 on: 23 May '17 - 15:52 »
let me describe the problem again, here are some investigations:
1- sometimes on any position of song, crackling begins and remains till the end of song. when we get to the next song it works as normal.
2- sometimes on any position of song, crackling begins and after random seconds on still the same song, playbacks returns to normal.

these 2 problems happens any time.. sometimes after 4-5 hours of playback, sometimes after 20 minutes of playback, sometimes never..
but i have now 2 raspberry pi devices having the problem in a day more then 2-3 times. so whenever you like, i can give you access to connect to device and see whats going on in it..

If you attach a WAV writer to the mixer, is the noise present in the written file? You can use the BASSenc add-on for that, something like this:

Code: [Select]
BASS_Encode_Start(mixer, "mixer.wav", BASS_ENCODE_PCM|ENC_RF64|BASS_ENCODE_AUTOFREE, 0, 0);

Note the file will be very large after 4-5 hours, so make sure there is plenty of disk space.

If you briefly stop or pause playback (eg. call BASS_ChannelStop/Pause on the mixer) when the problem happens, is it gone when you resume playback? Also, is the problem definitely happening on Windows too, and if so, is that desktop Windows, not Windows 10 running on an RPi?

ps: one interesting issue i found is, when there is a mixer channel and a streamcreatefile channel, and channel added to mixer, when you get vumeter values from channel (not from mixer), the playback becomes faster. but when you get vumeter values from mixer channel, the playback is normal. i dont know if this is a problem or not, but accidently we found this.

The fast playback is caused by the vumeter's BASS_ChannelGetData call taking data from the decoder, which then isn't available for the mixer to play, ie. the mixer skips some data. When playing through a mixer, you can use BASS_Mixer_ChannelGetData instead (or BASS_ChannelGetData on the mixer like you said) to avoid that problem.

serkanp

  • Posts: 135
Re: Crackling sound
« Reply #32 on: 5 Dec '17 - 07:57 »
Quote
If you briefly stop or pause playback (eg. call BASS_ChannelStop/Pause on the mixer) when the problem happens, is it gone when you resume playback? Also, is the problem definitely happening on Windows too, and if so, is that desktop Windows, not Windows 10 running on an RPi?

- when we stop or pause and resume (in our system we just stop and move to the next song), the crackling goes and normal playback of song starts
- the problem definetly happens on normal desktop windows player, both on x86,x64 windows 7-10 systems and rpi3 linux debian

one another issue is, playback freezes on any time position between 2 seconds. it plays 1-2 second and returns to previous position and loops like this.stopping and resuming have no change , we have to stop the application and restart it again.

these problems does not have a pattern, any time, on any player... sometimes never , sometimes 8-10 times a day..

Ian @ un4seen

  • Administrator
  • Posts: 26252
Re: Crackling sound
« Reply #33 on: 5 Dec '17 - 17:24 »
- when we stop or pause and resume (in our system we just stop and move to the next song), the crackling goes and normal playback of song starts

Did you also try attaching a WAV writer to the mixer to confirm whether the crackling is present in the mix? Also, did raising the BASS_CONFIG_DEV_BUFFER/PERIOD settings make any difference on the RPi?

one another issue is, playback freezes on any time position between 2 seconds. it plays 1-2 second and returns to previous position and loops like this.stopping and resuming have no change , we have to stop the application and restart it again.

That sounds like it could be a deadlock. They are typically caused by a callback function doing something that has to wait for another thread. Are you using any callback functions, eg. STREAMPROC/DSPPROC/SYNCPROC? If so, you could try logging their entry and exit to see if it's stuck in one of them when the problem happens. Make sure the logging isn't buffered.

serkan polat

  • Guest
Re: Crackling sound
« Reply #34 on: 5 Dec '17 - 17:46 »
Quote
Did you also try attaching a WAV writer to the mixer to confirm whether the crackling is present in the mix? Also, did raising the BASS_CONFIG_DEV_BUFFER/PERIOD settings make any difference on the RPi?

as i told you before, i cant, because it doesnt have any pattern and we dont know when and where it happening.
we know it when our customer calls us and says: its crackling.. then we remote desktop/teamviewer and see what is happening.

Quote
That sounds like it could be a deadlock. They are typically caused by a callback function doing something that has to wait for another thread. Are you using any callback functions, eg. STREAMPROC/DSPPROC/SYNCPROC? If so, you could try logging their entry and exit to see if it's stuck in one of them when the problem happens. Make sure the logging isn't buffered.

i removed all callbacks (one was to get callback when the music reaches to the end). still the same..
is there any option to log bass internal events to a file with a method?
so when this happens , i can give a command to my player to set a method to start logging..

serkanp

  • Posts: 135
Re: Crackling sound
« Reply #35 on: 6 Dec '17 - 08:05 »
i also have new audio recordings about this 2 issue.. (recorded by cell phone)
if you want to hear it , i can upload

Ian @ un4seen

  • Administrator
  • Posts: 26252
Re: Crackling sound
« Reply #36 on: 6 Dec '17 - 14:33 »
Quote
Did you also try attaching a WAV writer to the mixer to confirm whether the crackling is present in the mix? Also, did raising the BASS_CONFIG_DEV_BUFFER/PERIOD settings make any difference on the RPi?

as i told you before, i cant, because it doesnt have any pattern and we dont know when and where it happening.
we know it when our customer calls us and says: its crackling.. then we remote desktop/teamviewer and see what is happening.

Perhaps you could add a secret switch that attaches a WAV writer to the mixer, and you can activate that when you remote desktop/teamviewer?

The BASS_CONFIG_DEV_BUFFER/PERIOD settings are applied by BASS_Init, so you can't change them while the problem is happening, but perhaps you could add an option to raise them and have the affected user(s) use that option and see if the problem still happens after that?

i removed all callbacks (one was to get callback when the music reaches to the end). still the same..
is there any option to log bass internal events to a file with a method?
so when this happens , i can give a command to my player to set a method to start logging..

A deadlocked update thread will only result in repeating sound on Windows (the sound will stop on other platforms), so I assume this problem is only happening on Windows? To confirm whether the update thread is indeed deadlocked, please upload a dump file (ZIP'd) from when the problem is happening:

   ftp.un4seen.com/incoming/

You can use Task Manager's "Create Dump File" option to generate the dump file.

i also have new audio recordings about this 2 issue.. (recorded by cell phone)
if you want to hear it , i can upload

Yes, please upload them.

serkanp

  • Posts: 135
Re: Crackling sound
« Reply #37 on: 6 Dec '17 - 17:26 »
uploaded 2 audio files and 1 video recording to incoming.


ps:
interesting part, when looping (you mentioned as deadlock), the vumeters still working..
« Last Edit: 6 Dec '17 - 17:35 by serkanp »