c++ source and ocx for winamp dsp/vis plugins here

Started by RevG,

RevG

Hi everyone! Here is a link to the source code for the winamp dsp activex control and the winamp vis activex control I have been working on. I decided to keep using c++ for developing my next version of my dj software and not vb, so I am stopping work on my ocx controls as I won't be using vb anymore, but some of you may benefit from the source code so here it is.

WinampVis ActiveX Control
=========================
http://www.telusplanet.net/public/gellis/source/WinampVisActiveXSource.zip

I built the control in Microsoft Visual C++ 6.0.
The activex control works pretty well. I couldn't get the message handling to work so it is not working. So any IPC messages that winamp plugins request from the parent application, which will be your application window can't be processed unless someone figures out how to make that work in the activex control source code. For the visual basic application example that uses the activex control I built, I used the example application vb source that the trial control from www.afrodreams.com uses. I hope the author doesn't mind, but I tried to email him and that was 2 months ago and no response so....

To use the activex control you will have to make sure that in the vb source that you name the activex control as ActiveVis1 in the name property, either that or replace all the occurrences of ActiveVis1 in the source code to the name of the control as it appears in your vb source code. When you open the vb project it will probably say that it can't find the ocx, you will have to go the Project... Components.... menu and then click the browse button and browse to the WinampVisActiveXSource\Release\WinampVis.ocxfile and then put it on the form and name it ActiveVis1.

WinampDSP ActiveX Control
=========================
http://www.telusplanet.net/public/gellis/source/WinampDSPActiveXSource.zip

I built the control in Microsoft Visual C++ 6.0. I couldn't get this to work right. I am pretty sure the activex control I made works properly. The problem is with the STREAMPROC function in the modBass.bas file. I used a custom stream to handle giving bass the correct number of samples after winamp dsp plugins processes the data. It works on some mp3's but crashes after a bit, but the dsp processing is working, so it is nothing wrong with activex control I made, it is something in the vb source code in the STREAMPROC function I created. I used the same vb source from www.afrodreams.com for the vis plugin, but just changed the code to make it work with my DSP plugin ocx control. Again I hope the author doesn't mind, but I believe in open source.

To use the activex control you will have to make sure that in the vb source that you name the activex control as ActiveVis1 in the name property, either that or replace all the occurrences of ActiveVis1 in the source code to the name of the control as it appears in your vb source code. When you open the vb project it will probably say that it can't find the ocx, you will have to go the Project... Components.... menu and then click the browse button and browse to the WinampDSPActiveXSource\Release\WinampDSP.ocx file and then put it on the form and name it ActiveVis1.

So hopefully one of the vb guys or maybe Ian can figure out what is wrong with the vb source code in the STREAMPROC function of modBass.bass for the Winamp DSP vb source.

And hopefully maybe Ian or one of the c++ guys can figure out how to get the message handling working in the Winamp VIS OCX source code so that vb users can handle the SendMessage commands sent from the winamp vis plugins to the controlling application using the ocx control.

After those two problems are fixed the vb guys should be able to have support for Winamp DSP and Winamp Vis plugins!!

You can use the ocx source code in any way you want, but if anyone improves upon the ocx controls or the vb source I would ask that you share it with the rest of users on this message board.

Credit for the vb example source code goes to the Author at www.afrodreams.com (I only modified the code to work with my vis activex control and my dsp activex control).

Credit for the c++ OCX source code goes to me! :)

Anyway have fun!  :)

kai

I'm the author of ActiveVis ;)

And I definitely don't mind you using the example. I've been meaning to put the code for the control up for free anyway (which I will do in the next day or so).

:idea: Maybe we can combine the two since I have the message passing stuff working.

Kai

RevG

Great! I am really glad you are ok with that. I think there are a lot of people here that would really benefit from our source code :)

Ya, we could totally combine the two together. If we just implemented your message handling into the dsp activex control I made and then couple it with your visualization activex then we could even have both the handling of the winamp vis and dsp plugins into 1 ocx control  ;)

