Author Topic: ASIO get level case accelerated and distorted/clipped audio  (Read 193 times)

Dev01

  • Posts: 46
Hello.
I ask you for help because I have finished all the attempts.
My problem is that with ASIO asking for levels causes the audio to speed up and distort.
I've seen these cases before
https://www.un4seen.com/forum/?topic=16002.msg111163#msg111163
https://www.un4seen.com/forum/?topic=13827.msg96367#msg96367
but I've not found a solution yet.
I'm using Visual Studio 2022, NET Core 6, Windows 11 64 bit


Code: [Select]
float[] peaks = new float[8];

peaks = BassMix.BASS_Mixer_ChannelGetLevel(handle, 0.02f, BASSLevel.BASS_LEVEL_ALL);                         //null
error = BassAsio.BASS_ASIO_ErrorGetCode();                                                                   //Un4seen.Bass.BASSError.BASS_OK

peaks = BassMix.BASS_Mixer_ChannelGetLevel(mMixerHandles[mChannelIndex], 0.02f, BASSLevel.BASS_LEVEL_ALL);   //null
error = BassAsio.BASS_ASIO_ErrorGetCode();                                                                   //Un4seen.Bass.BASSError.BASS_OK

fpeakL = BassAsio.BASS_ASIO_ChannelGetLevel(false, 0);                                                       //Always -1
error = BassAsio.BASS_ASIO_ErrorGetCode();                                                                   //Un4seen.Bass.BASSError.BASS_ERROR_START


peaks[0] = Bass.BASS_ChannelGetLevel(handle);                                                                //OK BUT THE AUDIO IS ACCELERATED AND DISTORTED

peaks = Bass.BASS_ChannelGetLevels(handle, 0.00002f);                                                        //OK BUT STILL SOME CLIPPING IS HEARDABLE

Also the spectrum getting cause trouble with
Code: [Select]
Bass.BASS_ChannelGetData(handle, mFftBuffer, (int)BASSData.BASS_DATA_FFT1024);but it seems ok if I do
Code: [Select]
Bass.BASS_ChannelGetData(handle, mFftBuffer, (int)BASSData.BASS_DATA_FFT_INDIVIDUAL); //OK
« Last Edit: 29 Mar '24 - 15:51 by Dev01 »

Ian @ un4seen

  • Administrator
  • Posts: 25780
If "handle" is being played by BASSASIO then the problem is as in the 2nd link you posted, ie. BASSASIO will not see/play the data used in BASS_ChannelGetData/Level(s) calls on the same handle. BASS_ChannelGetLevel(s) could be replaced with BASS_ASIO_ChannelGetLevel, but BASS_ChannelGetData will be trickier to replace. The simplest solution is probably to create a mixer and plug "handle" into that with the BASS_MIXER_CHAN_BUFFER flag set, and have BASSASIO play the mixer. You can then use BASS_Mixer_ChannelGetData instead of BASS_ChannelGetData.

Regarding BASS_ASIO_ChannelGetLevel giving a BASS_ERROR_START error, that indicates the ASIO device hasn't been started. You can start it with BASS_ASIO_Start.