Winamp Vis if anyone can help

This is a discussion on Winamp Vis if anyone can help within the Windows Programming forums, part of the Platform Specific Boards category; Alright I wrote a winamp visualization pretty lame one but I am new to windows and winamp. Winamp won't recognize ...

  1. #1
    Unregistered
    Guest

    Winamp Vis if anyone can help

    Alright I wrote a winamp visualization pretty lame one but I am new to windows and winamp. Winamp won't recognize the.dll file in the plugins folder can anyone help me with it.

    #include <windows.h>
    #include <stdlib.h>
    #include "vis.h"

    char szAppName[] = "Morts Mod";
    int cxClient, cyClient;
    int config_x, config_y;

    void config_read(struct winampVisModule *mortmod); // reads the configuration
    void config_write(struct winampVisModule *mortmod); // writes the configuration
    void config_getinifn(struct winampVisModule *mortmod, char *ini_file); // makes the .ini file filename

    void config(struct winampVisModule *mortmod);
    winampVisModule *getModule(int which);
    int init(struct winampVisModule *mortmod);
    int Mortrender(struct winampVisModule *mortmod);
    void quit(struct winampVisModule *mortmod);


    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
    HWND hwnd;

    HDC memDC;
    HBITMAP memBMP,
    oldBMP;

    winampVisHeader hdr = { VIS_HDRVER, "MortMod", getModule };

    winampVisModule mod1 =
    {
    "MortMod",
    NULL,
    NULL,
    0,
    0,
    25,
    25,
    0,
    2,
    { 0, },
    { 0, },
    NULL,
    init,
    Mortrender,
    quit
    };

    #ifdef _cplusplus
    extern "C" {
    #endif
    __declspec( dllexport ) winampVisHeader *winampVisGetHeader()
    {
    return &hdr;
    }
    #ifdef __cpluscplus
    }
    #endif



    winampVisModule *getModule(int which)
    {
    switch(which)
    {
    case 0: return &mod1;
    default: return NULL;
    }
    }


    int init(struct winampVisModule *mortmod)
    {
    config_read(mortmod);

    WNDCLASS wc;
    memset(&wc,0,sizeof(wc));
    wc.lpfnWndProc = WndProc;
    wc.hInstance = mortmod->hDllInstance;
    wc.lpszClassName= szAppName;
    wc.hbrBackground= (HBRUSH) GetStockObject(WHITE_BRUSH);

    if(!RegisterClass(&wc))
    {
    MessageBox(mortmod->hwndParent, "Error registering window class", "MortMod Error", MB_OK);
    return 1;
    }

    hwnd = CreateWindow(szAppName,
    "Mort Mod",
    WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT, CW_USEDEFAULT,
    CW_USEDEFAULT, CW_USEDEFAULT,
    mortmod->hwndParent,
    NULL,
    mortmod->hDllInstance,
    NULL);

    if(!hwnd)
    {
    MessageBox(mortmod->hwndParent, "Error creating window", "VisMod Error", MB_OK);
    return 1;
    }

    SetWindowLong(hwnd, GWL_USERDATA,(LONG)mortmod);

    memDC = CreateCompatibleDC(NULL);
    memBMP = CreateCompatibleBitmap(memDC, cxClient, cyClient);

    ShowWindow(hwnd, SW_SHOWNORMAL);
    return 0;
    }

    void config(struct winampVisModule *mortmod)
    {
    MessageBox(mortmod->hwndParent,"This module is Copyright (c) 1997-1998, Justin Frankel/Nullsoft\n"
    "-- This is just a demonstration module, it really isn't\n"
    " supposed to be enjoyable --","Configuration",MB_OK);
    }


    int Mortrender(struct winampVisModule *mortmod)
    {
    int x, y;
    HDC hdc;
    HPEN hpen;

    for(y = 0; y < 2; y++)
    {
    hpen = CreatePen(PS_SOLID, rand() % 10, RGB( rand () % 255, rand () % 255, rand () % 255));
    SelectObject(memDC, hpen);
    for(x = 0; x < 576; x++)
    {
    if(mortmod->waveformData)
    {
    MoveToEx(memDC, rand() % cxClient, rand() % cyClient, NULL);
    LineTo(memDC, rand() % cxClient, rand() % cyClient);
    }
    }
    hdc = GetDC(hwnd);
    BitBlt(hdc, 0, 0, cxClient, cyClient, memDC, 0, 0, SRCCOPY);
    ReleaseDC(hwnd, hdc);
    }
    return 0;
    }

    void quit(struct winampVisModule *mortmod)
    {
    SelectObject(memDC, oldBMP);
    DeleteObject(memDC);
    DeleteObject(memBMP);
    DestroyWindow(hwnd);
    }

    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    switch(message)
    {
    case WM_CREATE : return 0;
    case WM_SIZE:
    cxClient = LOWORD(lParam);
    cyClient = HIWORD(wParam);
    return 0;
    case WM_PAINT:
    {
    PAINTSTRUCT ps;
    RECT r;
    HDC hdc = BeginPaint(hwnd, &ps);
    BitBlt(hdc, 0, 0, cxClient, cyClient, memDC, 0, 0, SRCCOPY);
    EndPaint(hwnd, &ps);
    }
    return 0;
    case WM_DESTROY: PostQuitMessage(0); return 0;
    }
    return 0;
    }


    void config_getinifn(struct winampVisModule *mortmod, char *ini_file)
    { // makes a .ini file in the winamp directory named "plugin.ini"
    char *p;
    GetModuleFileName(mortmod->hDllInstance,ini_file,MAX_PATH);
    p=ini_file+strlen(ini_file);
    while (p >= ini_file && *p != '\\') p--;
    if (++p >= ini_file) *p = 0;
    strcat(ini_file,"plugin.ini");
    }


    void config_read(struct winampVisModule *mortmod)
    {
    char ini_file[MAX_PATH];
    config_getinifn(mortmod,ini_file);
    config_x = GetPrivateProfileInt(mortmod->description,"Screen_x",config_x,ini_file);
    config_y = GetPrivateProfileInt(mortmod->description,"Screen_y",config_y,ini_file);
    }

    void config_write(struct winampVisModule *mortmod)
    {
    char string[32];
    char ini_file[MAX_PATH];

    config_getinifn(mortmod,ini_file);

    wsprintf(string,"%d",config_x);
    WritePrivateProfileString(mortmod->description,"Screen_x",string,ini_file);
    wsprintf(string,"%d",config_y);
    WritePrivateProfileString(mortmod->description,"Screen_y",string,ini_file);
    }

  2. #2
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Lightbulb well...

    Well... I would say a few things:

    A.) Many many of the functions appear to be missing __declspec(dllexport).
    B.) Use the dependency walker to check this
    C.) There may be discriptors you need to use for compiler independence, usually outside of MSVC.
    D.) Most procs of a dll have no ? and @YAH or w/e for the args, I dont know how to get rid of them but check the docs on this and see if thats the problem.
    E.) Could you show me the docs on this?

    SPH

  3. #3
    Unregistered
    Guest
    if you go to winamp.com you can download a Vis minisdk. I downloaded it and all it had was a ifdef statement the used the (_dllexport).

    ryan

  4. #4
    Unregistered
    Guest
    also sorry I forgot to give you the header file vis.h if you want that I can send it or get it with the winamp mindsdk at winamp.com.

    Ryan

  5. #5
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Arrow Got it...

    Well, I read up on it (as you know, we talked earlyer), and I made a 'simple' Vis using Consolodated NeHe GL and some Trigometric functions... it basically makes a ring devided into sevral sections based upon audio channels, and pitch, (ect.)

    One problem you may have is not having the correct proc name for your header retriving function...

    It must be: __declspec( dllexport ) winampVisHeader *winampVisGetHeader()

    The code and dll should be attached...

    SPH
    Attached Files Attached Files

  6. #6
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Lightbulb Another Bug!

    I lookedit over, and you're setting "config" paramiter to NULL!

    And also, did the site kill the tabbing or wuz it supposed to be that way? (Use code thing!)

    SPH

  7. #7
    Unregistered
    Guest
    // Winamp test visualization library v1.0
    // Copyright (C) 1997-1998, Justin Frankel/Nullsoft
    // Feel free to base any plugins on this "framework"...

    #include <windows.h>

    #include "vis.h"

    char szAppName[] = "SimpleVis"; // Our window class, etc

    // configuration declarations
    int config_x=50, config_y=50; // screen X position and Y position, repsectively
    void config_read(struct winampVisModule *this_mod); // reads the configuration
    void config_write(struct winampVisModule *this_mod); // writes the configuration
    void config_getinifn(struct winampVisModule *this_mod, char *ini_file); // makes the .ini file filename

    // returns a winampVisModule when requested. Used in hdr, below
    winampVisModule *getModule(int which);

    // "member" functions
    void config(struct winampVisModule *this_mod); // configuration dialog
    int init(struct winampVisModule *this_mod); // initialization for module
    int render1(struct winampVisModule *this_mod); // rendering for module 1
    int render2(struct winampVisModule *this_mod); // rendering for module 2
    int render3(struct winampVisModule *this_mod);
    int render4(struct winampVisModule *this_mod); // rendering for module 3
    int render5(struct winampVisModule *this_mod);
    void quit(struct winampVisModule *this_mod); // deinitialization for module

    // our window procedure
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
    HWND hMainWnd; // main window handle

    // Double buffering data
    HDC memDC; // memory device context
    HBITMAP memBM, // memory bitmap (for memDC)
    oldBM; // old bitmap (from memDC)


    // Module header, includes version, description, and address of the module retriever function
    winampVisHeader hdr = { VIS_HDRVER, "Nullsoft Test Visualization Library v1.0", getModule };

    // first module (oscilliscope)
    winampVisModule mod1 =
    {
    "Oscilliscope",
    NULL, // hwndParent
    NULL, // hDllInstance
    0, // sRate
    0, // nCh
    25, // latencyMS
    25, // delayMS
    0, // spectrumNch
    2, // waveformNch
    { 0, }, // spectrumData
    { 0, }, // waveformData
    config,
    init,
    render1,
    quit
    };

    // second module (spectrum analyser)
    winampVisModule mod2 =
    {
    "Spectrum Analyser",
    NULL, // hwndParent
    NULL, // hDllInstance
    0, // sRate
    0, // nCh
    25, // latencyMS
    25, // delayMS
    2, // spectrumNch
    0, // waveformNch
    { 0, }, // spectrumData
    { 0, }, // waveformData
    config,
    init,
    render2,
    quit
    };

    // third module (VU meter)
    winampVisModule mod3 =
    {
    "VU Meter",
    NULL, // hwndParent
    NULL, // hDllInstance
    0, // sRate
    0, // nCh
    25, // latencyMS
    25, // delayMS
    0, // spectrumNch
    2, // waveformNch
    { 0, }, // spectrumData
    { 0, }, // waveformData
    config,
    init,
    render3,
    quit
    };

    winampVisModule mod4 =
    {
    "Random Lines of Love",
    NULL,
    NULL,
    0,
    0,
    25,
    25,
    0,
    2,
    { 0, },
    { 0, },
    config,
    init,
    render4,
    quit
    };

    winampVisModule mod5 =
    {
    "Random Shapes of Love",
    NULL,
    NULL,
    0,
    0,
    25,
    25,
    0,
    2,
    { 0, },
    { 0, },
    config,
    init,
    render5,
    quit
    };





    // this is the only exported symbol. returns our main header.
    // if you are compiling C++, the extern "C" { is necessary, so we just #ifdef it
    #ifdef __cplusplus
    extern "C" {
    #endif
    __declspec( dllexport ) winampVisHeader *winampVisGetHeader()
    {
    return &hdr;
    }
    #ifdef __cplusplus
    }
    #endif

    // getmodule routine from the main header. Returns NULL if an invalid module was requested,
    // otherwise returns either mod1, mod2 or mod3 depending on 'which'.
    winampVisModule *getModule(int which)
    {
    switch (which)
    {
    case 0: return &mod1;
    case 1: return &mod2;
    case 2: return &mod3;
    case 3: return &mod4;
    case 4: return &mod5;
    default:return NULL;
    }
    }

    // configuration. Passed this_mod, as a "this" parameter. Allows you to make one configuration
    // function that shares code for all your modules (you don't HAVE to use it though, you can make
    // config1(), config2(), etc...)
    void config(struct winampVisModule *this_mod)
    {
    MessageBox(this_mod->hwndParent,"This module is Copyright (c) 1997-1998, Justin Frankel/Nullsoft\n"
    "-- This is just a demonstration module, it really isn't\n"
    " supposed to be enjoyable --","Configuration",MB_OK);
    }

    // initialization. Registers our window class, creates our window, etc. Again, this one works for
    // both modules, but you could make init1() and init2()...
    // returns 0 on success, 1 on failure.
    int init(struct winampVisModule *this_mod)
    {
    int width = (this_mod == &mod3)?256:288; // width and height are the same for mod1 and mod2,
    int height = (this_mod == &mod3)?32:256; // but mod3 is shaped differently

    config_read(this_mod);


    { // Register our window class
    WNDCLASS wc;
    memset(&wc,0,sizeof(wc));
    wc.lpfnWndProc = WndProc; // our window procedure
    wc.hInstance = this_mod->hDllInstance; // hInstance of DLL
    wc.lpszClassName = szAppName; // our window class name

    if (!RegisterClass(&wc))
    {
    MessageBox(this_mod->hwndParent,"Error registering window class","blah",MB_OK);
    return 1;
    }
    }


    hMainWnd = CreateWindowEx(
    WS_EX_TOOLWINDOW|WS_EX_APPWINDOW, // these exstyles put a nice small frame,
    // but also a button in the taskbar
    szAppName, // our window class name
    this_mod->description, // use description for a window title
    WS_OVERLAPPEDWINDOW, // make the window visible with a close button
    config_x,config_y, // screen position (read from config)
    width,height, // width & height of window (need to adjust client area later)
    this_mod->hwndParent, // parent window (winamp main window)
    NULL, // no menu
    this_mod->hDllInstance, // hInstance of DLL
    0); // no window creation data

    if (!hMainWnd)
    {
    MessageBox(this_mod->hwndParent,"Error creating window","blah",MB_OK);
    return 1;
    }


    SetWindowLong(hMainWnd,GWL_USERDATA,(LONG)this_mod ); // set our user data to a "this" pointer

    { // adjust size of window to make the client area exactly width x height
    RECT r;
    GetClientRect(hMainWnd,&r);
    SetWindowPos(hMainWnd,0,0,0,width*2-r.right,height*2-r.bottom,SWP_NOMOVE|SWP_NOZORDER);
    }


    // create our doublebuffer
    memDC = CreateCompatibleDC(NULL);
    memBM = CreateCompatibleBitmap(memDC,width,height);
    oldBM = SelectObject(memDC,memBM);

    // show the window
    ShowWindow(hMainWnd,SW_SHOWNORMAL);
    return 0;
    }

    // render function for oscilliscope. Returns 0 if successful, 1 if visualization should end.
    int render1(struct winampVisModule *this_mod)
    {
    int x, y;
    // clear background
    Rectangle(memDC,0,0,288,256);
    // draw oscilliscope
    for (y = 0; y < this_mod->nCh; y ++)
    {
    MoveToEx(memDC,0,(y*256)>>(this_mod->nCh-1),NULL);
    for (x = 0; x < 288; x ++)
    {
    LineTo(memDC,x,(y*256 + this_mod->waveformData[y][x]^128)>>(this_mod->nCh-1));
    }
    }
    { // copy doublebuffer to window
    HDC hdc = GetDC(hMainWnd);
    BitBlt(hdc,0,0,288,256,memDC,0,0,SRCCOPY);
    ReleaseDC(hMainWnd,hdc);
    }
    return 0;
    }

    // render function for analyser. Returns 0 if successful, 1 if visualization should end.
    int render2(struct winampVisModule *this_mod)
    {
    int x, y;
    // clear background
    Rectangle(memDC,0,0,288,256);
    // draw analyser
    for (y = 0; y < this_mod->nCh; y ++)
    {
    for (x = 0; x < 288; x ++)
    {
    MoveToEx(memDC,x,(y*256+256)>>(this_mod->nCh-1),NULL);
    LineTo(memDC,x,(y*256 + 256 - this_mod->spectrumData[y][x])>>(this_mod->nCh-1));
    }
    }
    { // copy doublebuffer to window
    HDC hdc = GetDC(hMainWnd);
    BitBlt(hdc,0,0,288,256,memDC,0,0,SRCCOPY);
    ReleaseDC(hMainWnd,hdc);
    }
    return 0;
    }

    // render function for VU meter. Returns 0 if successful, 1 if visualization should end.
    int render3(struct winampVisModule *this_mod)
    {
    int x, y;
    // clear background
    Rectangle(memDC,0,0,256,32);
    // draw VU meter
    for (y = 0; y < 2; y ++)
    {
    int last=this_mod->waveformData[y][0];
    int total=0;
    for (x = 1; x < 576; x ++)
    {
    total += abs(last - this_mod->waveformData[y][x]);
    last = this_mod->waveformData[y][x];
    }
    total /= 288;
    if (total > 127) total = 127;
    if (y) Rectangle(memDC,128,0,128+total,32);
    else Rectangle(memDC,128-total,0,128,32);
    }
    { // copy doublebuffer to window
    HDC hdc = GetDC(hMainWnd);
    BitBlt(hdc,0,0,256,32,memDC,0,0,SRCCOPY);
    ReleaseDC(hMainWnd,hdc);
    }
    return 0;
    }

    int render4(struct winampVisModule *this_mod)
    {
    static HPEN hpen;
    HDC hdc;
    int y;
    Rectangle(memDC, 0, 0, 288, 256);


    hpen = CreatePen(PS_SOLID, (int)this_mod->waveformData[1][24] % 25, RGB(255, 0, 0));
    for(y = 0; y < 256; y++)
    {

    if(this_mod->waveformData)
    {

    SelectObject(memDC, hpen);
    MoveToEx(memDC, rand() % 288, rand() % 256, NULL);
    LineTo(memDC, rand() % 288, rand() % 256);
    DeleteObject(hpen);
    }
    else
    {
    Rectangle(memDC, 0, 0, 288, 256);
    SelectObject(memDC, hpen);
    DeleteObject(hpen);
    }




    }
    hdc = GetDC(hMainWnd);
    BitBlt(hdc, 0, 0, 288, 256, memDC, 0 , 0, SRCCOPY);
    ReleaseDC(hMainWnd, hdc);




    return 0;
    }

    int render5(struct winampVisModule *this_mod)
    {
    HBRUSH hBrush;
    HDC hdc;
    RECT rect;
    int x;
    Rectangle(memDC, 0, 0, 288, 256);

    for(x = 0; x < 1; x++)
    {
    SetRect(&rect, this_mod->waveformData[1][24]%288, this_mod->waveformData[1][24]% 256, rand() % 288, rand() % 256);
    hBrush = CreateSolidBrush(RGB(rand() % 256, rand() % 256, rand() % 256));
    FillRect(memDC, &rect, hBrush);
    DeleteObject(hBrush);
    }

    hdc = GetDC(hMainWnd);
    BitBlt(hdc,0,0,288,256,memDC,0,0,SRCCOPY);
    ReleaseDC(hMainWnd,hdc);


    return 0;
    }





    // cleanup (opposite of init()). Destroys the window, unregisters the window class
    void quit(struct winampVisModule *this_mod)
    {
    config_write(this_mod); // write configuration
    SelectObject(memDC,oldBM); // delete our doublebuffer
    DeleteObject(memDC);
    DeleteObject(memBM);
    DestroyWindow(hMainWnd); // delete our window
    UnregisterClass(szAppName,this_mod->hDllInstance); // unregister window class
    }


    // window procedure for our window
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    switch (message)
    {
    case WM_CREATE: return 0;
    case WM_ERASEBKGND: return 0;
    case WM_PAINT:
    { // update from doublebuffer
    PAINTSTRUCT ps;
    RECT r;
    HDC hdc = BeginPaint(hwnd,&ps);
    GetClientRect(hwnd,&r);
    BitBlt(hdc,0,0,r.right,r.bottom,memDC,0,0,SRCCOPY) ;
    EndPaint(hwnd,&ps);
    }
    return 0;
    case WM_DESTROY: PostQuitMessage(0); return 0;
    case WM_KEYDOWN: // pass keyboard messages to main winamp window (for processing)
    case WM_KEYUP:
    { // get this_mod from our window's user data
    winampVisModule *this_mod = (winampVisModule *) GetWindowLong(hwnd,GWL_USERDATA);
    PostMessage(this_mod->hwndParent,message,wParam,lParam);
    }
    return 0;
    case WM_MOVE:
    { // get config_x and config_y for configuration
    RECT r;
    GetWindowRect(hMainWnd,&r);
    config_x = r.left;
    config_y = r.top;
    }
    return 0;
    }
    return DefWindowProc(hwnd,message,wParam,lParam);
    }


    void config_getinifn(struct winampVisModule *this_mod, char *ini_file)
    { // makes a .ini file in the winamp directory named "plugin.ini"
    char *p;
    GetModuleFileName(this_mod->hDllInstance,ini_file,MAX_PATH);
    p=ini_file+strlen(ini_file);
    while (p >= ini_file && *p != '\\') p--;
    if (++p >= ini_file) *p = 0;
    strcat(ini_file,"plugin.ini");
    }


    void config_read(struct winampVisModule *this_mod)
    {
    char ini_file[MAX_PATH];
    config_getinifn(this_mod,ini_file);
    config_x = GetPrivateProfileInt(this_mod->description,"Screen_x",config_x,ini_file);
    config_y = GetPrivateProfileInt(this_mod->description,"Screen_y",config_y,ini_file);
    }

    void config_write(struct winampVisModule *this_mod)
    {
    char string[32];
    char ini_file[MAX_PATH];

    config_getinifn(this_mod,ini_file);

    wsprintf(string,"%d",config_x);
    WritePrivateProfileString(this_mod->description,"Screen_x",string,ini_file);
    wsprintf(string,"%d",config_y);
    WritePrivateProfileString(this_mod->description,"Screen_y",string,ini_file);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. winamp
    By hartwork in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 09-11-2005, 07:54 AM
  2. create winamp like visualization in wav player?
    By V.G in forum Windows Programming
    Replies: 0
    Last Post: 10-13-2004, 07:08 AM
  3. remapping hotkeys and Winamp
    By confuted in forum Tech Board
    Replies: 0
    Last Post: 08-30-2003, 03:54 PM
  4. Manually programming Press any key in vis C++
    By vanceypants in forum C++ Programming
    Replies: 1
    Last Post: 06-06-2002, 04:23 AM
  5. The Winamp playlist file type
    By face_master in forum Windows Programming
    Replies: 3
    Last Post: 01-25-2002, 04:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21