Author Topic: BASS_Mixer_ChannelGetLevel: Illegal parameter  (Read 787 times)

kafffee

  • Posts: 293
Hey there,

I ran into a little problem that I am not able to fix on my own:

I want to show the peak of my music with the following code:

Code: [Select]
Public peak() As Single = {0, 0}

Public Sub ShowPeak(ByVal sender As Object, ByVal e As EventArgs)
       
        Dim MyFlag As BASSLevel = CType(16, BASSLevel)
       
        BassMix.BASS_Mixer_ChannelGetLevel(MainModule.streamfx(WhichDeck - 1), peak, 0.1, MyFlag Or BASSLevel.BASS_LEVEL_STEREO)
        Debug.WriteLine("Error GetLevel: " & Bass.BASS_ErrorGetCode)
       
        If peak IsNot Nothing Then
         
            Dim MyVolume As Single
            Bass.BASS_ChannelGetAttribute(MainModule.streamfx(WhichDeck - 1), BASSAttribute.BASS_ATTRIB_VOL, MyVolume)

            MainModule.MainDispatcher.Invoke(Sub() PeakLeft = peak(0) * MyVolume)

            MainModule.MainDispatcher.Invoke(Sub() PeakRight = peak(1) * MyVolume)

        End If
    End Sub

Unfortunately, I get error #20 (illegal parameter) on the BassMix.BASS_Mixer_ChannelGetLevel call

Anybody know what could be wrong with that?

Chris

  • Posts: 2221
Re: BASS_Mixer_ChannelGetLevel: Illegal parameter
« Reply #1 on: 25 Oct '23 - 11:28 »
Hi looks like the length Parameter is not correct/to small because its dependent from the  source's buffer or the full amount is not available.
https://www.un4seen.com/doc/#bassmix/BASS_Mixer_ChannelGetLevelEx.html
Just check it via  BASS_CONFIG_MIXER_BUFFER
« Last Edit: 25 Oct '23 - 11:34 by Chris »

kafffee

  • Posts: 293
Re: BASS_Mixer_ChannelGetLevel: Illegal parameter
« Reply #2 on: 25 Oct '23 - 12:18 »
Hey Chris,

can you give me an example of how to do that?

Chris

  • Posts: 2221
Re: BASS_Mixer_ChannelGetLevel: Illegal parameter
« Reply #3 on: 25 Oct '23 - 12:57 »
e.g
Mixer_Buffer = BASS_Mixer_ChannelFlags(YourMixer, 0, BASS_MIXER_CHAN_BUFFER);  // will return the ,BASS_MIXER_CHAN_BUFFER Value , Standard =2
Bass_Buffer = BASS_GetConfig( BASS_CONFIG_BUFFER) //Standard 500 ms
will mean  Bass_Buffer Value (e.g 500ms) * Mixer_Buffer Value is the complete available Buffer.

by the way do you have the the BASS_Mixer_ChannelGetLevelEx Call in a Timer what is the Timer repeat Value ? Does the Error occurs always or only  on the beginning?
Also its just possible that the full amount is not available.




« Last Edit: 25 Oct '23 - 13:03 by Chris »

kafffee

  • Posts: 293
Re: BASS_Mixer_ChannelGetLevel: Illegal parameter
« Reply #4 on: 25 Oct '23 - 13:33 »
Okay I still get error #20. What I have is this:

Code: [Select]
BassMix.BASS_Mixer_ChannelGetLevel(MainModule.streamfx(WhichDeck - 1), peak, BassMix.BASS_Mixer_ChannelFlags(MainModule.mixer, 0, BASSFlag.BASS_MIXER_CHAN_BUFFER), Flagge Or BASSLevel.BASS_LEVEL_STEREO)
streamfx(WhichDeck-1) holds the handle for a source channel of MainModule.mixer

Whats the difference between BASS_Mixer_ChannelGetLevel and BASS_Mixer_ChannelGetLevelEx?

When I use BASS_Mixer_ChannelGetLevelEx, I get "BASS_Mixer_ChannelGetLevelEx is not a member of BassMix"...

I am using a timer with an interval of 25 milliseconds... The error occurs always.

Chris

  • Posts: 2221
Re: BASS_Mixer_ChannelGetLevel: Illegal parameter
« Reply #5 on: 25 Oct '23 - 14:16 »
No not  so
 BASS_Mixer_ChannelGetLevel will have in Net 3 overloads

BASS_Mixer_ChannelGetLevel(Int32)

BASS_Mixer_ChannelGetLevel(Int32, Single, BASSLevel)// will need only   one single Variable // will use a length = 0,02f


BASS_Mixer_ChannelGetLevel(Int32,Single[], Single, BASSLevel) // array of Single // with your own length

The last 2 overloads are a Pseudonyms for Bass_ChannelGetLevelEx

so i think i see the error in your source because the error comes not from the Length Param it come from the wrong Level Flags.
 BASSLevel is a Enumeration of the Levelflags and you have declare a array of 2 Floats so
Code: [Select]
BassMix.BASS_Mixer_ChannelGetLevel(MainModule.streamfx(WhichDeck - 1), peak, 0.1, MyFlag Or BASSLevel.BASS_LEVEL_STEREO)that cannot work because your are mixing BASS_LEVEL_STEREO with BASS_LEVEL_ALL.
so
try it with
Code: [Select]
BassMix.BASS_Mixer_ChannelGetLevel(MainModule.streamfx(WhichDeck - 1), peak, 0.1F, BASSLevel.BASS_LEVEL_STEREO)by the way do you set the  mixer Channel without BASS_ATTRIB_BUFFER ?
remember
the source channel must have buffering enabled via the BASS_MIXER_CHAN_BUFFER flag.



« Last Edit: 25 Oct '23 - 14:52 by Chris »

kafffee

  • Posts: 293
Re: BASS_Mixer_ChannelGetLevel: Illegal parameter
« Reply #6 on: 25 Oct '23 - 14:48 »
Thanks that was it :-)