Author Topic: winamp plugins  (Read 5455 times)

exedore

  • Posts: 16
winamp plugins
« on: 14 Jan '03 - 19:41 »
I am trying to make an application of my to use winamps plugins but i have some problems...

Until now i have managed to get the plugins description and of all the modules that the DLL has in it. The problems start when i am trying to display graphics or the configuration dialog.

In some plugins the configuration dialog appears (as it should be) but in some others it doesnt. I have test them with winamp and they work fine. Some other display their window that use for rendering but nothing else just a black empty window. Other plugins work fine like the AVS.

Also i need some help in how to give the plugin the correct wave data. Winamp uses two arrays of 576 values for each channel but bass with the bass_channelgetdata funnction retreives 512 or 1024 values. In the first case i miss some values in the second i have more than i need. Below is some code that i use. Fill free to copy and make corrections...  ;D

I just need help to use the plugins correctly.

Code: [Select]

This Procedure Displays the Configure dialog of the Plugin

Procedure Tvisform.ConfigureButtonClick(Sender: TObject);
Var
 header: PWinAMPVisHeader;
 Module: PWinAMPVisModule;
 VisHandle: Thandle;
 GetHeader: Twagetheader;
 GetConfig: TWAconfig;
 tmpmodule: pWinAMPVisModule;
 i: integer;
Begin
 If listview.selected = Nil Then exit;
 VisHandle := LoadLibrary(pchar(listview.selected.subitems[0]));
 If visHandle <> 0 Then
 Begin
   @GetHeader := GetProcAddress(visHandle, 'winampVisGetHeader');
   If @GetHeader <> Nil Then
   Begin
     header := Getheader;
     For i := 0 To combobox1.itemindex Do Begin
       module := header.GetModule(i);
     End;
     module.Config(module);
     module.Quit(module);
   End;
   FreeLibrary(visHandle);
 End;
End;

This is the Event Handler of a TTimer that i use to give to the plugin the wave values.

Procedure TForm1.visualtimerTimer(Sender: TObject);
Var
 //  SpectrumData: Array[0..1, 0..575] Of byte;
 SpectrumData: Array[0..256] Of float;
 WaveformData: Array[0..1024] Of byte;
 i, d: word;
 freq, dum1: dword;
 dum: integer;
Begin
 If bass_channelisactive(stream) = BASS_ACTIVE_PLAYING Then Begin
   BASS_ChannelGetAttributes(main.stream, freq, dum1, dum);
   wa_module^.sRate := freq;
   FillChar(SpectrumData, SizeOf(SpectrumData), 0);
   FillChar(WaveformData, SizeOf(waveformData), 0);
   bass_channelgetdata(stream, @spectrumdata, BASS_DATA_FFT512s);
   For i := 0 To 256 Do Begin
     wa_module^.SpectrumData[0, i*2] := trunc(SpectrumData[i] * 2048);
     wa_module^.SpectrumData[1, i*2] := trunc(SpectrumData[i] * 2048);
   End;
   dum1 := BASS_ChannelGetFlags(stream);
   If ((dum1 And BASS_SAMPLE_8BITS) = BASS_SAMPLE_8BITS) Or ((dum1 And BASS_SAMPLE_MONO) = BASS_SAMPLE_MONO) Then Begin
     bass_channelgetdata(stream, @waveformdata, 512);
     For i := 0 To 512 Do Begin
       wa_module^.Waveformdata[0][i] := waveformdata[i];
       wa_module^.Waveformdata[1][i] := waveformdata[i];
     End;
   End Else Begin
     bass_channelgetdata(stream, @waveformdata, 1024);
     For i := 0 To 512 Do Begin
       wa_module^.Waveformdata[0][i] := waveformdata[i*2];
       wa_module^.Waveformdata[1][i] := waveformdata[i*2+1];
     End;
   End;


 End Else Begin
   FillChar(SpectrumData, SizeOf(SpectrumData), 0);
   FillChar(WaveformData, SizeOf(waveformData), 0);
 End;
 If wa_module.Render(wa_module) = 1 Then Begin
   visualtimer.enabled := false;
   wa_module.quit(wa_module);
 End;
End;


Irrational86

  • Posts: 960
Re: winamp plugins
« Reply #1 on: 15 Jan '03 - 23:39 »
You want to know what you're problem is there? I assume a "Yes", so here is the answer...You have to load all plugins when the app runs, so when you click the configure button, you just do the config procedure part..if you dont understand, please reply saying so..

exedore

  • Posts: 16
Re: winamp plugins
« Reply #2 on: 16 Jan '03 - 20:57 »
The problem is that the code i use above doesnt work properly on all plugins... for example in some plugins the config. window appear in some others dont or when i call the render function some plugins display graphics but others dont. I dont know what goes wrong in those plugins and dont run properly.

Another problem is that, for example in AVS, is that the graphic FX dont look so cool like in winamp. I dont know how to describe it better. But i think that the problem in this case is the Waveform and Specturm Arrays that hold tha values from the stream. Winamp uses 576 values but with BASS i can get 512 or 1024. So if i use 512 vallues i miss some or if i use 1024 i have to discard some. Is there anyone else who tryed to make the same thing?

