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

poqut

  • Posts: 20
Re: BASS.NET API 2.4.17.0
« Reply #1575 on: 3 Nov '22 - 09:42 »
Yes, my project is .Net 6.0 WPF project, so I was using core version of previous bass.net too.

Anyways, I reverted back to previous bass.net for now since I had some issues with BASS_Mixer_ChannelSetPosition too.

I will try again in the future when I have enough time and report back if I have any issues.

Thank you.

radio42

  • Posts: 4839
Re: BASS.NET API 2.4.17.0
« Reply #1576 on: 3 Nov '22 - 12:06 »
Sorry, but the previous .Net core version also had the same limitation.
I guess you used the regular Bass.Net version (which is the same as the full framework version) even in the previous version, which for WPF you can still perfectly use. As such, no need to go back...

poqut

  • Posts: 20
Re: BASS.NET API 2.4.17.0
« Reply #1577 on: 3 Nov '22 - 13:26 »
I'm currently using Bass.Net 2.4.14.1 from core folder which has 501kb filesize.

It has both methods and they work well, I can load dlls from a subfolder.

I will try soon but you mean that I can use Bass.Net 2.4.17 from full directory in the zip with .Net 6.0?

Since my project is .Net 6.0, I was thinking that I have to use core version.

radio42

  • Posts: 4839
Re: BASS.NET API 2.4.17.0
« Reply #1578 on: 3 Nov '22 - 18:18 »
No, then you have used them, but they actually only work on Windows and have actually be present by accident.

The full version uses the .Net version 4.8 (and not 6.0 core) - but if you only target Windows with WPF, you might use that version.

If you target .Net 6.0 core, you must use the core version and this doesn't support LoadMe etc. anymore, as these are not platform independent and only support Windows.

poqut

  • Posts: 20
Re: BASS.NET API 2.4.17.0
« Reply #1579 on: 4 Nov '22 - 15:23 »
I'm currently on WPF but soon I will move to crossplatform world via MAUI, that's why I'm targeting .Net 6.0 to make transition easier a bit.

So, today I've tried 2.4.17 again and gave up on all LoadMe() calls.

Supported formats are ok but for FLAC I had to use BASS_FLAC_StreamCreateFile, because I had issues (setposition and getlength) with BASS_StreamCreateFile.

After a while I saw that BASS_PluginLoad method and applied it like BASS_PluginLoad("bassflac"). After that I can be able to use BASS_StreamCreateFile without any issues.

Am I doing something wrong or is it mandatory -for other platforms too- to use BASS_PluginLoad even if the bassflac plugin file is at the same place?

radio42

  • Posts: 4839
Re: BASS.NET API 2.4.17.0
« Reply #1580 on: 4 Nov '22 - 20:55 »
Yes, you need to call the BASS_PluginLoad for any add-on formats in order to use the native BASS_StreamCreateFile method also for those formats.

radio42

  • Posts: 4839
Re: BASS.NET API 2.4.17.2
« Reply #1581 on: 25 Nov '22 - 07:53 »
24.11.2022 version 2.4.17.2 is out.

Some enhancements to the broadcast class.
And finally a .Net core NuGet package is available:


Full Install:
 www.un4seen.com/filez/4/Bass24.Net.zip

NuGet Package (.Net core only):
 www.nuget.org/packages/radio42.Bass.Net.core

syryo

  • Posts: 33
Re: BASS.NET API 2.4.17.2
« Reply #1582 on: 10 Dec '22 - 17:15 »
I am developing a tiny MIDI player in VB.NET using latest version of BASS.NET.
I want to refresh a form with program changes occurring when playing the MIDI file so the program acts like this:
'Get all program changes in MIDI file
 Dim NevProg = BASS_MIDI_StreamGetEvents(Stream, -1, MIDI_EVENT_PROGRAM, Nothing)
'allocate Event array and get the events
Dim ProgEv() = Array.Empty(Of BASS_MIDI_EVENT)
Dim NevProg = BASS_MIDI_StreamGetEvents(Stream, -1, MIDI_EVENT_PROGRAM, ProgEv)

'Set a sync proc for one event, just to try
Dim PCSyProc = New SYNCPROC(AddressOf ProgramSync)
If BASS_ChannelSetSync(Stream, BASS_SYNC_POS, ProgEv(3).pos, PCSyProc, Me.Handle) = 0 Then BassMes("Syncing program change")
...

Private Delegate Sub UpdateUIDelegate(ByVal channel As Integer, data As Integer)

Private Sub ProgramSync(handle As Integer, channel As Integer, data As Integer, user As IntPtr)
  ...
  Me.Invoke(New UpdateUIDelegate(AddressOf UpdProgram), New Object() {channel, data})
End Sub

Private Sub UpdProgram(ByVal channel As Integer, data As Integer)

   how can I get channel and program change?

End Sub

Thanks.

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS.NET API 2.4.17.2
« Reply #1583 on: 12 Dec '22 - 14:03 »
Rather than setting a separate BASS_SYNC_POS sync at the position of each program change, I would suggest setting a single BASS_SYNC_MIDI_EVENT sync with param=MIDI_EVENT_PROGRAM for all program changes. Something like this:

