Author Topic: Recording supported channel count  (Read 1465 times)

3delite

  • Posts: 895
Recording supported channel count
« on: 11 Jan '13 - 22:24 »
Hi!

Looking at the docs I couldn't find an explanation on how to query the available channels for a recording input. BASS_RecordStart()'s second parameter is the channel count. How can I determine the max. value for it?

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: Recording supported channel count
« Reply #1 on: 12 Jan '13 - 15:05 »
That information isn't available with the current BASS release, but it will be with the next release. If you would like to try that now, it is included in the latest stuff...

   www.un4seen.com/stuff/bass.dll

The channel count is placed in the high 8 bits of the BASS_RECORDINFO "formats" member. For example, you could do this to get it...

Code: [Select]
BASS_RECORDINFO ri;
BASS_RecordGetInfo(&ri);
DWORD chans=ri.formats>>24;
« Last Edit: 14 Jan '13 - 13:54 by Ian @ un4seen »

3delite

  • Posts: 895
Re: Recording supported channel count
« Reply #2 on: 13 Jan '13 - 11:14 »
In the example code it should be BASS_RecordGetInfo(), right?

Seems working fine, thank you!

Just one note though. So this input channel count is global to all the inputs? Not specific to a specific input?
I put the call after BASS_RecordSetInput() if that affects anything, I can't really test this value because I only have a plain 2 channel supported on-board audio device.


radio42

  • Posts: 4574
Re: Recording supported channel count
« Reply #3 on: 14 Jan '13 - 09:00 »
But that would also mean, that you couldn't cast/map the defined formats field (from MMSYSTEM.H) directly to the "formats" member anymore?!
E.g. "WAVE_FORMAT_4M16" and "WAVE_FORMAT_4S16"
Plus some of them are kind of useless, e.g. the above distinguish between Mono and Stereo...?

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: Recording supported channel count
« Reply #4 on: 14 Jan '13 - 13:57 »
In the example code it should be BASS_RecordGetInfo(), right?

Oops, that should indeed be BASS_RecordGetInfo. I've updated the snippet.

Just one note though. So this input channel count is global to all the inputs? Not specific to a specific input?

Yes, the channel count is taken from the device rather than a particular input. I guess it's possible that the number could change depending on the active input, but I think that's unlikely. You could recheck the channel count after switching inputs to be sure. Of course, this question only applies to pre-Vista Windows, as each input is presented as a separate device since Vista.

But that would also mean, that you couldn't cast/map the defined formats field (from MMSYSTEM.H) directly to the "formats" member anymore?!
E.g. "WAVE_FORMAT_4M16" and "WAVE_FORMAT_4S16"

Those flags don't use the high 8 bits, so they won't be affected by this. A "chans" member will probably be added to the BASS_RECORDINFO structure in future, but to retain 2.4 back-compatibility, it has to piggyback an existing member for now :)

radio42

  • Posts: 4574
Re: Recording supported channel count
« Reply #5 on: 14 Jan '13 - 15:21 »
Quote
Those flags don't use the high 8 bits, so they won't be affected by this
That depends on how this is used in existing code - as the MMSYSTEM.H and BASS today defines them as constants and not as 'flags'.
I would assume, that most users (like Bass.Net internally) would today simply take the "formats" member and compare its value directly (1:1) with the given BASS WAVE_FORMAT_* constants.
And a direct cast or comparision would effectively fail in the new version.
E.g. the following would fail:
Code: [Select]
if (recInfo.formats == WAVE_FORMAT_4S16)
    ...
As such all existing code might need to be revisited like this:
Code: [Select]
if ((recInfo.formats & WAVE_FORMAT_4S16) == WAVE_FORMAT_4S16)
    ...
// respectively
if ((recInfo.formats & 0xFFFFFF) == WAVE_FORMAT_4S16)
    ...

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: Recording supported channel count
« Reply #6 on: 14 Jan '13 - 16:26 »
They are flags though. The BASS and BASS.Net documentation even says they are :) ... So comparisons like the following are very likely to fail anyway, regardless of the channel count in the high 8 bits:

Code: [Select]
if (recInfo.formats == WAVE_FORMAT_4S16) ...

This would be the correct way to check for WAVE_FORMAT_4S16:

Code: [Select]
if (recInfo.formats & WAVE_FORMAT_4S16) ...

I'm not sure there's much point checking those flags these days though, as they don't appear to necessarily indicate what the device natively supports. They probably haven't really been useful since the days of Win9x and VxD drivers.