Cheers,
Greg

lagarto

??? Hello REGV congratulations. I am testing the dsp, but there is really a problem. When having to execute a plugin of audio of the winamp, after some seconds he gives problem. I am trying to help, as soon as gets enters in contact. But it lacks some functions in STREAMPROC. Excuse for English.  ;D

kai

I've uploaded a newer version of the ActiveVis control and the source code to:

http://www.afrodreams.com

Have a look and enjoy  :)

Kai

lagarto

;)
Function STREAMPROC(ByVal handle As Long, ByVal buffer As Long, ByVal length As Long, ByVal user As Long) As Long
     
     'I tried to make this function work, but couldn't get it
     'to work correctly. It almost works. On some songs the
     'dsp plugins work great, but it crashes after a little bit.
     'On some songs it crashes right away. not sure why.
     'Hopefully someone can figure it out.
     '
     Dim decbuff(decblock * 2) As Byte
     Dim tempbuffer() As Byte
     ReDim tempbuffer(length) As Byte
     Dim a As Long
     Dim c As Long
     Dim nBufferPos As Long
     nBufferPos = 0
     
     c = length
     
     If exlen Then
        a = 0
        If (c < exlen) Then
            a = c
        Else
            a = exlen
        End If
 
        'a = exlen !!!!!!!!!!!!!!!!!!!!!!!
        '!!!!!!! Err
       
        Call CopyMemory(tempbuffer(nBufferPos), excess(0), a)
        exlen = exlen - a
        If exlen Then
            Call CopyMemory(excess(0), excess(a), exlen)
        End If
            nBufferPos = nBufferPos + a
            c = c - a
    End If
   
    Do While (c)
        a = BASS_ChannelGetData(m_hStream, decbuff(0), decblock)
        If a < 0 Then
            Exit Do
        End If
       
       If frmMain.started Then
       a = 4 * frmMain.ActiveVis1.ModifySamples(VarPtr(decbuff(0)), a / 4, 16, 2, 44100)
       End If
       
        If (a > c) Then
            Call CopyMemory(tempbuffer(nBufferPos), decbuff(0), c)
            exlen = a - c
            Call CopyMemory(excess(0), decbuff(c), exlen)
            c = 0
        Else
            Call CopyMemory(tempbuffer(nBufferPos), decbuff(0), a)
            nBufferPos = nBufferPos + a
            c = c - a
        End If
    Loop
   
    Call CopyMemory(ByVal buffer, tempbuffer(0), length - c)
   
    STREAMPROC = length - c


   
    'Dim decbuff() As Byte
    'Dim tempbuffer() As Byte
    'ReDim decbuff(length) As Byte
    'ReDim tempbuffer(length) As Byte

    'BASS_ChannelGetData m_hStream, decbuff(0), length
    'Call CopyMemory(tempbuffer(0), decbuff(0), length)
'    Call CopyMemory(ByVal buffer, tempbuffer(0), length)
     'Call CopyMemory(ByVal buffer, decbuff(0), length)
    'STREAMPROC = length
   
End Function  ;D

RevG

Great! I feel like an idiot now, but great! I can't believe I didn't see that. I must have accidentally brought that line down from the above if statement.. oh well, I am so glad that you fixed it. Great Work!

Kai was so kind as to upload the source code for his winamp visualization activex control as well. He has the IPC message passing working in it. I will be trying to implement the message passing from his source code into the dsp plugin. When I have completed that, I will upload the new source.

Thanks goes out to lagarto and kai for their contributions! :D

lagarto

??? A question for REGV.  
 
How to execute 2 files at the same time using DSP. Please  ???

RevG

If you want to use multiple dsp plugins all at the same time to process your sound data I would say the easiest way to do this would be to use one of the stacker dsp plugins.

A good one is Multiple-DSP Stacker
http://classic.winamp.com/plugins/detail.jhtml?componentId=128742

I hope this helps :)
Greg


lagarto

