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(); }