Code: [Select]
BASS_ChannelSetSync(midihandle, BASS_SYNC_MIDI_EVENT, MIDI_EVENT_PROGRAM, ProgramSyncProc, 0); // set sync on all MIDI_EVENT_PROGRAM events

...

void CALLBACK ProgramSyncProc(HSYNC handle, DWORD channel, DWORD data, void *user)
{
int midichan = HIWORD(data); // MIDI channel number
int program = LOWORD(data); // new program number
...
}

syryo

  • Posts: 33
Re: BASS.NET API 2.4.17.2
« Reply #1584 on: 14 Dec '22 - 12:00 »
Thank you Ian, it's working now following your suggestions.
Now I'm facing up to compute remaining time when the tempo of MIDI is changed on going by user.
Is it possible? Any suggestions?

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS.NET API 2.4.17.2
« Reply #1585 on: 14 Dec '22 - 15:35 »
If you're using the BASS_ATTRIB_MIDI_SPEED option to adjust the tempo then you can calculate the time remaining (in seconds) like this:

Code: [Select]
double remsecs = BASS_ChannelBytes2Seconds(handle, BASS_ChannelGetLength(handle, BASS_POS_BYTE) - BASS_ChannelGetPositon(handle, BASS_POS_BYTE)) / speed;

Where "speed" is the BASS_ATTRIB_MIDI_SPEED setting.

syryo

  • Posts: 33
Re: BASS.NET API 2.4.17.2
« Reply #1586 on: 14 Dec '22 - 23:48 »
Using BASS_ATTRIB_MIDI_SPEED as you suggested, now it's working.
Thanks a lot!

syryo

  • Posts: 33
Re: BASS.NET API 2.4.17.2
« Reply #1587 on: 29 Dec '22 - 14:12 »
For my tiny MIDI player I would like to add a "VU meter" for each of 16 channels in a MIDI file.
Do I have to filter all notes  and calculate for each the "power" (f.i. considering velocity, volume, expression...) or is there any simpre way to do it?
Please give me some suggestions once again.

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS.NET API 2.4.17.2
« Reply #1588 on: 29 Dec '22 - 17:10 »
One way you could implement per-channel VU meters is by using BASS_MIDI_StreamGetChannel on each channel and then setting a DSPPROC on them (via BASS_ChannelSetDSP) to measure the level of the data. But note that doing so will disable per-key (including per-drum) reverb/chorus levels. Also note that it will give the current decoding levels, which will be ahead of what's heard due to buffering, so you would need to delay using the level readings to compensate for that (or disable buffering via BASS_ATTRIB_BUFFER).

If just knowing when notes are played will suffice then you can again use a BASS_SYNC_MIDI_EVENT sync for that, this time with param=MIDI_EVENT_NOTE.

Code: [Select]
BASS_ChannelSetSync(midihandle, BASS_SYNC_MIDI_EVENT, MIDI_EVENT_NOTE, NoteSyncProc, 0); // set sync on all MIDI_EVENT_NOTE events

...

void CALLBACK NoteSyncProc(HSYNC handle, DWORD channel, DWORD data, void *user)
{
int midichan = HIWORD(data); // MIDI channel number
int key = LOBYTE(data); // key number
int vel = HIBYTE(data); // velocity (0=released)
...
}

If needed, you can get the current volume (MIDI_EVENT_VOLUME) and expression (MIDI_EVENT_EXPRESSION) values from BASS_MIDI_StreamGetEvent.

syryo

  • Posts: 33
Re: BASS.NET API 2.4.17.2
« Reply #1589 on: 31 Dec '22 - 13:51 »
I don't want to give up to reverb and chorus effects so I choose the second approach.
I had some trouble to decode "data" but finally I got it in the followind way, please have a look at it:
 Private Sub UpdNote(ByVal Data As Integer)
    Dim MidiCh = Utils.HighWord32(Data)
    Dim LBl = Utils.LowWord(Utils.LowWord32(Data))
    Dim Key = LBl Mod 256
    Dim Vel = CInt(LBl / 256)
...
  End Sub

Thank you and happy new year!

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: BASS.NET API 2.4.17.2
« Reply #1590 on: 2 Jan '23 - 14:34 »
Just to be clear, using BASS_MIDI_StreamGetChannel won't disable reverb/chorus entirely, it'll just disable per-key levels, ie. all keys in the channel will have the same reverb/chorus levels. But per-key levels are pretty important in drum channels at least, so I would favour the second approach too if possible.

jpf

  • Posts: 196
Re: BASS.NET API 2.4.17.2
« Reply #1591 on: 19 Jan '23 - 04:28 »
I have an app developed in VB.NET 2008. VB.NET running on a 32 bit Windows XP OS. The app runs without errors there.
Today I installed VB 2008 in a 64 bit notebook running Windows 10, copied the app project folder from the original location and started the debugger.

The execution stops at this line:
BassExists = Not (Bass.BASS_GetVersion(2) < ExpectedVersion)
with error  0x8007000B = 'System.BadImageFormatException' in Bass.Net.dll

