Author Topic: BASS_SFX v2.4.2.1 for winamp, sonique, bassbox, & WMP visual plugin support!  (Read 289133 times)

RevG

  • Posts: 458
FYI... I have run some preliminary tests on the BASS_SFX library on Windows 7 and everything has been working just great.

Cheers,
Greg

RevG

  • Posts: 458
Hi Guys,

I have solved the problem with the .NET examples that stop visualizing after 30 seconds. The problem was with how I coded the examples. I now use the Win32 call GetDC/ReleaseDC to grab a proper handle to a device context and all seems to work well now. Please let me know if it works for you now :)

I have uploaded new examples to the BASS_SFX and BASS_SFX_LEAN packages. Keep in mind that the source code and dll has not changed, only the C# and VB.NET example projects were modified as shown below.

C#
Code: [Select]
[DllImport("User32.dll")]
public static extern IntPtr GetDC(IntPtr hWnd);

[DllImport("User32.dll")]
public static extern Int32 ReleaseDC(IntPtr hWnd, IntPtr hDC);

....

private void frmMain_Load(object sender, EventArgs e)
        {
            hVisDC = GetDC(m_oVisPanel.Handle);
            hVisDC2 = GetDC(m_oVisPanel2.Handle);
            hVisDC3 = GetDC(m_oVisPanel3.Handle);

.....

 private void frmMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            ReleaseDC(m_oVisPanel.Handle, hVisDC);
            ReleaseDC(m_oVisPanel2.Handle, hVisDC2);
            ReleaseDC(m_oVisPanel3.Handle, hVisDC3);
        }





VB.NET

Code: [Select]
Private Declare Function GetDC Lib "user32.dll" (ByVal hWnd As Int32) As IntPtr

 Private Declare Function ReleaseDC Lib "user32.dll" (ByVal hWnd As Int32, ByVal hDC As IntPtr) As Int32

...

hVisDC = GetDC(m_oVisPanel.Handle)
hVisDC2 = GetDC(m_oVisPanel2.Handle)
hVisDC3 = GetDC(m_oVisPanel3.Handle)
...

 Private Sub frmMain_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        ReleaseDC(m_oVisPanel.Handle, hVisDC)
        ReleaseDC(m_oVisPanel2.Handle, hVisDC2)
        ReleaseDC(m_oVisPanel3.Handle, hVisDC3)
    End Sub




Cheers,
Greg

ken

  • Posts: 752
Any ideas who to get the "visual" as a "BitmapSource" so I can use it in C# WPF (Windows Presentation Foundation).

I tried to create graphic hdc, and convert it to a "BitmapSource" with "System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap" but I get error:
'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll


RevG

  • Posts: 458
Any ideas who to get the "visual" as a "BitmapSource" so I can use it in C# WPF (Windows Presentation Foundation).

I tried to create graphic hdc, and convert it to a "BitmapSource" with "System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap" but I get error:
'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll



Hmm this is something that I have not looked into. I have not done any work with WPF yet. I will look into this and see what I can figure out.

Cheers,
Greg


ken

  • Posts: 752
Problem is that BASS_SFX works with hWnd / handle for the graphic. If BASS_SFX would give me an Bitmap then it would be easy to convert that and use in WPF. WPF image don't have hWnd / handle, what I know.

Guest

  • Guest
