Posted: Sat Mar 22, 2008 6:21 am
Jesus Christ that post is 5 years old. Don't demand anything here. If it doesn't work because of the smileys then remove them yourself and don't expect others to do that for you.
Code: Select all
;## Winamp 2.x Vis Plugin example by Doobrey.
;## No asm was harmed in the making of this program.
#VIS_HDRVER =$101
Structure winampVisModule
description.l ;## Pointer to plugin description string
hWndParent.l ;## This lot is filled by Winamp .
hDllInstance.l
sRate.l
nCh.l
latencyMs.l ;## Set these 2 to time the calls to render()
delayMs.l
spectrumNch.l ;## Set these to what your render() needs
waveformNch.l ;## either 0,1 or 2 ..but I get wierd results on 1 :(
;## Winamp fills these 2 every render(), depending on what was set above ^^^^
spectrumData.b[1152] ;(2*576)
waveformData.b[1152] ;## 8 bit samples
Config.l ;## These 4 are the pointers to your routines.
Init.l
Render.l
Quit.l
UserData.l ;## pfffff??
EndStructure
Structure winampVisHeader
Version.l ;## **MUST** always be #VIS_HDRVER
description.l ;## Addr of module title string
getmodule.l ;## Addr of your getmodule() proc
EndStructure
Structure tmpspec
specdata.b[106]
EndStructure
Global hdr.winampVisHeader
Global Mod0.winampVisModule,Mod1.winampVisModule
Global imgnumber.l,rendercount.l,oldtitle.s,winamphwnd.l
Global Mem1.l,Mem2.l,Mem3.l,count.l,oldspec.tmpspec
Global Start_Plugin.l,Stop_Plugin.l
Procedure.s GetSongTitle() ;## RETURNS NULL IF SAME TITLE, OTHERWISE NEW TITLE
;## Full list of the usercodes on the Winamp2 dev forums.
If winamphwnd
songindex.l=SendMessage_(winamphwnd,#WM_USER,0,125)
titlepointer.l=SendMessage_(winamphwnd,#WM_USER,songindex,212)
If titlepointer
title.s=PeekS(titlepointer)
If title<>oldtitle
ProcedureReturn title
EndIf
EndIf
EndIf
EndProcedure
;## This little proc gets asked by winamp for the address of the winampVisModule struct
;## for every module you write. Return 0 to tell it there`s no more!
ProcedureC .l getModule(modnum.l)
pr.l=0
Select modnum ;## ONCE CASE PER MODULE
Case 0
pr= @Mod0
EndSelect
ProcedureReturn pr
EndProcedure
;## Put any user config stuff in this routine.
ProcedureC Config(*this_mod.winampVisModule)
MessageBox_(*this_mod\hWndParent,"Powered by PureBasic !","Config",#MB_OK)
EndProcedure
;## Init for fullscreen-o-rama
ProcedureC.l Init(*this_mod.winampVisModule)
winamphwnd=*this_mod\hWndParent
InitKeyboard()
InitSprite()
EndIf
OpenScreen(800,600,16,"winamp")
ProcedureReturn 0
EndProcedure
Procedure myrender()
If IsScreenActive()
StartDrawing(ScreenOutput())
DrawText(100,100,Str(Mod0\spectrumData&255))
DrawText(100,200,Str(Mod0\waveformData&255))
DrawText(300,300,GetSongTitle())
StopDrawing()
;## Better just check to see if escape has been pressed !
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
ProcedureReturn 1
EndIf
FlipBuffers(2)
ClearScreen(0)
Else
FlipBuffers(2)
delay(50)
EndIf
EndProcedure
;## The full screen render routine..
ProcedureC.l Render(*this_mod.winampVisModule)
pr=myrender()
ProcedureReturn pr
EndProcedure
Procedure myquit()
CloseScreen()
EndProcedure
;## Cleanup after Init0
ProcedureC Quit(*this_mod.winampVisModule)
myquit()
EndProcedure
;## This is called by winamp to examine all available plugin modes
;## Don`t init anything here, just return the address of the header structure!
ProcedureCDLL.l winampVisGetHeader()
;## GENERAL HEADER STUFF
hdr\Version=#VIS_HDRVER
hdr\description=?desc_label
hdr\getmodule=@getModule()
;## MODULE STUFF ..fill out one of these for each module in the plugin.
;## MODULE 0..FULL SCREEN
Mod0\description=?mod0_label
Mod0\latencyMs=50
Mod0\delayMs=50
Mod0\spectrumNch=2 ;# Gimme one of each
Mod0\waveformNch=2 ;# Wierd results when using 1 !
Mod0\Config=@Config()
Mod0\Init=@Init()
Mod0\Render=@Render()
Mod0\Quit=@Quit()
ProcedureReturn @hdr
EndProcedure
;## Quick and easy static strings
DataSection
desc_label:
Data.s "Doobreys PB Plugathlon"
mod0_label:
Data.s "Full Screen (escape to stop)"
mod1_label:
Data.s "Windowed mode"
EndDataSection
He should know the codes used smileys ( : ) : - ) ). If I ask there is a reason for that. I am not stupid at this point there.Fluid Byte wrote:Jesus Christ that post is 5 years old. Don't demand anything here. If it doesn't work because of the smileys then remove them yourself and don't expect others to do that for you.
Code: Select all
; GPI 12.02.2003
;
;
; IMPORTANT: The "Inline ASM" must aktivated Or The program will crash!
;
; Normaly The in-plugin send a #WM_WA_MPEG_EOF, If The file is played.
; This message can be Read With WindowEvent() And WaitWindowEvent().
;
;
; Return=Init_Winamp(in_dll$,out_dll$,WindowId)
; --------------------------------------
; must called befor you can use The other routines Or The programm will crash!
;
; Return error
; 0 no error
; -1 out_dll is no winamp-dll
; -2 can't open out_dll
; -3 in_dll is no winamp-dll
; -4 can't open in_dll
;
;
; Quit_Winamp()
; -------------
; End winamp.
;
;
; Return.s=Winamp_OutName()
; -------------------------
; Return The name of The out-plugin.
;
;
; Winamp_OutConfig(WindowId)
; --------------------------
; Open The config-dialog of The out-plugin.
;
;
; Winamp_OutAbout(WindowId)
; -------------------------
; Open The about-dialog of The out-plugin.
;
;
; Return=Winamp_IsPlaying()
; -------------------------
; Return <>0 If a Sound is playing.
; WARNING: This function checks only The state of The out-plugin. It is possible, that a in-plugin don't need the out-plugin. In this case the Winamp_IsPlaying() will always return 0.
;
;
; Return.s=Winamp_InName()
; ------------------------
; Return The name of The in-plugin.
;
;
; Return=Winamp_isSeekable()
; --------------------------
; Return <>0, If a The in-plugin is seekable.
; IMPORTANT: This check isn't alway right. For example the in_mp3.dll does say, that it isn't seekable. Ignore It.
;
;
; Return.s=Winamp_OnlyExtensions()
; --------------------------------
; Return all The supported mediafiles. ("*.mp1;*.mp2;*.mp3)
;
;
; Return.s=Winamp_Extensions()
; ----------------------------
; Return The extentions And The type name of all supported mediafiles. Ready For use With OpenFileRequester And SaveFileRequester. ("Layer3 MPEG|*.mp3|Layer 2 MPEG|*.mp2|Layer 1 MPEG|*.mp1")
;
;
; Winamp_InConfig(WindowId)
; -------------------------
; Open The config-dialog of The in-plugin.
;
;
; Winamp_Inabout(WindowId)
; ------------------------
; Open The about-dialog of The in-plugin.
;
;
; Return.s=Winamp_GetFileInfo(playfile$,@length_ms)
; -------------------------------------------------
; Return The title of a file And The length in ms.
; IMPORTANT: The function will overwrite The length_ms! don't forget the @ or the program can crash.
;
;
; Winamp_InfoBox(playfile$,WindowId)
; ----------------------------------
; Open The file-info-dialog of The in-plugin. Not supported of all pluggins (=The will do nothing)
;
;
; Return=Winamp_IsOurFile(stream$)
; --------------------------------
; used For detecting URL streams
;
;
; Return=Winamp_Play(playfile$)
; -----------------------------
; Play The file. Return 0 If no error happend.
; WARNING: When call Winamp_Play() again without stop The playing before, some in-plugin can crash. i insert a small test With Winamp_IsPlaying(), but If The in-plugin doesn't use the out-plugin the test is useless.
;
;
; Return=Winamp_IsPaused()
; ------------------------
; Return <>0 If paused.
;
;
; Winamp_Pause()
; --------------
; First call pause The Sound And The second call unpause It.
;
;
; Winamp_Stop()
; -------------
; stop playing.
; WARNING: If no Sound is playing, some plugin can crash.
;
;
; Return=Winamp_GetLength()
; -------------------------
; Returns The length of The playing file in ms.
;
;
; Return$=Winamp_LengthStr(length)
; --------------------------------
; Convert The length To a string. Format: "h:mm:ss".
;
;
; Return=Winamp_GetOutputTime()
; -----------------------------
; Return The current playing Position.
;
;
; Winamp_SetOutputTime(length)
; ----------------------------
; Set The playing Position Position. Not supported of all in-plugins. Also It can be very slow.
;
;
; Winamp_SetVolume(volume)
; ------------------------
; Set The volume (0 To 255)
;
;
; Winamp_SetPan(pan)
; ------------------
; Set The pan (left=-127 To 127=right)
;
;
;
; winamp.pbi
; <pre id="code"><font face="courier" Size="2" id="code">;***;*** Winamp-Pluginuser
; ;***
#WM_WA_MPEG_EOF=#WM_USER+2
#DLL_WINAMP_IN=100
#DLL_WINAMP_OUT=101
;-Structure
Structure winamp_out_module
Version.l ;module version (OUT_VER)
*description.s ;description of module, with version string
id.l ;module id. each input module gets its own. non-nullsoft modules should be >= 65536.
hMainWindow.l ;winamp's main window (filled in by winamp)
hDllInstance.l ;DLL instance handle (filled in by winamp)
config.l ;void (*Config)(HWND hwndParent); // configuration dialog
about.l ;void (*About)(HWND hwndParent); // about dialog
Init.l ;void (*Init)(); // called when loaded
Quit.l ;void (*Quit)(); // called when unloaded
Open.l ; Int (*Open)(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms);
; // returns >=0 on success, <0 on failure
; // NOTENOTENOTE: bufferlenms And prebufferms are ignored in most If not all output plug-ins.
; // ... so don't expect the max latency returned to be what you asked for.
; // returns max latency in ms (0 For diskwriters, etc)
; // bufferlenms And prebufferms must be in ms. 0 To use defaults.
; // prebufferms must be <= bufferlenms
Close.l ;void (*Close)(); // close the ol' output device.
Write.l ; Int (*Write)(char *buf, int len);
; // 0 on success. Len == bytes To write (<= 8192 always). buf is straight audio Data.
; // 1 returns not able To write (yet). Non-blocking, always.
CanWrite.l ; Int (*CanWrite)(); // returns number of bytes possible to write at a given time.
; // Never will decrease unless you call Write (Or Close, heh)
IsPlaying.l ; Int (*IsPlaying)(); // non0 if output is still going or if data in buffers waiting to be
; // written (i.e. closing While IsPlaying() returns 1 would truncate the song
Pause.l ; Int (*Pause)(int pause); // returns previous pause state
SetVolume.l ;void (*SetVolume)(int volume); // volume is 0-255
SetPan.l ;void (*SetPan)(int pan); // pan is -128 to 128
Flush.l ;void (*Flush)(int t); // flushes buffers and restarts output at time t (in ms)
; // (used For seeking)
GetOutputTime.l ; Int (*GetOutputTime)(); // returns played time in MS
GetWrittenTime.l ; Int (*GetWrittenTime)(); // returns time written in MS (used for synching up vis stuff)
EndStructure
Structure winamp_in_module
version.l ;module type (IN_VER)
*description.s ;description of module, with version string
hMainWindow.l ;winamp's main window (filled in by winamp)
hDllInstance.l ;DLL instance handle (Also filled in by winamp)
FileExtensions.l ;"mp3\0Layer 3 MPEG\0mp2\0Layer 2 MPEG\0mpg\0Layer 1 MPEG\0"
; May be altered from Config, so the user can Select what they want
is_seekable.l ;is this stream seekable?
UsesOutputPlug.l ;does this plug-in use the output plug-ins? (musn't ever change, ever :)
Config.l ;void (*Config)(HWND hwndParent); // configuration dialog
About.l ;void (*About)(HWND hwndParent); // about dialog
Init.l ;void (*Init)(); // called at program init
Quit.l ;void (*Quit)(); // called at program quit
GetFileInfo.l ;void (*GetFileInfo)(char *file, char *title, int *length_in_ms);
; // If file == NULL, current playing is used
InfoBox.l ; Int (*InfoBox)(char *file, HWND hwndParent);
IsOurFile.l ; Int (*IsOurFile)(char *fn); // called before extension checks, to allow detection of mms://, etc
;playback stuff
Play.l ; Int (*Play)(char *fn); // return zero on success, -1 on file-not-found, some other value on other (stopping winamp) error
Pause.l ;void (*Pause)(); // pause stream
UnPause.l ;void (*UnPause)(); // unpause stream
IsPaused.l ; Int (*IsPaused)(); // ispaused? return 1 if paused, 0 if not
Stop.l ;void (*Stop)(); // stop (unload) stream
;time stuff
GetLength.l ; Int (*GetLength)(); // get length in ms
GetOutputTime.l ; Int (*GetOutputTime)(); // returns current output time in ms. (usually returns outMod->GetOutputTime()
SetOutputTime.l ;void (*SetOutputTime)(int time_in_ms); // seeks to point in stream (in ms). Usually you signal yoru thread to seek, which seeks and calls outMod->Flush()..
;volume stuff
SetVolume.l ;void (*SetVolume)(int volume); // from 0 to 255.. usually just call outMod->SetVolume
SetPan.l ;void (*SetPan)(int pan); // from -127 to 127.. usually just call outMod->SetPan
;in-window builtin vis stuff
SAVSAInit.l ;void (*SAVSAInit)(int maxlatency_in_ms, int srate);
; // call once in Play(). maxlatency_in_ms should be the value returned from outMod->Open()
; // call after opening audio device with max latency in ms And samplerate
SAVSADeInit.l ;void (*SAVSADeInit)(); // call in Stop()
;simple vis supplying mode
SAAddPCMData.l ;void (*SAAddPCMData)(void *PCMData, int nch, int bps, int timestamp);
; // sets the spec Data directly from PCM Data
; // quick And easy way To get vis working :)
; // needs at least 576 samples :)
;advanced vis supplying mode, only use If you're cool. Use SAAddPCMData for most stuff.
SAGetMode.l ; Int (*SAGetMode)(); // gets csa (the current type (4=ws,2=osc,1=spec))
; // use when calling SAAdd()
SAAdd.l ;void (*SAAdd)(void *data, int timestamp, int csa);
; // sets the spec data, filled in by winamp
;vis stuff (plug-in)
; simple vis supplying mode
VSAAddPCMData.l ;void (*VSAAddPCMData)(void *PCMData, int nch, int bps, int timestamp)
; // sets the vis data directly from PCM data
; // quick And easy way To get vis working :)
; // needs at least 576 samples :)
; advanced vis supplying mode, only use If you're cool. Use VSAAddPCMData for most stuff.
VSAGetMode.l ;Int (*VSAGetMode)(int *specNch, int *waveNch)
; // use to figure out what to give to VSAAdd
VSAAdd.l ;void (*VSAAdd)(void *data, int timestamp);// filled in by winamp, called by plug-in
;call this in Play() To tell the vis plug-ins the current output params.
VSASetInfo.l ;void (*VSASetInfo)(int nch, int srate);
;dsp plug-in processing:
;(filled in by winamp, called by input plug)
;returns 1 If active (which means that the number of samples returned by dsp_dosamples
;could be greater than went in.. Use it To estimate If you'll have enough room in the
;output buffer
dsp_isactive.l ;Int (*dsp_isactive)();
;returns number of samples To output. This can be as much as twice numsamples.
;be sure To allocate enough buffer For samples, then.
dsp_dosamples.l ;Int (*dsp_dosamples)(short int *samples, int numsamples, int bps, int nch, int srate);
;eq stuff
EQSet.l ;void (*EQSet)(int on, char data[10], int preamp); // 0-64 each, 31 is +0, 0 is +12, 63 is -12. Do nothing to ignore.
;info setting (filled in by winamp)
SetInfo.l ;void (*SetInfo)(int bitrate, int srate, int stereo, int synched); // if -1, changes ignored? :)
outMod.l ;winamp_out_module *outMod; // filled in by winamp, optionally used :)
EndStructure
;-Global
Global *winamp_out_head.winamp_out_module
Global *winamp_in_head.winamp_in_module
Global winamp_return_long.l
Global winamp_return_string.s
Procedure winamp_setinfo_():EndProcedure
Procedure winamp_dsp_isactive_():EndProcedure
Procedure winamp_dsp_dosamples_(pointer,numsamples,bps,nch,srate)
ProcedureReturn numsamples
EndProcedure
Procedure winamp_SAVSAInit_():EndProcedure
Procedure winamp_SAVSADeInit_():EndProcedure
Procedure winamp_SAAddPCMData_():EndProcedure
Procedure winamp_SAGetMode_():EndProcedure
Procedure winamp_SAAdd_():EndProcedure
Procedure winamp_VSAAddPCMData_():EndProcedure
Procedure winamp_VSAGetMode_():EndProcedure
Procedure winamp_VSAAdd_():EndProcedure
Procedure winamp_VSASetInfo_():EndProcedure
Declare winamp_stop()
Declare winamp_setoutputtime(time)
Declare Winamp_IsPlaying()
Procedure Quit_Winamp()
If *winamp_in_head
If Winamp_IsPlaying() :Winamp_Stop():EndIf
CallFunctionFast(*winamp_in_head\Quit)
CloseLibrary(#DLL_WINAMP_IN)
*winamp_in_head=0
EndIf
If *winamp_out_head
CallFunctionFast(*winamp_out_head\Quit)
CloseLibrary(#DLL_WINAMP_OUT)
*winamp_out_head=0
EndIf
EndProcedure
Procedure Init_Winamp(in_dll$,out_dll$,WindowId)
;return
; 0 no error.
; -1 out_dll is no winamp-dll
; -2 can't open out_dll
; -3 in_dll is no winamp-dll
; -4 can't open in_dll
If *winamp_out_head<>0 Or *winamp_in_head<>0
Quit_Winamp()
EndIf
out_DLLinstance=OpenLibrary(#DLL_WINAMP_OUT, out_dll$)
If out_DLLinstance
*winamp_out_head=CallFunction(#DLL_WINAMP_OUT,"winampGetOutModule")
If *winamp_out_head
*winamp_out_head\hMainWindow=WindowID(0)
*winamp_out_head\hDllInstance=out_DLLinstance
CallFunctionFast(*winamp_out_head\Init)
Else
CloseLibrary(#DLL_WINAMP_OUT)
*winamp_out_head=0:*winamp_in_head=0
ProcedureReturn -1
EndIf
Else
*winamp_out_head=0:*winamp_in_head=0
ProcedureReturn -2
EndIf
in_DLLinstance= OpenLibrary(#dll_winamp_in, in_dll$)
If in_DLLinstance
*winamp_in_head = CallFunction(#dll_winamp_in, "winampGetInModule2" )
If *winamp_in_head
*winamp_in_head\hMainWindow=WindowID
*winamp_in_head\hDllInstance=in_DLLinstance
*winamp_in_head\outMod=*winamp_out_head
CallFunctionFast(*winamp_in_head\Init)
;dummy-routines
*winamp_in_head\SetInfo=@winamp_setinfo_()
*winamp_in_head\dsp_isactive =@winamp_dsp_isactive_()
*winamp_in_head\dsp_dosamples=@winamp_dsp_dosamples_()
*winamp_in_head\SAVSAInit =@winamp_SAVSAInit_()
*winamp_in_head\SAVSADeInit =@winamp_SAVSADeInit_()
*winamp_in_head\SAAddPCMData =@winamp_SAAddPCMData_()
*winamp_in_head\SAGetMode =@winamp_SAGetMode_()
*winamp_in_head\SAAdd =@winamp_SAAdd_()
*winamp_in_head\VSASetInfo =@winamp_VSASetInfo_()
*winamp_in_head\VSAAddPCMData=@winamp_VSAAddPCMData_()
*winamp_in_head\VSAGetMode =@winamp_VSAGetMode_()
*winamp_in_head\VSAAdd =@winamp_VSAAdd_()
Else
CallFunctionFast(*winamp_out_head\quit)
CloseLibrary(#DLL_WINAMP_OUT)
CloseLibrary(#dll_winamp_in)
*winamp_out_head=0:*winamp_in_head=0
ProcedureReturn -3
EndIf
Else
CallFunctionFast(*winamp_out_head\quit)
CloseLibrary(#DLL_WINAMP_OUT)
*winamp_out_head=0:*winamp_in_head=0
ProcedureReturn -4
EndIf
ProcedureReturn 0
EndProcedure
Procedure.s Winamp_OutName()
ProcedureReturn *winamp_out_head\description
EndProcedure
Procedure Winamp_OutConfig(windowid)
CallFunctionFast(*winamp_out_head\config,windowid)
!ADD esp,4
EndProcedure
Procedure Winamp_OutAbout(windowid)
CallFunctionFast(*winamp_out_head\about,windowid)
!ADD esp,4
EndProcedure
Procedure Winamp_IsPlaying()
winamp_return_long=CallFunctionFast(*winamp_out_head\IsPlaying)
ProcedureReturn winamp_return_long
EndProcedure
Procedure.s Winamp_InName()
ProcedureReturn *winamp_in_head\description
EndProcedure
Procedure Winamp_isSeekable()
ProcedureReturn *winamp_in_head\is_seekable
EndProcedure
Procedure.s Winamp_OnlyExtensions()
adr=*winamp_in_head\FileExtensions
ok=0:out$="*.":exit=0:l=1
Repeat
a=PeekB(adr):adr+1
If a=0 And ok=0
ok=-1
ElseIf a=0 And ok
exit=-1
Else
If ok
ok=0
If l=0
out$+";*."
l=1
Else
l=0
EndIf
EndIf
EndIf
If l
If a=59
out$+";*."
Else
out$+Chr(a)
EndIf
EndIf
Until exit
ProcedureReturn out$
EndProcedure
Procedure.s Winamp_Extensions()
adr=*winamp_in_head\FileExtensions
ok=0:exit=0:l=0
Repeat
a=PeekB(adr):adr=adr+1
If a=0 And o1$<>"" And o2$<>""
If out$<>"":out$+"|":EndIf
If Left(o2$,2)<>"*.":o2$="*."+o2$:EndIf
out$+o1$+"|"+o2$
o1$="":o2$=""
EndIf
If a=0 And ok=0
ok=-1
ElseIf a=0 And ok
exit=-1
Else
If ok
ok=0
If l=0
o1$="*."
l=1
Else
o2$=""
l=0
EndIf
EndIf
If l=0
If a=59
o2$+";*."
Else
o2$+Chr(a)
EndIf
Else
o1$+Chr(a)
EndIf
EndIf
Until exit
ProcedureReturn out$
EndProcedure
Procedure Winamp_InConfig(windowid)
CallFunctionFast(*winamp_in_head\config,windowid)
!ADD esp,4
EndProcedure
Procedure Winamp_InAbout(windowid)
CallFunctionFast(*winamp_in_head\about,WindowID)
!ADD esp,4
EndProcedure
Procedure.s Winamp_GetFileInfo(playfile$,length_adr)
winamp_return_string=Space(1000)
CallFunctionFast(*winamp_in_head\getfileinfo,@playfile$,@winamp_return_string,length_adr)
!ADD esp,12
ProcedureReturn winamp_return_string
EndProcedure
Procedure Winamp_InfoBox(playfile$,windowid)
winamp_return_long=CallFunctionFast(*winamp_in_head\infobox,@playfile$,windowid)
!ADD esp,8
ProcedureReturn winamp_return_long
EndProcedure
Procedure Winamp_IsOurFile(playfile$)
;used For detecting URL streams.. unused here. strncmp(fn,"http://",7) To detect HTTP streams, etc
winamp_return_long=CallFunctionFast(*winamp_in_head\isourfile,@playfile$)
!add esp,4
ProcedureReturn winamp_return_long
EndProcedure
Procedure Winamp_Play(playfile$)
If winamp_isplaying() :winamp_stop():EndIf ; or it can crash
winamp_return_long=CallFunctionFast(*winamp_in_head\play,@playfile$)
!ADD esp,4
ProcedureReturn winamp_return_long
EndProcedure
Procedure Winamp_IsPaused()
winamp_return_long=CallFunctionFast(*winamp_in_head\ispaused)
ProcedureReturn winamp_return_long
EndProcedure
Procedure Winamp_Pause()
If winamp_ispaused()
CallFunctionFast(*winamp_in_head\unpause)
Else
CallFunctionFast(*winamp_in_head\pause)
EndIf
EndProcedure
Procedure Winamp_Stop()
CallFunctionFast(*winamp_in_head\stop)
EndProcedure
Procedure Winamp_GetLength()
winamp_return_long=CallFunctionFast(*winamp_in_head\GetLength)
ProcedureReturn winamp_return_long
EndProcedure
Procedure.s Winamp_LengthStr(length)
out$=""
a=length/(60*60*1000):length-(a*60*60*1000)
out$=Str(a)
a=length/(60*1000):length-(a*60*1000)
out$+":"+Right("0"+Str(a),2)
a=length/1000
out$+":"+Right("0"+Str(a),2)
ProcedureReturn out$
EndProcedure
Procedure Winamp_GetOutputTime()
winamp_return_long=CallFunctionFast(*winamp_in_head\GetOutputTime)
ProcedureReturn winamp_return_long
EndProcedure
Procedure Winamp_SetOutputTime(time)
CallFunctionFast(*winamp_in_head\SetOutputTime,time)
!ADD Esp,4
EndProcedure
Procedure Winamp_SetVolume(volume)
CallFunctionFast(*winamp_in_head\SetVolume,volume)
!ADD Esp,4
EndProcedure
Procedure Winamp_SetPan(pan)
CallFunctionFast(*winamp_in_head\SetPan,pan)
!ADD Esp,4
EndProcedure
; Example.pb
; <pre id="code"><font face="courier" Size="2" id="code">;Small Winamp-Demo
;WM_WA_MPEG_EOF
; IncludeFile "winamp.pbi"
If OpenWindow(0, 0,0,340,265,"Winamp-Plugin-Test",#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget )
If CreateGadgetList(WindowID(0))
top=10
ButtonGadget( 0, 10,top ,100,20, "ChangeOut")
ButtonGadget( 1, 120,top ,100,20, "OutConfig")
ButtonGadget( 2, 230,top ,100,20, "OutAbout"):top+22
TextGadget ( 3, 10,top ,100,20, "",#PB_Text_Center)
TextGadget ( 4, 120,top ,210,20, "",#PB_Text_Center):top+22
top+5
ButtonGadget( 5, 10,top ,100,20, "ChangeIn")
ButtonGadget( 6, 120,top ,100,20, "InConfig")
ButtonGadget( 7, 230,top ,100,20, "InAbout"):top+22
TextGadget ( 8, 10,top ,100,20, "",#PB_Text_Center)
TextGadget ( 9, 120,top ,210,20, "",#PB_Text_Center):top+22
top+5
ButtonGadget(10, 10,top ,100,20, "Open")
ButtonGadget(11, 120,top ,100,20, "InfoBox")
TextGadget (12, 230,top ,100,20, ""):top+22
TextGadget (13, 10,top ,210,20, "",#PB_Text_Center)
TextGadget (14, 230,top ,100,20, ""):top+22
top+5
ButtonGadget(15, 10,top ,100,20, "Play")
ButtonGadget(16, 120,top ,100,20, "Stop")
ButtonGadget(17, 230,top ,100,20, "Pause"):top+22
top+5
TextGadget (18, 10,top , 64,20, "Volume")
TrackBarGadget(19, 74,top ,256,20,0,255):top+22
TextGadget (20, 10,top , 64,20, "Pan")
TrackBarGadget(21, 74,top ,256,20,-127+127,127+127):top+22
top+5
TextGadget (22, 10,top , 64,20, "Position")
TrackBarGadget(23, 74,top ,256,20,0,255):top+22
DisableGadget(23,1)
in_dll$="": in_des$=""
out_dll$="":out_des$=""
playfile$="":Title$="":length$="":length_ms=0
volume=255:pan=0:Position=0:pos$=""
SetGadgetState(19,volume): SetGadgetState(21,pan+127)
changed=1:winamp_install=-1:reload=1
Repeat
If reload
If out_dll$<>"" And in_dll$<>""
winamp_install=Init_Winamp(in_dll$,out_dll$,WindowID(0))
Select winamp_install
Case 0
Winamp_SetVolume(volume)
Winamp_SetPan(pan)
in_des$=Winamp_InName()
out_des$=Winamp_OutName()
;If winamp_isseekable() ;<- don't use id ...
DisableGadget(23,0)
;Else
; DisableGadget(23,1)
;EndIf
Case -1
MessageRequester("MiniWinamp",GetFilePart(out_dll$)+" is no winamp-out-plugin",#PB_MessageRequester_Ok)
out_dll$="":out_des$=""
Case -2
MessageRequester("MiniWinamp","Can't open "+GetFilePart(out_dll$),#PB_MessageRequester_Ok)
out_dll$="":out_des$=""
Case -3
MessageRequester("MiniWinamp",GetFilePart(in_dll$)+" is no winamp-in-plugin",#PB_MessageRequester_Ok)
in_dll$="":in_des$=""
Case -4
MessageRequester("MiniWinamp","Can't open "+GetFilePart(in_dll$),#PB_MessageRequester_Ok)
in_dll$="":in_des$=""
EndSelect
EndIf
reload=0
changed=1
EndIf
If changed
SetGadgetText(3,GetFilePart(out_dll$)): SetGadgetText(4,out_des$)
SetGadgetText(8,GetFilePart(in_dll$)) : SetGadgetText(9,in_des$)
SetGadgetText(12,GetFilePart(playfile$)):SetGadgetText(13,Title$):SetGadgetText(14,length$)
changed=0
EndIf
Repeat ; i know, cpu=100%, but it is only a demo!
If winamp_install=0 And length_ms>0
i=Winamp_GetOutputTime()
a$=Winamp_LengthStr(i)
If a$<>pos$
SetGadgetText(22,a$)
pos$=a$
EndIf
i=i*255/length_ms
If i<0:i=0:EndIf
If i>255:i=255:EndIf
If i<>GetGadgetState(23)
Position=i
SetGadgetState(23,Position)
EndIf
EventID=WindowEvent()
Else
EventID=WaitWindowEvent()
EndIf
Until EventID<>0
Select EventID
Case #WM_WA_MPEG_EOF; File played!
MessageRequester("MiniWinamp","File Played.",#PB_MessageRequester_Ok)
Case #PB_Event_CloseWindow
Quit=1
Case #PB_Event_Gadget
EventType=EventType()
gadgetid=EventGadget()
Select gadgetid
Case 0;ChangeOut
out_dll$=OpenFileRequester("Winamp Out-Plugin","out_","Winamp Out-Plugin|out_*.dll|all|*.*",0)
reload=1
Case 5;ChangeIn
in_dll$=OpenFileRequester("Winamp In-Plugin","in_","Winamp In-Plugin|in_*.dll|all|*.*",0)
reload=1
Case 19;volume
volume=GetGadgetState(19)
If volume<0:volume=0:EndIf
If volume>255:volume=255:EndIf
If winamp_install=0:Winamp_SetVolume(volume):EndIf
Case 21;pan
pan=GetGadgetState(21)-127
If pan<-127:pan=-127:EndIf
If pan>127:pan=127:EndIf
If winamp_install=0:Winamp_SetPan(pan):EndIf
Default; only when winamp function
If winamp_install=0
Select gadgetid
Case 1:Winamp_OutConfig(WindowID(0))
Case 2:Winamp_OutAbout(WindowID(0))
Case 6:Winamp_InConfig(WindowID(0))
Case 7:Winamp_Inabout(WindowID(0))
Case 10;open
If Winamp_IsPlaying() :Winamp_Stop():EndIf
pat$="Modul|"+Winamp_OnlyExtensions()+"|"+Winamp_Extensions()
playfile$=OpenFileRequester("Winamp File","",pat$,0)
Title$=Winamp_GetFileInfo(playfile$,@length_ms)
length$=Winamp_LengthStr(length_ms)
changed=1
Default
If playfile$=""
MessageRequester("MiniWinamp","Please open file first.",#PB_MessageRequester_Ok)
If gadgetid=23
SetGadgetState(23,0)
EndIf
Else
Select gadgetid
Case 11;infobox
Winamp_InfoBox(playfile$,WindowID(0))
Case 15;play
i=Winamp_Play(playfile$)
If i<>0
MessageRequester("MiniWinamp","Can't play "+GetFilePart(playfile$),#PB_MessageRequester_Ok)
EndIf
Case 16;stop
Winamp_Stop()
Case 17;pause
Winamp_Pause()
Case 23
i=GetGadgetState(23)
If i<>Position
i=i*length_ms/255
If i<0:i=0:EndIf
If i>length_ms:i=length_ms:EndIf
Winamp_SetOutputTime(i)
EndIf
EndSelect
EndIf
EndSelect
Else
If EventID>0 And EventID<19
MessageRequester("MiniWinamp","Please load first the plugins.",#PB_MessageRequester_Ok)
EndIf
EndIf
EndSelect
EndSelect
Until Quit
EndIf
EndIf
If winamp_install=0 :Quit_Winamp():EndIf
zxtunes.com wrote:This code not completely the worker.
And in_vtx.dll too crash.Psychophanta wrote:zxtunes.com wrote:This code not completely the worker.![]()
It works like a charm here! except with in_vgm.dll![]()
I used several plugins:
in_msx.dll, in_nez.dll, in_snes.dll, ...
With in_vgm.dll the program just quits without any message when after push "play" with a .vgz module.
There are 2 versions in_vtx.dll - 3-rd (crash) and 4-th (works but uses many resources cpu)Psychophanta wrote:It works here without problems with in_vtx.dll (may be my in_vtx.dll is a correct version? )!
Tested with tune Shock5.vtx at
http://zxtunes.com/author.php?id=743
And by the way what is the plugin needed to play .sqt tunes ?? For example these:
http://zxtunes.com/author.php?id=698
?