Author Topic: BASS.NET API 2.4.17.5  (Read 1128196 times)

santanutosh

  • Posts: 30
Re: BASS.NET API 2.4.14.1
« Reply #1550 on: 4 Sep '20 - 20:00 »
I create 2 streams from 2 different audio files of same freq, channels and bitrate.
Code: [Select]
stream1=Bass.BASS_StreamCreateFile(file1, 0, 0, BASSFlag.BASS_STREAM_DECODE)
stream2=Bass.BASS_StreamCreateFile(file2, 0, 0, BASSFlag.BASS_STREAM_DECODE)
mixer=BassMix.BASS_Mixer_StreamCreate(FileInfo.freq, FileInfo.chans, BASSFlag.BASS_STREAM_DECODE)
BassMix.BASS_Mixer_StreamAddChannel(mixer, stream1, BASSFlag.BASS_MIXER_BUFFER)
BassMix.BASS_Mixer_StreamAddChannel(mixer, stream2, BASSFlag.BASS_MIXER_BUFFER)
Then I create a mixer and add the stream channels in the mixer. Then I set an encoder on the mixer as I need the mixed audio in another file.
Code: [Select]
encHandle=BassEnc.BASS_Encode_Start(mixer, fileName, BASSEncode.BASS_ENCODE_PCM Or BASSEncode.BASS_ENCODE_FP_16BIT, Nothing, 0)Then I use the following to get the mixed data.
Code: [Select]
While len > 0
    len= BassMix.BASS_Mixer_ChannelGetData(stream1, buffer, buffer.Length)
    len= BassMix.BASS_Mixer_ChannelGetData(stream2, buffer, buffer.Length)
End While
BassEnc.BASS_Encode_Stop(encHandle)
I do not know if I'm doing right or wrong. But I'm only getting a 0Kb audio file as an output. Please help me.

santanutosh

  • Posts: 30
Re: BASS.NET API 2.4.14.1
« Reply #1551 on: 6 Sep '20 - 10:56 »
Quote
I have been trying the Utils.GetNormalizationGain function to check the Peak and Gain factor of an Audio file. Then if required I would apply this gain factor to the same audio and save it as a new audio file.
Okay. I solved it.
Code: [Select]
fxHandle = Bass.BASS_ChannelSetFX(_stream, BASSFXType.BASS_FX_VOLUME, 0)
Dim par As New BASS_FX_VOLUME_PARAM
par.fTarget = par.fCurrent * vol
Bass.BASS_FXSetParameters(fxHandle, par)
vol = Gain % delivered by GetNormalizationGain function. After this, Bass.BASS_ChannelGetData(_stream, buffer, buffer.Length) returns the modified data.  :)

santanutosh

  • Posts: 30
Re: BASS.NET API 2.4.14.1
« Reply #1552 on: 6 Sep '20 - 11:05 »
I have a question regarding the Marker used in WaveForm Class. As given in documentation, we can have Markers of different Color and Alignment by using "{...}" in the Marker Name.
Is it also possible to have Markers of different lengths? I tried by putting "{Length=0.5}", but didn't work. Also, if the vertcal position of an individual Marker could be altered, it would be very nice.
Thank you.

radio42

  • Posts: 4839
Re: BASS.NET API 2.4.14.1
« Reply #1553 on: 6 Sep '20 - 16:36 »
All Markers are drawn with the same length using the global MarkerLength property.

toob

  • Posts: 137
BASS_ChannelGetLevel via BassWasapi latency
« Reply #1554 on: 13 Sep '20 - 12:19 »
My goal is to show audio db levels via VU meters from Windows speaker output. It's my understanding I should use BassWasapi to capture the speaker output into a stream. Then use a timer event (or a loop) and use BASS_ChannelGetLevel on the stream to get left and right values for the VU meters.
The code below does this but the values output by BASS_ChannelGetLevel are approx 3 seconds behind the speaker output. For example if I stop the music playing BASS_ChannelGetLevel keeps outputting values greater than say 0.1 for 3 seconds. Likewise if I restart the track BASS_ChannelGetLevel does not output values above 0.1 for 3 seconds.
I have tried setting _wasapi.SetFullDuplex buffer to true and false without any noticeable difference.
3 is my Windows speaker output loopback channel device number.

What is causing the 3 second delay and how can I fix it?

