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.0048 sec