Author Topic: BASS_ChannelGetInfo 32bit integer or 32bit float?  (Read 2889 times)

3delite

  • Posts: 926
Hi!

Is it possible to decide if the (WAV) file is 32bit integer or 32bit float (IEEE) with BASS_ChannelGetInfo()?

Thank you!

Ian @ un4seen

  • Administrator
  • Posts: 21211
Re: BASS_ChannelGetInfo 32bit integer or 32bit float?
« Reply #1 on: 19 Jun '12 - 18:06 »
Yes, that can be detected from the "ctype" value. It will be BASS_CTYPE_STREAM_WAV_PCM for integer and BASS_CTYPE_STREAM_WAV_FLOAT for floating-point.

3delite

  • Posts: 926
Re: BASS_ChannelGetInfo 32bit integer or 32bit float?
« Reply #2 on: 21 Jun '12 - 12:58 »
Ok. Works fine. Though I was first trying as a flag, it seemed to me from the docs!?
Trying as a value seems working.

Code: [Select]
type
    TAudioResolution = (arUnknown, ar8bit, ar16bit, ar24bit, ar32bit, ar32bitFloat);

Not working:

Code: [Select]
               case ChanInfo.origres of
                    8: Bits := ar8bit;
                    16: Bits := ar16bit;
                    24: Bits := ar24bit;
                    32: begin
                        if (ChanInfo.ctype AND BASS_CTYPE_STREAM_WAV_PCM) > 0 then begin
                            Bits := ar32bit;
                        end else begin
                            if (ChanInfo.ctype AND BASS_CTYPE_STREAM_WAV_FLOAT) > 0 then begin
                                Bits := ar32bitFloat;
                            end else begin
                                Bits := ar32bit;
                            end;
                        end;
                    end;
                end;

Working:

Code: [Select]
               case ChanInfo.origres of
                    8: Bits := ar8bit;
                    16: Bits := ar16bit;
                    24: Bits := ar24bit;
                    32: begin
                        if ChanInfo.ctype = BASS_CTYPE_STREAM_WAV_PCM then begin
                            Bits := ar32bit;
                        end else begin
                            if ChanInfo.ctype = BASS_CTYPE_STREAM_WAV_FLOAT then begin
                                Bits := ar32bitFloat;
                            end else begin
                                Bits := ar32bit;
                            end;
                        end;
                    end;
                end;


Ian @ un4seen

  • Administrator
  • Posts: 21211
Re: BASS_ChannelGetInfo 32bit integer or 32bit float?
« Reply #3 on: 21 Jun '12 - 13:38 »
BASS_CTYPE_STREAM_WAV can be used as a flag to detect whether it's a WAV file of some sort, and BASS_CTYPE_STREAM_WAV_PCM/FLOAT can be used to check specifically whether it's an integer/floating-point PCM WAV file. For example, like this...

Code: [Select]
BASS_CHANNELINFO info;
BASS_ChannelGetInfo(handle, &info);
if (info.ctype&BASS_CTYPE_STREAM_WAV) { // it's a WAV file of some sort
if (info.ctype==BASS_CTYPE_STREAM_WAV_PCM)
printf("integer PCM WAV file\n");
else if (info.ctype==BASS_CTYPE_STREAM_WAV_FLOAT)
printf("floating-point PCM WAV file\n");
else
printf("some other WAV file\n");
}

A little demonstration can be found in the PLUGINS example ("GetCTypeString" function), although I'm not sure the Delphi version of it looks quite right :)

3delite

  • Posts: 926
Re: BASS_ChannelGetInfo 32bit integer or 32bit float?
« Reply #4 on: 21 Jun '12 - 14:36 »
From the Delphi example it looks like it's a value but BASS_CTYPE_STREAM_WAV is a flag? :)

But BASS_CTYPE_STREAM_WAV_PCM and BASS_CTYPE_STREAM_WAV_FLOAT is a value???

Ian @ un4seen

  • Administrator
  • Posts: 21211
Re: BASS_ChannelGetInfo 32bit integer or 32bit float?
« Reply #5 on: 21 Jun '12 - 16:42 »
From the Delphi example it looks like it's a value but BASS_CTYPE_STREAM_WAV is a flag? :)

Yep, that's the bit that doesn't look right. Check the C or VB version instead :)

3delite

  • Posts: 926
Re: BASS_ChannelGetInfo 32bit integer or 32bit float?
« Reply #6 on: 22 Jun '12 - 10:19 »
For me it seems the same. It's a value. But its very interesting finding for me that it could be both! For example (in binary): 101 = WAV_PCM (value), 100 = WAV (flag) so you specify the variable = WAV_PCM and then can test it against:

Code: [Select]
    if (Variable AND WAV) > 0 then begin //* it's a WAV
        if Variable = WAV_PCM then begin //* it's a WAV with format PCM
            ...

:)