Code: [Select]
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click

        Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)
        err = Bass.BASS_ErrorGetCode()
        If Not err = 14 Then
            If err > 0 Then
                MsgBox("bass error " & err.ToString)
                Exit Sub
            End If
        End If

        '3 = loopback speaker output
        _wasapi = New BassWasapiHandler(3, False, 44100, 2, 0, 0.0F)
        _wasapi.Init()
        _wasapi.SetFullDuplex(0, BASSFlag.BASS_STREAM_DECODE, False)
        vu_stream = _wasapi.OutputChannel
        If _wasapi.DeviceMute Then
            _wasapi.DeviceMute = False
        End If
        _wasapi.Start()


        vu_timer.Interval = 50
        vu_timer.Start()

    End Sub

    Private Sub vu_timer_Tick(sender As System.Object, e As System.EventArgs) Handles vu_timer.Tick

        Dim left_val As Double = 0
        Dim right_val As Double = 0

        Dim Levels(2) As Single
        Bass.BASS_ChannelGetLevel(vu_stream, Levels, 0.02, BASSLevel.BASS_LEVEL_STEREO)
        left_val = Levels(0) * 100
        right_val = Levels(1) * 100

        Me.Text = left_val

        If left_val > 0.1 Then
            final_delay_left = False
            last_left_val = left_val
            Me.AGauge1.Value = left_val
        Else
            If final_delay_left = False Then
                final_delay_left = True
                Dim t = New Thread(Sub() Me.NeddleDecayLeft(last_left_val))
                t.Start()
            End If
        End If

    End Sub

Thanks

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS.NET API 2.4.14.1
« Reply #1555 on: 14 Sep '20 - 13:21 »
The latency will likely be caused by buffering in the intermediate stream. I don't think you need that stream, ie. you can get the level directly from the input/recording. I'm not very familiar with the BassWasapiHandler class so I'm not sure how to best use that, but you could call BASS_WASAPI_Init to initialize and then use BASS_WASAPI_GetLevel(Ex) to get the levels instead. Alternatively, you could use the regular BASS recording functions instead of BASSWASAPI, ie. BASS_RecordInit/Start and BASS_ChannelGetLevel(Ex), as BASS itself supports WASAPI loopback recording too.

If you just want to display the level (no other processing of the data) then another option is to simply use BASS_WASAPI_GetDeviceLevel instead. There's no need to even initialize the device for that. For example:

Code: [Select]
float left = BassWasapi.BASS_WASAPI_GetDeviceLevel(device, 0);
float right = BassWasapi.BASS_WASAPI_GetDeviceLevel(device, 1);

Please see the documentation for details on the mentioned functions.

toob

  • Posts: 137
Re: BASS.NET API 2.4.14.1
« Reply #1556 on: 15 Sep '20 - 13:49 »
Code: [Select]
float left = BassWasapi.BASS_WASAPI_GetDeviceLevel(device, 0);
float right = BassWasapi.BASS_WASAPI_GetDeviceLevel(device, 1);

Thanks Ian that last option worked a treat and more concise for my VU meters.

I use the code below to feed a spectrum visuals stream and also to breakdown FFT frequencies into low/mid/hi ranges to drive DMX lighting on another stream, using two separate timers. The code works fine but your simplified answer above got me thinking if BassWasapiHandler is the best / most effective method to get the live windows speaker output for either the spectrum visuals or FFT data for the low/mid/hi freq triggering?

Code: [Select]
        _wasapi1 = New BassWasapiHandler(3, False, 44100, 2, 0.0F, 0.0F)
        _wasapi1.Init()
        _wasapi1.SetFullDuplex(0, BASSFlag.BASS_DEFAULT Or BASSFlag.BASS_STREAM_DECODE, False)
        _wasapi1.DeviceMute = False
        _wasapi1.DeviceVolume = 1.0F
        spectrum_stream = _wasapi1.OutputChannel
        bassmidhi_stream = _wasapi1.OutputChannel
        _wasapi1.Start()

       start_timers...

teq

  • Posts: 80
Re: BASS.NET API 2.4.14.1
« Reply #1557 on: 18 Jul '21 - 18:04 »
Hi there! Recently i've decided to port my app(Unity) to macOS, but i face with issue.
There is no Waveform class under Un4seen.Bass.Misc. It's strange because under Windows it's totally fine.
And of course i use macOS version of bass.h and Bass.Net.OSX.

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS.NET API 2.4.14.1
« Reply #1558 on: 19 Jul '21 - 16:42 »
If I recall correctly, BASS.Net's Waveform class requires features that are only available on Windows, so it unfortunately isn't supported on other platforms.

