Getting and setting recording format

Started by kafffee,

kafffee

Hey everywhere :-)

Is there anyone to know how to set the recording format (i.e. sampling rate, number of channels (mono/stereo) and bit depth) of a specific recording device as seen in BASS_RECORDINFO class (WaveFormat property)?

Or if that's not doable, how can I get the bit depth, that has been determined in the windows sound settigs for that device?

________________________________________________________________________________________________________

Edit: Ah okay, I can just set it in the Bass.BASS_RecordStart call :-)

________________________________________________________________________________________________________

But when calling this (VB.NET):

Bass.BASS_RecordInit(DeviceIndex)

[code]Dim RecordingDeviceInfo As New BASS_RECORDINFO
Bass.BASS_RecordGetInfo(RecordingDeviceInfo)

I am trouble getting the supported formats for that device:

Qualities = ListRecordingQualities(RecordingDeviceInfo)
Public Function ListRecordingQualities(argInfo As BASS_RECORDINFO) As ObservableCollection(Of Model.RecDeviceInfo)

    Dim resultFlags = New ObservableCollection(Of BASSRecordFormat)()
    Dim allFlags As BASSRecordFormat = CType(Convert.ToInt32(argInfo.formats), BASSRecordFormat)


    For Each flag As BASSRecordFormat In [Enum].GetValues(GetType(BASSRecordFormat))
        If allFlags.HasFlag(flag) AndAlso flag <> BASSRecordFormat.WAVE_FORMAT_UNKNOWN Then
            resultFlags.Add(flag)
        End If
    Next

    Dim resQualities As New List(Of Model.RecDeviceInfo)
    For Each Quality In resultFlags
        resQualities.Add(New Model.RecDeviceInfo(Quality))
    Next
    Return New ObservableCollection(Of Model.RecDeviceInfo)(resQualities)

End Function

I keep getting BASSRecordFormat.WAVE_FORMAT_UNKNOWN, even though I tried six different devices. I also tried this:

Dim allFlags As BASSRecordFormat = CType(Convert.ToInt32(argInfo.WaveForm), BASSRecordFormat
Is this something that just might happen or is it me (respectively my code  :) )

And what's the difference in between .formats and .WaveForm ?

radio42

The record format is determined by the device initialization from which you are recording.
Channels can be made to use 32-bit floating-point sample data (see BASS_SAMPLE_FLOAT and BASS_CONFIG_FLOATDSP).

See BASS_RecordStart for details, e.g. here:
https://www.un4seen.com/doc/#bass/BASS_RecordStart.html
https://www.radio42.com/bass/help/html/5378b3fc-9c64-d097-1446-39346af86ad5.htm

Ian @ un4seen

Quote from: kafffeeIs there anyone to know how to set the recording format (i.e. sampling rate, number of channels (mono/stereo) and bit depth) of a specific recording device as seen in BASS_RECORDINFO class (WaveFormat property)?

Or if that's not doable, how can I get the bit depth, that has been determined in the windows sound settigs for that device?

BASS_RECORDINFO gives the device's native sample rate (in "freq") and channel count (in high 8 bits of "formats"), but not the bitdepth currently. The native format can only be changed in the Sound control panel (or the device's own control panel).

Quote from: kafffee    Dim allFlags As BASSRecordFormat = CType(Convert.ToInt32(argInfo.formats), BASSRecordFormat)


    For Each flag As BASSRecordFormat In [Enum].GetValues(GetType(BASSRecordFormat))
        If allFlags.HasFlag(flag) AndAlso flag <> BASSRecordFormat.WAVE_FORMAT_UNKNOWN Then
            resultFlags.Add(flag)
        End If
    Next

I keep getting BASSRecordFormat.WAVE_FORMAT_UNKNOWN, even though I tried six different devices.

Those WAVE_FORMAT_xxx flags are from the old days (from DirectSound), and are now only still set in "formats" on Windows XP and older. You can record at any sample rate due to resampling, so those flags are/were quite useless.

kafffee

#3
QuoteThe native format can only be changed in the Sound control panel (or the device's own control panel).

With "native format" you mean the default settings of the device?

QuoteYou can record at any sample rate due to resampling, so those flags are/were quite useless.
Okay, that sounds good. Can I also set the number of channels and bit depth to any value I want in Bass.BASS_RecordStart?

Ian @ un4seen

Quote from: kafffeeWith "native format" you mean the default settings of the device?

The native format is the one set in the Sound control panel. When you record in that format, no resampling is required.

Quote from: kafffeeCan I also set the number of channels and bit depth to any value I want in Bass.BASS_RecordStart?

You can use any bitdepth (from 8-bit int / 16-bit int / 32-bit float) but the channel count shouldn't exceed 2 (stereo) unless the device supports more than 2. The number of supported channels is in the high 8 bits of the BASS_RECORDINFO "formats" field (BASS.Net also has a "Channels" field for that).