Author Topic: Add Input Device (for instance microphone) to mix  (Read 919 times)

Ian @ un4seen

  • Administrator
  • Posts: 24494
Re: Add Input Device (for instance microphone) to mix
« Reply #25 on: 20 Jun '22 - 12:58 »
I am using bass version 33820416. and there seems no BASS_CONFIG_REC_WASAPI being implemented:

That is 2.4.15, so not the latest. Please try upgrading to the latest BASS version, which uses WASAPI recording by default, and see what result you get then.

There seems to be no BASS_ChannelGetLevelEx implemented:

As Chris says, BASS_ChannelGetLevelEx is called BASS_ChannelGetLevels in BASS.Net.

kafffee

  • Posts: 107
Re: Add Input Device (for instance microphone) to mix
« Reply #26 on: 21 Jun '22 - 14:19 »
OK, I got the current version of bass.dll and bassnet.dll from the downloads section and now theres no latency any more, even without BASS_ChannelGetLevel(s).

I am doing it this way now:

Code: [Select]
peak = Bass.BASS_ChannelGetLevels(MikroInput)
       
        If peak(0) > 0.15 Then
            Timer1.Interval = 1750
            If WirdGesprochen = False Then
                Dim success As Boolean = Bass.BASS_ChannelSlideAttribute(streamA, BASSAttribute.BASS_ATTRIB_VOL, 0.2, 100)
                Debug.WriteLine("leiser stellen erfolgreich" & CStr(success))
                WirdGesprochen = True
            End If
        Else
            Timer1.Interval = 100
            If WirdGesprochen = True Then
                Dim success As Boolean = Bass.BASS_ChannelSlideAttribute(streamA, BASSAttribute.BASS_ATTRIB_VOL, 1, 300)
                Debug.WriteLine("lauter stellen erfolgreich" & CStr(success))
                WirdGesprochen = False
            End If
        End If

For my mono mic, I guess you recommend BASS_LEVEL_MONO, right? What would you recommend for length? You can see my timer's interval in the code... And is it important in this case to use peak(0) (mono channel returns value in index 0 right?)

Ian @ un4seen

  • Administrator
  • Posts: 24494
Re: Add Input Device (for instance microphone) to mix
« Reply #27 on: 21 Jun '22 - 17:00 »
If the recording channel is mono (chans=1) then there's no need to use the BASS_LEVEL_MONO flag, as the level reading will be mono by default, but it'll do no harm. The level will indeed be returned in index 0 of the array. If you're getting the level every 100ms then the length parameter should probably be 0.1. If "MikroInput" is plugged in a mixer, you should also use the BASS_LEVEL_NOREMOVE flag (defined as 16) in the call to avoid taking data away from the mixer (resulting in discontinuities/skips).

kafffee

  • Posts: 107
Re: Add Input Device (for instance microphone) to mix
« Reply #28 on: 22 Jun '22 - 17:52 »
In which call should I use BASS_LEVEL_NOREMOVE? There is no such flag implemented when I call either BASS_ChannelGetLevels, BASS_Mixer_StreamCreate or BASS_RecordStart...

I got the bass(net).dll from the downloads section, has there anything else been renamed?

Guest

  • Guest
Re: Add Input Device (for instance microphone) to mix
« Reply #29 on: 22 Jun '22 - 19:50 »
Code: [Select]
If WirdGesprochen = False Thenbad code style

Code: [Select]
If not IsSpeak then  and
Code: [Select]
If IsSpeak then
should be better..
do not check of True or False part an use for programming better english

kafffee

  • Posts: 107
Re: Add Input Device (for instance microphone) to mix
« Reply #30 on: 23 Jun '22 - 14:11 »
@Guest

Thanks for the hint, I'm relatively new to this. I have always been wondering what the difference is between Is/IsNot and =True/=False.... Is there any at all?

Also I am usually naming my elements in German because it's less confusing for me to read. I can see at one glance whether it's named by me or it's a "foreign" Element or keyword.
I will try my best to use english namings at least when I'm in an english-speaking forum... You are right it might be easier for readers to understand...

Ian @ un4seen

  • Administrator
  • Posts: 24494
Re: Add Input Device (for instance microphone) to mix
« Reply #31 on: 23 Jun '22 - 15:40 »
In which call should I use BASS_LEVEL_NOREMOVE? There is no such flag implemented when I call either BASS_ChannelGetLevels, BASS_Mixer_StreamCreate or BASS_RecordStart...

Unfortunately, BASS.Net doesn't include the BASS_LEVEL_NOREMOVE flag yet, but you can use its numeric value (16) instead, like this:

Code: [Select]
peak = Bass.BASS_ChannelGetLevels(MikroInput, 0.1, (BASSLevel)16);

kafffee

  • Posts: 107
Re: Add Input Device (for instance microphone) to mix
« Reply #32 on: 26 Jun '22 - 13:07 »
@Ian

I know you re not using .NET yourself, but when I do this I get the error:

Quote
"BASSLevel" ist ein Enumerationstyp und kann nicht als Ausdruck verwendet werden.

which is something like this in English:
Quote
"BASSLevel" is a type of enumeration and cannot be used as an expression.

I looked the error up in the Microsoft docs but I don't quite understand what is being said there:

Quote
To correct this error, remove the type name and construct the expression using valid elements.

The only thing I could think of is doing this, which at least does not end up in an error:

Code: [Select]
Dim Flag As BASSLevel = 16
peak = Bass.BASS_ChannelGetLevels(MikroInput, 0.1, Flag)

Anybody know if this is the right way to do this?
« Last Edit: 26 Jun '22 - 13:14 by kafffee »

Ian @ un4seen

  • Administrator
  • Posts: 24494
Re: Add Input Device (for instance microphone) to mix
« Reply #33 on: 27 Jun '22 - 12:34 »
Oh, I see now that you're using VB.Net. I believe it needs to be a bit different then. Try this:

Code: [Select]
peak = Bass.BASS_ChannelGetLevels(MikroInput, 0.1, CType(16, BASSLevel))

kafffee

  • Posts: 107
Re: Add Input Device (for instance microphone) to mix
« Reply #34 on: 27 Jun '22 - 14:35 »
Yes that should do the same as I did, but directly without any variable. So now I can't hear any clicking or something like that.

Thank you :-)

kafffee

  • Posts: 107
Re: Add Input Device (for instance microphone) to mix
« Reply #35 on: 29 Jun '22 - 14:59 »
I have another question:

If I want to switch in between playback devices, I have to call BASS_Init for each device and then call ChannelSetDevice.

Is this also doable for recording devices and what are the method's names? I coud not find any...

Ian @ un4seen

  • Administrator
  • Posts: 24494
Re: Add Input Device (for instance microphone) to mix
« Reply #36 on: 29 Jun '22 - 17:14 »
It isn't currently possible to move a recording to another device. You would instead need to start a new recording on the new device (use BASS_RecordSetDevice before BASS_RecordStart). If you happened to be encoding the old recording, you can move the encoder to the new one via BASS_Encode_SetChannel.

kafffee

  • Posts: 107
Re: Add Input Device (for instance microphone) to mix
« Reply #37 on: 30 Jun '22 - 11:07 »
Ok thanks it works :)