Friday, September 3, 2010

Aero Visualization Tutorial

Hi people! Jaschar60 has asked me how do I get that Aero visualization effect in MusicBox.NET.
Its actually pretty easy, just follow and you guys should get it right...Or........you guys can watch the 7 minutes video below made by me using a blurred out mic and screen recorder(highly not recommended)

First, you guys need to download the required files :
  1. BASS(.NET Wrapper, Original Lib)
  2. VB.NET
  3. VB6(Optional)
  4. Time
Then, you guys follow the following steps :
  1. Start VB.NET
  2. Start a new project or open an existing one, add a reference to BASS.NET.DLL
  3. Add the following code before Public Class
    Imports Un4seen.Bass
    Imports System.IO
    Imports System.Runtime.InteropServices
  4. Add the following code after Public Class
    Dim P As DWMCOLORIZATIONPARAMS
    Dim special As Long
    Dim wdm_saved_color As Long
    Dim wdm_is_on As Boolean
    Dim strm As Integer
    _
    Private Shared Sub DwmSetColorization(ByRef dp As DWMCOLORIZATIONPARAMS, ByVal unknown As Long)
    End Sub
    _
    Private Shared Sub DwmGetColorizationParameters(ByRef dp As DWMCOLORIZATIONPARAMS)
    End Sub
    Private Structure DWMCOLORIZATIONPARAMS
    Public Color1 As Long
    Public Color2 As Long
    Public intensity As Long
    Public Unknown1 As Long
    Public Unknown2 As Long
    Public Unknown3 As Long
    Public Opaque As Long
    End Structure
    Public Sub rescolor()
    On Error Resume Next
    Dim w As New StreamWriter("StopAero.txt")
    w.Close()
    My.Computer.FileSystem.DeleteFile("StopAero.txt")
    End Sub
    Public Sub getcolor()
    On Error Resume Next
    Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("Aerolizer")
    For Each p As Process In pProcess
    p.Kill()
    Next
    DwmGetColorizationParameters(P)
    special = Math.Sign(P.Color2) * (P.Color2 And &HFFFF0000)
    wdm_saved_color = P.Color1 And P.Color2
    wdm_is_on = True
    Process.Start("Aerolizer.exe")
    End Sub
    Function LoWord(ByVal DWord As Long) As Integer
    If DWord And &H8000& Then ' &H8000& = &H00008000
    LoWord = DWord Or &HFFFF0000
    Else
    LoWord = DWord And &HFFFF&
    End If
    End Function

    Function HiWord(ByVal DWord As Long) As Integer
    HiWord = (DWord And &HFFFF0000) \ &H10000
    End Function

    Public Sub setcolor()
    If wdm_is_on Then
    Dim level As Long
    Static prev As Long
    level = Bass.BASS_ChannelGetLevel(strm)
    level = ((HiWord(level) + LoWord(level)) / 2) \ 128
    If level = 256 Then level = 255 'Cap it.
    If level - prev > 50 Then level = prev + 50 Else If prev - level > 50 Then level = prev - 50 'Smoother.
    If level <>
    P.Color1 = special + RGB(0, 128 + level, level * 2)
    Else
    P.Color1 = special + RGB(0, 256 - (level - 127) * 2, 255)
    End If
    P.Color2 = P.Color1
    DwmSetColorization(P, 0)
    prev = level
    End If
    End Sub
  5. Add two buttons* and one timer to your application
  6. Name the first button "Enable Aero" and the second button "Disable Aero"
  7. Set the timer interval between 10 and 50
  8. Add setcolor() under timer_tick event
  9. Add timer.enabled = true under the first button
  10. Add the following code under the second button
    Timer.Enabled = False
    rescolor()
  11. Save the project
  12. Now, you need to create the helper application, click here for the code(VB6)
    If your lazy, click here to download a compiled version.
  13. After you have saved the project, there should be a folder
    My Documents/Visual Studio 2008/Projects/(YourProjectNameHere)/
  14. Inside that folder, add the files you have downloaded(bass.dll, Aerolizer.exe)
  15. Add the following code under Form_Load
    getcolor()
    Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)
    strm = Bass.BASS_StreamCreateFile("YourFileNameHere", 0,0 BASSFlags.BASS_Default)
    Bass.BASS_ChannelPlay(strm, False)
  16. Debug, have fun!

1 comment:

  1. Hey man..

    I followed all this.

    But I continue to get errors on this part of the code:

    Add the following code under Form_Load
    getcolor()
    Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)
    strm = Bass.BASS_StreamCreateFile("YourFileNameHere", 0,0 BASSFlags.BASS_Default)
    Bass.BASS_ChannelPlay(strm, False)


    ~~~~~~~~~~~~~~~~~~~~~~~~

    Any Idea whats going on? I don't get what "YouFileNameHere" is... and your video is removed :(

    ReplyDelete