Is it possible to embedd WinAmp visualizations into a panel or such? (e.g. Do I have to use Winamp's own window)

RevG

  • Posts: 458
Problem is that BASS_SFX works with hWnd / handle for the graphic. If BASS_SFX would give me an Bitmap then it would be easy to convert that and use in WPF. WPF image don't have hWnd / handle, what I know.

I will look into this for you and see what I can do.

Is it possible to embedd WinAmp visualizations into a panel or such? (e.g. Do I have to use Winamp's own window)

I will also look into this and see what I can do.

Cheers,
Greg

jeffdavis

  • Posts: 297
Would like to add Visualizations into our VB6 app that uses BASS.   I've tried the sample and it does work but crashes the IDE when the app exits?   Is the sample correct?  Here are the order of SFX operations but it seems like it crashes during the unload?   

Jeff

(on form load)
BASS_SFX_Init 
BASS_SFX_PluginCreate

BASS_SFX_PluginStart (after channelplay)

(on form unload)
BASS_SFX_Free

(In timer)
BASS_SFX_PluginRender


jeffdavis

  • Posts: 297
I am using VB6 with BASS_SFX to add visualizations to our app.   Trying to use some of the basic WMP visualization DLL's that are part of XP Pro.   Are there any tips on getting some of these working?  Using the ones in C:\Program Files\Windows Media Player\Visualisations


zoidberg

  • Posts: 2
Problem is that BASS_SFX works with hWnd / handle for the graphic. If BASS_SFX would give me an Bitmap then it would be easy to convert that and use in WPF. WPF image don't have hWnd / handle, what I know.

I will look into this for you and see what I can do.

Cheers,
Greg

Hello,

I´m creating an XNA-Application. I want to use the Bitmapdata too and would be happy if this is possible.
(sorry for my bad english)

thanks,
zoidberg

RevG

  • Posts: 458
Hey Guys,

I made a new build for testing to see if this bitmap modification I made will work for all of your needs.
http://www.cubesol.com/Files/BASS_SFXBitmapTest.zip

The only thing that has changed is now BASS_SFX_PluginRender now returns an HBITMAP handle containing the last rendered visualization frame. I have included updated header files for all appropriate languages. In C# and VB.NET you only need to change your definition for BASS_SFX_PluginRender to below.
C#
Code: [Select]
        [DllImport("bass_sfx.dll")]
        public static extern IntPtr BASS_SFX_PluginRender(int handle, int hStream, IntPtr hDC);

VB.NET
Code: [Select]
<DllImport("bass_sfx.dll")> _
    Public Shared Function BASS_SFX_PluginRender(ByVal handle As Integer, ByVal hStream As Integer, ByVal hDC As IntPtr) As IntPtr
    End Function


Please let me know if this works for you. You should be able to convert the HBITMAP handle to what you need using the links that radio posted for you above.

It this works I will publish a new official build with updated examples and documentation.

Cheers,
Greg

zoidberg

  • Posts: 2
Hi,

I think the following code should work:
Code: [Select]
System.Drawing.Image x = System.Drawing.Image.FromHbitmap(BASS_SFX_PluginRender(hSFX, hStream, hVisDC));

but I get an external Exception.

Code: [Select]
System.Runtime.InteropServices.ExternalException was unhandled
  Message="Allgemeiner Fehler in GDI+."
  Source="System.Drawing"
  ErrorCode=-2147467259
  StackTrace:
       bei System.Drawing.Image.FromHbitmap(IntPtr hbitmap, IntPtr hpalette)
       bei System.Drawing.Image.FromHbitmap(IntPtr hbitmap)
       bei BASS_SFXTest.frmMain.timer1_Tick(Object sender, EventArgs e) in D:\BASS_SFX\VS 2005\C# .NET\BASS_SFXTest\Form1.cs:Zeile 103.
       bei System.Windows.Forms.Timer.OnTick(EventArgs e)
       bei System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
       bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       bei System.Windows.Forms.Application.Run(Form mainForm)
       bei BASS_SFXTest.Program.Main() in D:\BASS_SFXTest\Program.cs:Zeile 17.
       bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       bei System.Threading.ThreadHelper.ThreadStart()
  InnerException:


What I´m doing wrong?

zoidberg

RevG

  • Posts: 458
I am looking into this right now :)

RevG

  • Posts: 458
Ok I looked into that code and everything is working here on my side under windows 7. Just did below as test.

Code: [Select]
[DllImport("bass_sfx.dll")]
public static extern IntPtr BASS_SFX_PluginRender(int handle, int hStream, IntPtr hDC);

...

private void timer1_Tick(object sender, EventArgs e)
{
    IntPtr hBitmap = IntPtr.Zero;
    Image x;
    if(hSFX != -1)
    {
        hBitmap = BASS_SFX_PluginRender(hSFX, hStream, hVisDC);
        x = Image.FromHbitmap(hBitmap);
        pictureBox1.Image = x;
    }
}

i00

  • Posts: 27
I will donate $100 AUD towards this project if you can get it working properly in VB.net ...

see my post here:
https://www.un4seen.com/forum/?topic=10550.0

Otherwise this control is useless to me - it seems issue when you have a lot of other drawing stuff happening in the app.

Thanks
Kris

RevG

  • Posts: 458
I will donate $100 AUD towards this project if you can get it working properly in VB.net ...

see my post here:
https://www.un4seen.com/forum/?topic=10550.0

Otherwise this control is useless to me - it seems issue when you have a lot of other drawing stuff happening in the app.

Thanks
Kris

Hi I really appreciate your offer to donate, but I will help you for free :) Based on your post it looks like you are  using the old code. Instead of getting the device context by using hVisDC = frm.CreateGraphics().GetHdc() instead use the code below and your problem should be solved. Let me know if this works.

