DIY WinAMP plug-in

Source: Internet
Author: User

 

 

I want to answer: "What player are you using ?"MP3 ", 90% of people will answer Winamp! So you must have used the Winamp plug-in function. It is a variety of plug-ins that make this "old" Player continuously become youthful. No matter what audio format (MP4, VQF, RM...) is introduced, the plug-in can be played once it is installed. There are also a variety of visual plug-ins, such as Giess, to fully express the rhythm of music!

 

Since the plug-in is written in a program, why don't we give it a try ?! UsedWinamp everyone knows that the Winamp plug-in is a DLL (Dynamic Link Library) file in the Pulgin folder, so writing the Winamp plug-in is actually a dynamic link library for writing Windows. Of course, certain standards must be followed when writing (relevant documents can be downloaded from www.winamp.com). In this regard, the example of a visual plug-in written by Winamp author Justin Frankel can be used as our reference. Next we will take this example (of course also a compilation Specification) as a reference to understand the compiling method of the Winamp visual plug-in.

 

  (The following program can be downloaded from the Winamp official website. The file name is vis_minisdk.zip)

 

First, let's take a look at the data structure used by the visual plug-in.(In File Vis. h)

 

// Note:

// Any plug-in window that stays at the front end should send the key to its parent window (WinAMP) to ensure

// You can still control WinAMP (unless you press the ESC key or the key specified by the plug-in ).

// The configuration data should be stored in plugin. ini.

// Consider this plug-in routine as a framework.

 

Typedef struct winampVisModule {

 Char * description; // module description (displayed in the drop-down list box under the plug-in selection list box)

 HWND hwndParent; // parent window ------------- (filled by the main application)

 HINSTANCE hDllInstance; // instance handle of this DLL-(filled by the main application)

 Int sRate; // sampling rate ---------- (filled by the main application)

 Int nCh; // number of audio channels ---------- (filled by the main application)

 Int latencyMs; // The latent time (in milliseconds) from calling RenderFrame to actually drawing)

 // (The main application will view this value when obtaining data)

 Int delayMs; // interval between each call (MS)

 

 // Data is filled according to their Nch (number of channels) Entries

 Int spectrumNch;

 Int waveformNch;

 Unsigned char spectrumData [2] [576]; // spectrum data

 Unsigned char waveformData [2] [576]; // waveform data

 

 Void (* Config) (struct winampVisModule * this_mod); // module configuration function

 Int (* Init) (struct winampVisModule * this_mod );

 // Initialize the function (create a window, and so on ). 0 is returned successfully.

 Int (* Render) (struct winampVisModule * this_mod );

 // "Performance" function. 0 is returned. If 1 is returned, the plug-in should be terminated.

 Void (* Quit) (struct winampVisModule * this_mod );

 // Exit the function. Call

 

 Void * userData; // user data (optional)

} WinampVisModule;

 

Typedef struct {

 Int version; // VID_HDRVER (current module version)

 Char * description; // plug-in description (displayed in the plug-in list box in the select plug-in dialog box)

 WinampVisModule * (* getModule) (int); // used to obtain the module structure

} WinampVisHeader;

 

// Define the export ID

Typedef winampVisHeader * (* winampVisGetHeaderType )();

 

// Version of the current module (0x101 = 1.01)

# Define VIS_HDRVER 0x101

 

 

The above list is a header file that must be included in the preparation of the visual plug-in, which lists the data structures used by the visual plug-in. Before discussing specific plug-in programs, you must understand some concepts: a visual plug-in can contain several modules.(Each module is a demo. You can select which module to use in the plug-in selection dialog box.) These modules are obtained by Winamp in some way (which will be seen later, in this way, you can get a chance to perform the show.

 

In short,Winamp uses a uniform name function exported from all plug-in DLL to obtain a plug-in header data structure, then, use a function in the data structure to obtain information about each module (this process is somewhat similar to the usage of the QueryInterface () of COM. It seems that a good design idea is the same ), then, the visual plug-in is displayed using multiple threads (observed by DLL View. The following is the source program of the visual plug-in:

 

// Visual plug-in v1.0 for Winamp Testing

// Copyright (C) 1997-1998, Justin Frankel/Nullsoft

// Based on this framework, You can freely compile any visual plug-in...

 

# Include

 

# Include "vis. h"

 

Char szAppName [] = "SimpleVis"; // window class name

 

// Configuration Declaration

Int config_x = 50, config_y = 50; // the horizontal and vertical coordinates of the window on the screen

Void config_read (struct winampVisModule * this_mod); // read the configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.