radio42

  • Posts: 4839
Re: BASS.NET API 2.4.14.1
« Reply #1559 on: 3 Aug '21 - 19:21 »
Correct!

DividedSE

  • Posts: 6
Re: BASS.NET API 2.4.14.1
« Reply #1560 on: 25 Aug '21 - 18:53 »
As .net framework is almost dead with VS2022.. .will there be any update (last updatew in 2019) for .net 5/6 optimising with c# 9/10... & Support for waveform & visuals with Systems.Drawing.Common(which is crossplatform) now widely used from Microsoft Nuget as microsoft pushing for it itself.
I myself used it bass.net.dll in .net5 wpf app with system.drawing.common by microsoft & it successfully works on waveform & visuals. So if it works please add official support of it.

radio42

  • Posts: 4839
Re: BASS.NET API 2.4.14.1
« Reply #1561 on: 26 Aug '21 - 21:47 »
Hi DividedSE,

there is already support for .Net core in Bass.Net. But I am not sure, if I will add support to the .Net code version for the WaveForm and Visuals.
The current implementation of the the WaveForm and Visuals are indeed targeted for the .Net framework, but also only additions on top for fun.

So maybe the current idea is to provide that as open source to the public, so everyone who wants can use that and convert as wanted - but that is my current idea only, I am still not sure about it.
But would you like to support that idea and add your stuff as well to the public?

serkanp

  • Posts: 135
Re: BASS.NET API 2.4.14.1
« Reply #1562 on: 4 Jan '22 - 22:52 »
hi 
i am using dotnet standart version of your wrapper and that is working in linux, macos , windows.  (i am using it with unity also)
i have a problem with lame EncoderCommandLine..
it always sets  "lame.exe"
but on linux or macos, installed lame is not named as lame.exe..
it is where it is and the name is just lame, and you can call it system-wide..
so how can we override/change lame.exe name on EncoderCommandLine ?

serkanp

  • Posts: 135
Re: BASS.NET API 2.4.14.1
« Reply #1563 on: 5 Jan '22 - 11:56 »
hi 
i am using dotnet standart version of your wrapper and that is working in linux, macos , windows.  (i am using it with unity also)
i have a problem with lame EncoderCommandLine..
it always sets  "lame.exe"
but on linux or macos, installed lame is not named as lame.exe..
it is where it is and the name is just lame, and you can call it system-wide..
so how can we override/change lame.exe name on EncoderCommandLine ?


when F12 on EncoderLame on visual studio2022, it decompiles and your sourcecode seems hardcoded lame.exe
Code: [Select]
private string BuildEncoderCommandLine()
        {
            CultureInfo provider = new CultureInfo("en-US", useUserOverride: false);
            StringBuilder stringBuilder = new StringBuilder();
            if (!string.IsNullOrEmpty(base.EncoderDirectory))
            {
                stringBuilder.Append("\"" + Path.Combine(base.EncoderDirectory, "lame.exe") + "\"");
            }
            else
            {
                stringBuilder.Append("lame.exe");
            }
.
.
.
}

you must put an option to change lame.exe name... :)

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS.NET API 2.4.14.1
« Reply #1564 on: 5 Jan '22 - 16:31 »
Instead of using a separate LAME executable, you could use the BASSenc_MP3 add-on. It supports most common LAME options (please see the documentation for a full list).

serkanp

  • Posts: 135
Re: BASS.NET API 2.4.14.1
« Reply #1565 on: 5 Jan '22 - 17:17 »
Instead of using a separate LAME executable, you could use the BASSenc_MP3 add-on. It supports most common LAME options (please see the documentation for a full list).

thanks for the reply Ian.. thats what i am exactly looking for..
it seems that it can work on ios and android..

ps: radio42 made an excellent wrapper for the encoders.. i was using and implementing his features.. but, i have to implement native bass features instead of his encoder wrappers..

cheers..

vassilis

  • Posts: 3
Re: BASS.NET API 2.4.14.1
« Reply #1566 on: 17 Mar '22 - 09:04 »
Hi,
I'm trying to set the following FX:

Code: [Select]
var envFxHandle = Bass.BASS_ChannelSetFX(track.StreamHandle, BASSFXType.BASS_FX_BFX_VOLUME_ENV, 0);