Code: [Select]
Private Declare Function GetDC Lib "user32.dll" (ByVal hWnd As Int32) As IntPtr

 Private Declare Function ReleaseDC Lib "user32.dll" (ByVal hWnd As Int32, ByVal hDC As IntPtr) As Int32

...

hVisDC = GetDC(m_oVisPanel.Handle)
hVisDC2 = GetDC(m_oVisPanel2.Handle)
hVisDC3 = GetDC(m_oVisPanel3.Handle)
...

 Private Sub frmMain_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        ReleaseDC(m_oVisPanel.Handle, hVisDC)
        ReleaseDC(m_oVisPanel2.Handle, hVisDC2)
        ReleaseDC(m_oVisPanel3.Handle, hVisDC3)
    End Sub

i00

  • Posts: 27
Thanks works like a charm ... I know you said that you would give me advice for free ... but i really appreciate you sure you don't want a beer to help the cause?

Kris

Knight_Rider

  • Posts: 131
Hey,
well, there isn't a 64-bit version of sfx available yet, is it :-(

RevG

  • Posts: 458
Hey,
well, there isn't a 64-bit version of sfx available yet, is it :-(

I will make this for you :) won't take long

RevG

  • Posts: 458
Thanks works like a charm ... I know you said that you would give me advice for free ... but i really appreciate you sure you don't want a beer to help the cause?

Kris

Great to hear that it is now working! As much as I appreciate your generosity I will have to respectfully decline :)

I am glad to take care of this library for free for everyone. If anyone has any problems or requests I will definitely do my best to keep up with them. You can be sure that my library will not just disappear like some others have. I realize that people's projects have come to rely on certain libraries and that is why mine is opensource.

Cheers,
Greg

Ian @ un4seen

  • Administrator
  • Posts: 26269
well, there isn't a 64-bit version of sfx available yet, is it :-(

Unfortunately, I don't think that will be possible, or rather not much use. Note that the vis plugins would need to be 64-bit too, and I'm not sure any of them are?

Patrice Terrier

  • Posts: 108
Quote
Note that the vis plugins would need to be 64-bit too

Yep, as long as i can speak for the BassBox plugins, they are currently only 32-bit  :)

...

Knight_Rider

  • Posts: 131
well, that means it will never work on 64-bit os'? :O

RevG

  • Posts: 458
well, there isn't a 64-bit version of sfx available yet, is it :-(

Unfortunately, I don't think that will be possible, or rather not much use. Note that the vis plugins would need to be 64-bit too, and I'm not sure any of them are?

Ah yes, very good point. Would be very pointless :p