??? Not two plugins. Two audio files at the same time. Example: (Two MP3). I am developing a program for DJ. I already made some functions. But when he/she plays the together two the audio it is perforating. Excuse me for English. OK.  :-/

RevG

Oh i see what you mean. Ya, I will have to update the ocx plugin to run the modifysamples function in its own thread. That is my guess right now as to what is causing the problem, I will change the code to run the modifysamples function in its own thread, and if that solves the issue I will upload the new source.

Cheers,
Greg


KarLKoX

RevG>i recommand you to NOT create a thread for DSPs, some plugins don't like them (like AdaptX).

lagarto

RegV. Please. The new source already this ready one. order for the email. largatobega@ig.com.br.

lagarto

??? Hello REGV. You have some innovation in relation to my problem. Some code source in VisualBasic to help me. Please. Thank you.  ???

RevG

Ya, I am working on it. It will take me a couple days. I am busy working on my next dj application, but I will make some time within the next few days. When I am done I will upload the new source code to this message board.

Cheers,
Greg

lagarto

Yes. I will await. Once again thank you for the attention. My program is here for exclusive use in a Rádio FM in Brazil, similar to programs of DJs.  :)

kai

One thing I wanted to add to the visualization source code was support for Sonique plugins. Now that the code is public, it would be nice if someone who knew how to added this in.  ;D

Kai

RevG

Ok, I have merged much of the work kai did in his vis plugin with my dsp plugin activex control. I multi-threaded it so that it opens the dsp plugin in its own thread.

A BIG Thanks goes out to kai for releasing his source code to make the message handling possible. I also adpoted some other nice coding structure from kai's source code! :)

Just so you know, I have only lightly tested this code, but it seems pretty solid. I whipped it off pretty fast. I haven't tested the message handling, or playing two sound files at once that are both using dsp plugins, but I expect that they are working. Also for now, the Stopped event doesn't fire for the activex control, because I didn't have time to figure out how to get the window handle of the ocx control so that I could postmessage to it, but I will figure it out when I have more time.

If you find something wrong with the dsp activex control just post me a message here, or since it is open source you could fix it and upload the new source ;)

legarto: let me know if this fixes your problem with playing two sound files at once  ;)

http://www.telusplanet.net/public/gellis/source/WinampDSPMultiThread.zip

Cheers,
Greg

KarLKoX

It is pretty "easy" to receive winamp IPC Message, you ll have to create a fake winamp windows each time a DSP is activated (the windows message can't be opened once due to multithreading), i ve done it this way and dsp support is very stable. One day, (listen to the Empire Strike Back song ^_^ ) i ll adapt (i ve saying it already, i know) my DLL (not an OCX) for Bass (mine is for Fmod, sorry), there are complete (vis/dsp/in) examples for VB/Delphi/PureBasic users.

lagarto

???  Hello RevG. The new code source no this more one executing Plugin DSP Adapt-x 3.5. This near the code source two ActiveX, the previous and the new. The previous works Plugin DSP Adapt-x 3.5.  I tried in several ways to play the two audio, but I didn't get. I am putting a link of my code source for you to help me. I have many other ideas that I should put here soon. Help me please.   :-[

http://www.lagartobega.kit.net/lagartodsprevg.zip


RevG

ok I will have to look into why the adapt-x plugin isn't working and fix that up. I can't download your source code to try and help you out. The link just times out. Anyway I will be working on the dsp plugin to solve some of these issues.

Cheers,
Greg

lagarto

??? I am not getting to execute two audio files. I only get to execute an audio file. When I execute two audio files, the audio is bad. I don't get to understand, how to play two audio files at the same time.  
 
 ;) A Great Hug: You are very helpful and efficient.

lagarto

Revg, não sei o motivo, mas o ADAPT-X voltou a funcionar. Estou aguardando a ajuda em relação a execução de dois arquivos de audio. Quando executo somente um, funciona perfeito, mas quando executo dois audios, começa a aparecer uns defeitos. Mas uma vez, muito obrigado.