Author Topic: BASS_Init and freq ?  (Read 176 times)

Couin

  • Posts: 40
BASS_Init and freq ?
« on: 16 Jun '22 - 00:57 »
Hi friends,

On VB6 (Always Jingle Palette  ;D ), BASS_init is set with 44100.
 
As well as soundcards allows higher samplerates, like 48 or 96 kHz, is it possible :
1) to init to a higher freq than 44100 ?
2) to init to the default soundcard samplerate ?
I mean, in the Windows sound configuration, the default format.
For example, if I set 48000 here, I would BASS_init to 48000.

Possible ?

Thanks :)
Couin

jpf

  • Posts: 120
Re: BASS_Init and freq ?
« Reply #1 on: 16 Jun '22 - 07:30 »
According to Ian: "
The BASS_Init "freq" parameter has no effect on Windows (except Win9x). The sample rate is set by the user in Windows' Sound control panel these days.
On BASS_GetInfo(), the BASS_INFO "freq" value tells the device's current output rate.
"

If I understood Ian correctly, each input plugin will output at a certain samplerate depending on the decoded file's native sampleerate. If it's different from the device's current rate it will be converted in the final mix. It's a hard-to-avoid efficiency / quality penalty. If you use mixers you should set their samplerate to the value that would give less samplerate conversions (sometimes the device's current samplerate). Some input plugins may inevitably resample internally (bass_midi). Same for some FXs (tempo / pitch ?). If they have a freq/samplrate paramter you should set it to the value that would give less samplerate conversions.

You can tweak the convertion quality vs. efficiency tradeoff using BASS_SetConfig(BASS_CONFIG_SRC) and/or BASS_ChannelSetAttribute(BASS_ATTRIB_SRC).

Couin

  • Posts: 40
Re: BASS_Init and freq ?
« Reply #2 on: 16 Jun '22 - 13:48 »
Hi jpf,

Hmmm, it's a bit confusus for me .
If I init the device @44100, and I load and play a jingle recorded @48000, on a soundcard set @48000 on Windows, it will be played as a jingle recorded in 44100 ?

Also, I try to use BASS Get info , but or I'm not on the right documentation page or ? 
http://www.un4seen.com/doc/#bass/BASS_GetInfo.html

How to use in VB6 ?

Edit :

Ok, found for GetInfo from another website :

Code: [Select]
    Dim i As BASS_INFO
    ' get channel info
    Call BASS_GetInfo(i)
    MsgBox i.freq
« Last Edit: 16 Jun '22 - 14:49 by Couin »

Chris

  • Posts: 2074
Re: BASS_Init and freq ?
« Reply #3 on: 16 Jun '22 - 15:26 »
Hi, you can do it on this way.
BASS_Init(-1, 48000, BASS_DEVICE_FREQ, Handle, NULL);
Bass_GetInfo(info);
// will by me Return from Bass_Info 48000

ChannelCheck:
BASS_ChannelGetInfo(chan, Chan_info);
will return by me also (48000).
some note of the Bass Doc

//
this only affects BASS's output format, not the device's output format
BASS's output format may not necessarily match the device's output format, in which case the OS will be resampling it.
 

jpf

  • Posts: 120
Re: BASS_Init and freq ?
« Reply #4 on: 16 Jun '22 - 16:32 »
@ Chris: Maybe we need some clarification from Ian.

The documentations says: "on Vista and newer, the output format is determined by the user's choice in the Sound control panel", so I believe the Init freq param is ignored on those OS and it defaults to Window's Sound pannel seeting.

What you said: "BASS's output format may not necessarily match the device's output format, in which case the OS will be resampling it." doesen't seem true for those OSs, since now bass is doing the final mix/resampling internally.

@ Couin: Sorry I wasn't clear enough.
Quote
If I init the device @44100, and I load and play a jingle recorded @48000, on a soundcard set @48000 on Windows, it will be played as a jingle recorded in 44100 ?
As for me, in this case the freq 44100 value in your Init will be ignored and the 48000 Hz file will be played at 48000 Hz without resampling. Hope Ian can confirm or deny my statement.

Ian @ un4seen

  • Administrator
  • Posts: 24495
Re: BASS_Init and freq ?
« Reply #5 on: 16 Jun '22 - 18:05 »
That is correct. The BASS_Init "freq" parameter will have no effect on Windows Vista and newer - BASS will always use the rate set in the Sound control panel (even if you change that mid-playback). But it will have effect on older Windows because the device's rate isn't reliably available then - it will set BASS's output rate but not necessarily the device's output rate, so the OS/driver may be resampling the BASS output. If the device's output rate happens to be known on an older Windows system (eg. it's in a control panel from the manufacturer) then you should use that in the BASS_Init call for best quality/performance, eg. allow the user to set it.

Couin

  • Posts: 40
Re: BASS_Init and freq ?
« Reply #6 on: 16 Jun '22 - 22:06 »
Hi friends,

Thanks for your answer.

So, if I understand well :
- Vista and upper Windows : BASS will take the samplerate of the soundcard, regardless the freq value I put in the BASS_Init command (for example, soundcard support 48000, I init BASS with 44100, BASS will init with 48000).
- XP (and lower) : BASS wil take the samplerate of the freq value I put in the BASS_Init command, in the condition of soundcard support it (I mean if the soundcard supports max 44100, I don't set BASS_init to 48000 but 44100, and if the soundcard supports max 48000, I can set init to 48000).

Am I right ?

Ian @ un4seen

  • Administrator
  • Posts: 24495
Re: BASS_Init and freq ?
« Reply #7 on: 17 Jun '22 - 13:15 »
- Vista and upper Windows : BASS will take the samplerate of the soundcard, regardless the freq value I put in the BASS_Init command (for example, soundcard support 48000, I init BASS with 44100, BASS will init with 48000).

That is correct.

- XP (and lower) : BASS wil take the samplerate of the freq value I put in the BASS_Init command, in the condition of soundcard support it (I mean if the soundcard supports max 44100, I don't set BASS_init to 48000 but 44100, and if the soundcard supports max 48000, I can set init to 48000).

In this case, the "freq" value will be used for the BASS output even if the soundcard doesn't support it. If the soundcard is using a different output rate then BASS's output will be resampled by Windows (or the driver/soundcard itself) accordingly. So it is best to use the soundcard's rate if it is known, to avoid that extra resampling.

Couin

  • Posts: 40
Re: BASS_Init and freq ?
« Reply #8 on: 17 Jun '22 - 14:27 »
Hi Ian,

Thanks for answer :)

So I think I will leave 44100. XP machine are high probably old mahines so without a soundcard over than 44100, it's not a necessaryto risk unreliable rate detection to init BASS matching with the soundcard.