BASS_BFX_ENV_NODE[] nodes =
{
  new BASS_BFX_ENV_NODE(0, 0f),
  new BASS_BFX_ENV_NODE(track.CuePoints.Start.Value + track.CuePoints.FadeIn, 1f),
};

Bass.BASS_FXSetParameters(envFxHandle, new BASS_BFX_VOLUME_ENV(nodes));

It throws the following exception::

Code: [Select]
System.Runtime.InteropServices.COMException: 'Typelib export: Type library is not registered. (0x80131165)'
Any help? This drives me crazy for hours.

[Framework: .NET 6, Windows]

radio42

  • Posts: 4839
Re: BASS.NET API 2.4.14.1
« Reply #1567 on: 17 Mar '22 - 18:05 »
The BASS_BFX_VOLUME_ENV class exists in the BASS_FX add-on.
So you need to load that beforehand - did you do that?
I.e. did you call BassFx.BASS_FX_GetVersion();  ? This will load the BassFx add-on automatically...

vassilis

  • Posts: 3
Re: BASS.NET API 2.4.14.1
« Reply #1568 on: 17 Mar '22 - 19:14 »
It was one of the first things I tried but unfortunately the problem remains.

vassilis

  • Posts: 3
Re: BASS.NET API 2.4.14.1
« Reply #1569 on: 19 Mar '22 - 13:18 »
Any help? I really got stuck here. Do you suspect it is specific to .NET Core?

Guest

  • Guest
Re: BASS.NET API 2.4.14.1
« Reply #1570 on: 19 Mar '22 - 18:21 »
load Bass FX if your want use it in your Project from add-ons Site here
and put it to your Exe path.

Bello

  • Posts: 43
Re: BASS.NET API 2.4.14.1
« Reply #1571 on: 6 Apr '22 - 09:32 »
So maybe the current idea is to provide that as open source to the public, so everyone who wants can use that and convert as wanted - but that is my current idea only, I am still not sure about it.

That might be a good option!
My application is currently on 4.8 but we'll have to move to 6, 7, ... at some point.

radio42

  • Posts: 4839
Re: BASS.NET API 2.4.17.0
« Reply #1572 on: 11 Oct '22 - 22:15 »
11.10.2022: Version 2.4.17.0 is out!

Finally a full update after a long time...

Note:
        - Added support for .Net 6.0 (core)
        - Added support for .Net 4.8 (full)
        - Removed all other platform specific builds (no need anymore, so its time to update)
        - BASS: added support for v2.4.17.0
        - add-ons: all latest versions!

Other fundamental changes:
The used .Net Frameworks are now only the Full and the Core versions, which makes deployment and configuration much more easy.
The Encoder and Broadcasting Framework now supports all BASSenc_XXX add-ons.
iOS now uses dynamic linking (instead of static), just like any other platform, so make sure to always also update to all latest native BASS, plug-in and add-on versions!

core: .Net 6.0 fully supports platform independent development for Windows, Linux, macOS, Android or iOS - no other extra version/build is needed.
         The only limitation with this version is, that any Drawing or Image specific classes or functions have been excluded, like the Visual and WaveForm.

full: uses the .Net 4.8 full framework to target Windows development including any Drawing or Image specific classes or functions.


Full Install:
 www.un4seen.com/filez/4/Bass24.Net.zip
« Last Edit: 12 Oct '22 - 15:57 by radio42 »

poqut

  • Posts: 20
Re: BASS.NET API 2.4.17.0
« Reply #1573 on: 2 Nov '22 - 12:06 »
11.10.2022: Version 2.4.17.0 is out!

Hey,

I've just updated to 2.4.17 for my .Net 6 WPF project.

I was putting bass and addons dlls to a folder and using them via LoadMe() and BASS_PluginLoadDirectory() methods.

Now it says "Bass does not contain a definition for LoadMe" and also for others there is same error.  BASS_PluginLoadDirectory() still exists though.

Is LoadMe removed or replaced with something?
« Last Edit: 2 Nov '22 - 12:13 by poqut »

radio42

  • Posts: 4839
Re: BASS.NET API 2.4.17.0
« Reply #1574 on: 2 Nov '22 - 18:29 »
These methods do still exist for the FullFramework version, as the LoadMe() and BASS_PluginLoadDirectory() methods do use native Windows functions.

These however do not exist for the platform independent .Net core version - I assume you are using the .Net core version of Bass.Net?!