I then installed my app in the same notebook from the installer created in Windows XP.
The same error occurs at the same line.

Bass.Net.dll version 2.4.7.4
bass.dll version 2.4.1.1

What am I doing wrong?

I thought of updating Bass.net and bass but I want to be sure that that's needed.

According to Microsoft, VB.NET 2008 creates only 32 bit apps.

radio42

  • Posts: 4839
Re: BASS.NET API 2.4.17.2
« Reply #1592 on: 19 Jan '23 - 11:30 »
When switching to 64bit, you need to replace ALL native BASS libs (dlls) with their 64bit version.

jpf

  • Posts: 196
Re: BASS.NET API 2.4.17.2
« Reply #1593 on: 20 Jan '23 - 01:55 »
Yes, I realize that. Thanks for your help!

I thought my app was 32 bit but looking at the Task Manager it turned out that it's running on 64 bit. This is new to me. At Microsoft forum I found instructions for setting VB.NET 2008 to compile for X86 platform. I tried to set that but on the VB.Net 2008 Express edition I have the Compile for Platform dropdown menu has only one item: AnyCPU.

So I guess my app is compiled for AnyCPU and I can't change that.

According to Microsoft those AnyCPU executables run on 64 bit when the OS is 64 bit and on 32 bit when the OS is 32 bit.

I guess Bass.Net.dll is compiled for AnyCPU too (?).

I could settle for 64 bit if I had all of the dlls I need in 64 bit. Bass and its plugins have 64 bit versions, but my app also uses other dlls with no 64 bit version available.

I developed a couple of those dlls on VC++ 6.0, which I believe doesn't have a 64 bit compiler, but I'm not sure. I must check.

Others are 3rd party; most notably a few freeware Vst, not opencode and abandoned.

So I'd like to keep the app with all its dependencies running on 32 bit on 64 bit OS as well as on 32 bit OS.

I found an app that promisses to launch AnyCPU executables at 32 bit: RunAsX86.exe. I didn't try it yet.

Arte you aware of any other way to get what I want?

radio42

  • Posts: 4839
Re: BASS.NET API 2.4.17.2
« Reply #1594 on: 20 Jan '23 - 06:15 »
The easiest way is to compile your app as a 32bit app. So you might consider to upgrade your VS environment.
I am not aware of any other easy way, as this is the recommended way by Microsoft.

jpf

  • Posts: 196
Re: BASS.NET API 2.4.17.2
« Reply #1595 on: 20 Jan '23 - 16:50 »
I reckon I should upgrade my hardware to be able to run a higher VS version. This is not a priority now. I once tried VS 2010 Express and my PC crawled, eventually freezing.

Thanks!

radio42

  • Posts: 4839
Re: BASS.NET API 2.4.17.2
« Reply #1596 on: 20 Jan '23 - 18:23 »
With the free VS community Edition you can compile for Any, x86, x64 and ARM64 targets.
So that should not be an issue.

jpf

  • Posts: 196
Re: BASS.NET API 2.4.17.2
« Reply #1597 on: 20 Jan '23 - 22:02 »
According to Microsoft, VS comunity version 2022 won't run on my 32 bit PC. Also VS comunity version 2022 won't open the project I wrote on VS 2008 Express. The 64 bit notebook I mentioned isn't mine and I must bring it back; I installed my app in it to check for compatibility but I won't use it for further development. So no, VS comunity version is not an option just now.

I still didn't try RunAsX86.exe. If it doesn't do the trick and no other easy option appears I'll just let it be.

radio42

  • Posts: 4839
Re: BASS.NET API 2.4.17.2
« Reply #1598 on: 21 Jan '23 - 08:44 »
I don’t know your special cases and projects. But in general you can compile projects for the different targets as mentioned with the community edition of VS.

jpf

  • Posts: 196
Re: BASS.NET API 2.4.17.2
« Reply #1599 on: 21 Jan '23 - 14:09 »
Never mind. Mine is an ill case. You've been very helpfull and your library has been my reason and inspiration to learn VB.NET. Otherwise I'd be stuck on VS 6.0 (which is still my main coding environment). If I find a no cost way around my problem I'll post it here.

For those who may have related issues, I'll share some details of my tests:
"RunAsX86.exe SrtCreator.exe" didn't do the trick. It fails with error "Can't find an entry point".

At least 2 of the dlls that don't seem to have x64 versions were released in this very forum:
BASS_FFMPEG https://www.un4seen.com/forum/?topic=15372.0
Like other projects by Ionut Cristea, this one seems abandoned. The x86 version works fine for me, anyway.
BASS_DTS https://github.com/aidan-g/BASS_DTS
I don't know where I got the compiled BASS_DTS dll and I can't find it right now. I may have compiled it myself and later deleted it. There's fork for a x64 version at https://github.com/aidan-g/BASS_DTS/tree/x64 but it's incomplete (doesn't load as a plugin) and seems abandoned.

I mention those because their creators are members of the forum and may be moved to continue their development. My project uses quite a lot of dlls and I've been searching for x64 versions of quite a few of them so far. I may still find others released here with no x64 support. If I do I'll add them to the list.