Irrational86

  • Posts: 960
Re: winamp plugins
« Reply #3 on: 17 Jan '03 - 23:14 »
You got the whole render thing wrong...try this

Code: [Select]

Var
//  SpectrumData: Array[0..1, 0..575] Of byte;
SpectrumData: Array[0..2048] Of float;
WaveformData: Array[0..2048] Of DWORD;
i, d: word;
freq, dum1: dword;
dum: integer;
Begin
If bass_channelisactive(stream) = BASS_ACTIVE_PLAYING Then Begin
  BASS_ChannelGetAttributes(main.stream, freq, dum1, dum);
  wa_module^.sRate := freq;
  FillChar(SpectrumData, SizeOf(SpectrumData), 0);
  FillChar(WaveformData, SizeOf(waveformData), 0);
  bass_channelgetdata(stream, @spectrumdata, BASS_DATA_FFT2048);
  For i := 1 To 576 Do Begin
    wa_module^.SpectrumData[0, i-1] := trunc(SpectrumData[i] * 255);
    wa_module^.SpectrumData[1, i-1] := trunc(SpectrumData[i] * 255);
  End;
  dum1 := BASS_ChannelGetFlags(stream);
  If ((dum1 And BASS_SAMPLE_8BITS) = BASS_SAMPLE_8BITS) Or ((dum1 And BASS_SAMPLE_MONO) = BASS_SAMPLE_MONO) Then Begin
    bass_channelgetdata(stream, @waveformdata, 1024);
    For i := 0 To 575 Do Begin
      wa_module^.Waveformdata[0][i] := waveformdata[i] div 256;
      wa_module^.Waveformdata[1][i] := waveformdata[i] div 256;
    End;
  End Else Begin
    bass_channelgetdata(stream, @waveformdata, 2048);
    For i := 0 To 575 Do Begin
      wa_module^.Waveformdata[0][i] := waveformdata[i*2] div 256;
      wa_module^.Waveformdata[1][i] := waveformdata[i*2+1] div 256;
    End;
  End;
End;
If wa_module.Render(wa_module) = 1 Then Begin
  visualtimer.enabled := false;
  wa_module.quit(wa_module);
End;
End;

exedore

  • Posts: 16
Re: winamp plugins
« Reply #4 on: 3 Feb '03 - 19:56 »
Sorry for my late response but i had some problems with my internet connection and not much time to fix it :)

XminioNX, have you tested your piece of code because when i tested it with AVS in some plugins that use a spectrum analyzer, the plugin shows only the half of the waveform. The left part of it appears correctly but in the right just a straight line. I changed some values in your code but still a part of the waveform looks like a straight line.

Test it yourself and see if you will have the same problem.

Another problem with the AVS plugin is that when i press the  close button of the plugins window my whole application exits!!! Why?  As a window handle of the plugins window i have applyed several values like zero, my applications handle or just random, but in every case the whole application exits. Why?  ???

Irrational86

  • Posts: 960
Re: winamp plugins
« Reply #5 on: 3 Feb '03 - 20:06 »
Quote

XminioNX, have you tested your piece of code because when i tested it with AVS in some plugins that use a spectrum analyzer, the plugin shows only the half of the waveform. The left part of it appears correctly but in the right just a straight line. I changed some values in your code but still a part of the waveform looks like a straight line.
I know why this is, you have to request a sample size 4 times bigger than what you need. Since you need 576, all you have to do is [576 * 4] which equals 2304. This means you request 2304 and feed in what you need...

Quote

Another problem with the AVS plugin is that when i press the  close button of the plugins window my whole application exits!!! Why?
As to why the application closes, i have no idea, when i used to play around with winamp visuals in my App, the sample exact thing used to happen, but i found no solution so i removed the vis plugin support...

RevG

  • Posts: 458
Re: winamp plugins
« Reply #6 on: 14 Mar '03 - 06:48 »
I was just surfing through old messages when I found this. The reason why the whole application closes when you close a plugin window is because winamp vis plugins are designed to be run through their own user interface thread.

So what some plugin developers did is post a wm_quit message to close the plugin, which is fine if the vis dll was loaded into it's own thread because then it would just close the plugin, but because you are not loading the vis plugin into it's own UI thread it closes the current thread which is the thread your application is running in.

I am going to be posting a sample MFC c++ app that shows how to add support for Winamp dsp and visualization plugins fully. So you can see how this is done when I post the example.

Cheers,
Greg


manu

  • Posts: 51
Winamp Plugins in .NET
« Reply #7 on: 22 Mar '03 - 13:24 »
hi

if you use .NET then I have something for you.
I wrote a Class Library which makes Winamp Visual & DSP Plugin support really easy  ;)
http://www.people.freenet.de/mweber/WinampPlugins.rar

Most of the Visual Plugins work (G-Force, AVS , Milk ..)
Tripex Version 3 is not closed correctly. Really don't know why!

WinampDSP only works with 16 Bit Audio and FloatDSP is also not supported jet.  

cheers
Manu