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