E D R , A S I H C RSS

Winamp Plugin을이용한프로그래밍

winamp plugin

winamp 한 plugin .

input plugin output plugin . output plugin . DSP Visual plugin callback .

한 ACM 한 확 .


Simple Code

in2.h Out.h . http://www.winamp.com/nsdn/ Winamp SDK .


~cpp 
#include <windows.h>
#include <stdio.h>
#include "in2.h"

// define procedures, that'll be found in a .DLL
typedef In_Module* (*INHDRPROC)(void);
typedef Out_Module* (*OUTHDRPROC)(void);

// dsp-functions
int dsp_donothing(short int *, int cnt, int, int, int) {
	return cnt;
}
int dsp_isactive() {
	return 0;
}

// other functions, needed to get it to work
void SAVSAInit(int maxlatency_in_ms, int srate){
}

void SAVSADeInit(){
}

void SAAddPCMData(void *PCMData, int nch, int bps, int timestamp){
//	printf ("%d,%d,%d\n", nch,bps,timestamp);
}

int  SAGetMode(){
	return 0;
}

void SAAdd(void *data, int timestamp, int csa){
}

void VSAAddPCMData(void *PCMData, int nch, int bps, int timestamp){
//	printf ("%d,%d,%d\n", nch,bps,timestamp);
}

int  VSAGetMode(int *specNch, int *waveNch) {
	*specNch = *waveNch = 0;
	return 0;
}

void VSAAdd(void *data, int timestamp){
}

void VSASetInfo(int nch, int srate){
}

void SetInfo(int bitrate, int srate, int stereo, int synched){
}


void playFile() {

    // 플 DLL load 하 .
    HINSTANCE hout = LoadLibrary("out_wave.dll");
    HINSTANCE hin = LoadLibrary("in_vorbis.dll");

    //    
    INHDRPROC ihp = (INHDRPROC)GetProcAddress(hin,"winampGetInModule2");
    OUTHDRPROC ohp = (OUTHDRPROC)GetProcAddress(hout,"winampGetOutModule");

    // Mapping. 
    In_Module* in = ihp();
    Out_Module* out = ohp();
    
    //    .
    if (in->version != IN_VER || out->version != OUT_VER) 
    {
        FreeLibrary(hout);
        FreeLibrary(hin);
        return;
    }

    //   console mode .  window   NULL.
    out->hMainWindow = NULL;
    out->hDllInstance = hout;

    in->hMainWindow = NULL;
    in->hDllInstance = hin;


    if (in->UsesOutputPlug)
    {
        in->outMod = out;
    }

    //   . input plugin  Visual plugin  . 
    // 함  핑해.
    //      callback 함  .
    //  Visualization      .
    in->SAVSAInit = SAVSAInit;
    in->SAVSADeInit = SAVSADeInit;
    in->SAAdd = SAAdd;
    in->SAGetMode = SAGetMode;
    in->SAAddPCMData = SAAddPCMData;
    in->VSAAddPCMData = VSAAddPCMData;
    in->VSAGetMode = VSAGetMode;
    in->VSAAdd = VSAAdd;
    in->VSASetInfo = VSASetInfo;
    
    // DSP Plugin .   . 
    in->dsp_dosamples = dsp_donothing;
    in->dsp_isactive = dsp_isactive;

    in->SetInfo = SetInfo;

    // 플 화.
    out->Init();
    in->Init();

    char playFile[256] = "garden.ogg";
    
	printf ("%d \n", in->version); // 플  
	printf ("%s \n", in->description); // 플  
	printf ("%s \n", in->FileExtensions); // 해  .


    // if playing starts correctly
    if (!in->Play(playFile))
    {
        //  & panning (  balance) .
        in->SetVolume(255);
        in->SetPan(0);

        //int x = 1,len = in->GetLength();
        //for (;x=1 && in->GetOutputTime()<len;) Sleep(100);
        
		for (int i=0;i<10000;i++) {
			printf(" %d ms\n", in->GetLength()); //  play time (ms)
			printf("current : %d ms\n", in->GetOutputTime()); //  play time (ms)
			Sleep(1000); //  plugin     .
		}

        // when playing stops, terminate
        in->Stop();
    }

    // un-init plugins
    in->Quit();
    out->Quit();

    // dll   .
    FreeLibrary(hin);
    FreeLibrary(hout);

}

void main() {
	playFile();
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:26
Processing time 0.0114 sec