Advertisement
Testaware

in_PureAmp.dll v1.06 (x86)

Nov 15th, 2018
2,965
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; **************************************************
  2. ; Name:        in_PureAmp.dll v1.06 (x86)
  3. ; --------------------------------------------------
  4. ; Description: WinAmp Player-Plugin (untested)
  5. ; Author:      Peace / Testaware
  6. ; Code:        Purebasic v5.44 LTS - Windows x86
  7. ; Create:      30.08.2017 12:11
  8. ; Update:      15.11.2018 14:02
  9. ; Home:        https://testaware.wordpress.com/
  10. ; **************************************************
  11.  
  12. ;EnableExplicit
  13.  
  14. #IN_VER  =  $100
  15.  
  16. ; ImageDecoder (0=off, 1=on)
  17. #IsIFF   =  1  ; Use IFF
  18. #IsGDI   =  1  ; Use GDI+
  19. #IsIDX   =  1  ; Use Registered
  20. #IsDDS   =  1  ; Use DDS
  21.  
  22. #IsXUP   =  1  ; Use Uncompress (PP20;XPKF;FIMP...)
  23.  
  24. #PA_Raster        =  8  ; px-rastesize
  25. #PA_DefaultLength =  -1 ;300000
  26.  
  27. #PA_WinW    =  130   ; min. Win-Width
  28. #PA_WinH    =  10    ; min. Win-Height
  29. #PA_WinMaxW =  1024  ; max. width
  30. #PA_WinMaxH =  768   ; max. height
  31.  
  32. Enumeration 1  ; Format-IDentifer
  33.    #ID_AUD
  34.    #ID_HTM
  35.    #ID_MCI
  36.    #ID_MOD
  37.    #ID_MOV
  38.    #ID_PIC
  39.    #ID_SND
  40.    #ID_TXT
  41. EndEnumeration
  42.  
  43. Enumeration ; Window
  44.    #W_Main
  45. EndEnumeration
  46.  
  47. Enumeration ; Gadgets
  48.    #G_Area
  49.    #G_Canvas
  50.    #G_Editor
  51. EndEnumeration
  52.  
  53. ;* IN_WinAmp
  54. Structure IN_WinAmp  Align #PB_Structure_AlignC
  55.    version.i            ;* module type (IN_VER)
  56.    *description         ;* description of module, with version string
  57.    *hMainWindow         ;* winamp's main window (filled in by winamp)
  58.    *hDllInstance        ;* DLL instance handle (Also filled in by winamp)
  59.    *FileExtensions      ;* "mp3\0Layer 3 MPEG\0mp2\0Layer 2 MPEG\0mpg\0Layer 1 MPEG\0"
  60.    is_seekable.i        ;* is this stream seekable?
  61.    UsesOutputPlug.i     ;* does this plug-in use the output plug-ins?
  62.    *Config              ;* void (*Config)(HWND hwndParent);       // configuration dialog
  63.    *About               ;* void (*About)(HWND hwndParent);        // about dialog
  64.    *Init                ;* void (*Init)();                        // called at program init
  65.    *Quit                ;* void (*Quit)();                        // called at program quit
  66.    *GetFileInfo         ;* void (*GetFileInfo)(char *file, char *title, int *length_in_ms); // If file == NULL, current playing is used
  67.    *InfoBox             ;*  Int (*InfoBox)(char *file, HWND hwndParent);
  68.    *IsOurFile           ;*  Int (*IsOurFile)(char *fn);           // called before extension checks, to allow detection of mms://, etc
  69.    *Play                ;*  Int (*Play)(char *fn);                // return zero on success, -1 on file-not-found, some other value on other (stopping winamp) error
  70.    *Pause               ;* void (*Pause)();                       // pause stream
  71.    *UnPause             ;* void (*UnPause)();                     // unpause stream
  72.    *IsPaused            ;*  Int (*IsPaused)();                    // ispaused? return 1 if paused, 0 if not
  73.    *Stop                ;* void (*Stop)();                        // stop (unload) stream
  74.    *GetLength           ;*  Int (*GetLength)();                   // get length in ms
  75.    *GetOutputTime       ;*  Int (*GetOutputTime)();               // returns current output time in ms. (usually returns outMod->GetOutputTime()
  76.    *SetOutputTime       ;* void (*SetOutputTime)(int time_in_ms); // seeks to point in stream (in ms). Usually you signal your thread to seek, which seeks and calls outMod->Flush()..
  77.    *SetVolume           ;* void (*SetVolume)(int volume);         // from 0 to 255.. usually just call outMod->SetVolume
  78.    *SetPan              ;* void (*SetPan)(int pan);               // from -127 to 127.. usually just call outMod->SetPan
  79.    *SAVSAInit           ;* void (*SAVSAInit)(int maxlatency_in_ms, int srate);
  80.    *SAVSADeInit         ;* void (*SAVSADeInit)();                 // call in Stop()
  81.    *SAAddPCMData        ;* void (*SAAddPCMData)(void *PCMData, int nch, int bps, int timestamp);
  82.    *SAGetMode           ;*  Int (*SAGetMode)();                   // gets csa (the current type (4=ws,2=osc,1=spec))
  83.    *SAAdd               ;* void (*SAAdd)(void *data, int timestamp, int csa);
  84.    *VSAAddPCMData       ;* void (*VSAAddPCMData)(void *PCMData, int nch, int bps, int timestamp)
  85.    *VSAGetMode          ;* Int (*VSAGetMode)(int *specNch, int *waveNch)
  86.    *VSAAdd              ;* void (*VSAAdd)(void *data, int timestamp)
  87.    *VSASetInfo          ;* void (*VSASetInfo)(int nch, int srate)
  88.    *dsp_isactive        ;* Int (*dsp_isactive)();
  89.    *dsp_dosamples       ;* Int (*dsp_dosamples)(short int *samples, int numsamples, int bps, int nch, int srate);
  90.    *EQSet               ;* 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.
  91.    *SetInfo             ;* void (*SetInfo)(int bitrate, int srate, int stereo, int synched); // if -1, changes ignored?
  92.    *outMod              ;* winamp_out_module *outMod; // filled in by winamp, optionally used
  93. EndStructure
  94.  
  95. Structure   PureAmp
  96.    IsPause.i
  97.    IsPlay.i
  98.    IsMCI.i
  99.    IsGIF.i
  100.    Length.q
  101.    Pan.i
  102.    Position.q
  103.    Volume.i
  104.    Buffer.s{#MAX_PATH}
  105. EndStructure
  106.  
  107. Structure   PureInfo
  108.    Decoder.s
  109.    Encoder.s   ; IFF,GDI+...
  110.    Width.i
  111.    Height.i
  112.    Depth.i
  113.    Length.q
  114.    Speed.i
  115.    Frames.i
  116.    Fps.i
  117.    Herz.i
  118.    Colors.i
  119.    NoInfo.s
  120. EndStructure
  121.  
  122. Macro MA_MsgBox(WIN, TXT, TIT)
  123.    MessageBox_(WIN, TXT, TIT, #MB_OK)
  124. EndMacro
  125.  
  126. ProcedureDLL   AttachProcess(Instance)
  127.  
  128.    Global   PA.PureAmp
  129.    Global   PI.PureInfo ; PureAmp_InfoBox
  130.    Global   *In_Module.IN_WinAmp
  131.  
  132. EndProcedure
  133. ProcedureDLL   DetachProcess(Instance)
  134.  
  135.    With  PA
  136.  
  137.       If \IsPlay
  138.  
  139.          If       \IsMCI            :  mciSendString_("CLOSE " + Str(#ID_MCI), 0, 0, 0)
  140.          ElseIf   IsMovie(#ID_AUD)  :  FreeMovie(#ID_AUD)
  141.          ElseIf   IsMovie(#ID_MOV)  :  FreeMovie(#ID_MOV)
  142.          ElseIf   IsSound(#ID_SND)  :  FreeSound(#ID_SND)
  143.          ElseIf   IsMusic(#ID_MOD)  :  FreeMusic(#ID_MOD)
  144.          ElseIf   IsImage(#ID_PIC)  :  FreeImage(#ID_PIC)
  145.          EndIf
  146.  
  147.          If IsWindow(#W_Main) :  CloseWindow(#W_Main) :  EndIf
  148.  
  149.       EndIf
  150.  
  151.    EndWith
  152.  
  153. EndProcedure
  154.  
  155. CompilerIf  #IsXUP   ; Uncompress file
  156.    XIncludeFile   "Include\i_XUP.pbi"
  157. CompilerEndIf
  158.  
  159. XIncludeFile   "Include\i_IMG.pbi"  ; Picture
  160. XIncludeFile   "Include\i_MUS.pbi"  ; Modules
  161. XIncludeFile   "Include\i_TXT.pbi"  ; Text
  162. XIncludeFile   "Include\i_HTM.pbi"  ; HTML
  163.  
  164. ProcedureC  PureAmp_Config(hwndParent)
  165.    MA_MsgBox(hwndParent, "No configuration.", "Configuration")
  166. EndProcedure
  167. ProcedureC  PureAmp_About(hwndParent)
  168.  
  169.    Protected   t$ =  PeekS(*In_Module\description) + #LF$   +  #LF$  +
  170.                      FormatDate("Coded by Peace^TST, build: %yyyy.%mm.%dd %hh:%ii:%ss", #PB_Compiler_Date)  + #LF$ +
  171.                      "https://testaware.wordpress.com/"  +  #LF$ +   #LF$  +
  172.                      "Using PureBasic "   +  StrF(#PB_Compiler_Version*0.01, 2)  +  " (x86)" +  #LF$  +
  173.                      "http://www.purebasic.com/"   +  #LF$ +   #LF$  +
  174.                      "This plugin is not tested in real Winamp,"  +  #LF$  +
  175.                      "created for the AmpMaster Library only!"
  176.  
  177.    MA_MsgBox(hwndParent, t$, "About")
  178.  
  179. EndProcedure
  180.  
  181. ProcedureC  PureAmp_Init()
  182.  
  183.    UseOGGSoundDecoder()       ; 153Kb
  184.    UseFLACSoundDecoder()      ; 37Kb
  185.  
  186.    UsePNGImageDecoder()       ; 126Kb
  187.    ;UseJPEGImageDecoder()     ; 111Kb
  188.    UseJPEG2000ImageDecoder()  ; 86Kb
  189.    UseTGAImageDecoder()       ; 1Kb
  190.  
  191.    InitSound()
  192.    InitMovie()
  193.  
  194.    ;ClearStructure(@PA, PureAmp)
  195.  
  196. EndProcedure
  197. ProcedureC  PureAmp_Quit()
  198.  
  199.    ; Bug in StopMusic/Sound() and Free?
  200.    With  PA
  201.  
  202.       *In_Module\is_seekable  =  #True ; *** Default: seekable
  203.  
  204.       If \IsPlay
  205.          If       \IsMCI            :  mciSendString_("CLOSE " + Str(#ID_MCI), 0, 0, 0)
  206.          ElseIf   IsMovie(#ID_AUD)  :  FreeMovie(#ID_AUD)
  207.          ElseIf   IsMovie(#ID_MOV)  :  FreeMovie(#ID_MOV)
  208.          ElseIf   IsSound(#ID_SND)  :  FreeSound(#ID_SND)
  209.          ElseIf   IsMusic(#ID_MOD)  :  FreeMusic(#ID_MOD)
  210.          ElseIf   IsImage(#ID_PIC)  :  FreeImage(#ID_PIC)
  211.          EndIf
  212.       EndIf
  213.  
  214.       If IsWindow(#W_Main) :  CloseWindow(#W_Main) :  EndIf
  215.  
  216.       ClearStructure(@PA, PureAmp)
  217.       ClearStructure(@PI, PureInfo)
  218.  
  219.    EndWith
  220.  
  221. EndProcedure
  222.  
  223. ProcedureC  PureAmp_GetFileInfo(*file, *title.Integer, *length_in_ms.Integer)
  224.  
  225.    If *title         :  *title\i          =  #Null             :  EndIf ; No title or @GetFilePart(PeekS(*File))
  226.    If *length_in_ms  :  *length_in_ms\i   =  #PA_DefaultLength :  EndIf ; Default = -1/300000ms
  227.  
  228. EndProcedure
  229. ProcedureC  PureAmp_InfoBox(*file, hwndParent)
  230.  
  231.    ; https://msdn.microsoft.com/en-us/library/vs/alm/dd798683(v=vs.85).aspx
  232.  
  233.    ClearStructure(@PI, PureInfo)
  234.  
  235.    With  PI
  236.  
  237.       Protected   t$, i
  238.  
  239.       If PA\IsMCI
  240.          \Decoder =  "MCI_SENDSTRING"
  241.          \Width   =  WindowWidth(#W_Main, #PB_Window_InnerCoordinate)   :  If \Width   <= #PA_WinW :  \Width   =  #Null :  EndIf
  242.          \Height  =  WindowHeight(#W_Main,#PB_Window_InnerCoordinate)   :  If \Height  <= #PA_WinH :  \Height  =  #Null :  EndIf
  243.          mciSendString_("STATUS " + Str(#ID_MCI) + " SPEED", @PA\Buffer, #MAX_PATH, 0) :  \Speed   =  StrToInt_(PA\Buffer)
  244.          mciSendString_("STATUS " + Str(#ID_MCI) + " LENGTH",@PA\Buffer, #MAX_PATH, 0) :  StrToInt64Ex_(PA\Buffer, #Null, @\Length)
  245.  
  246.       ElseIf   IsMovie(#ID_AUD)
  247.          \Decoder =  "PB_AUDIO/MOVIE"
  248.  
  249.       ElseIf   IsMovie(#ID_MOV)
  250.          \Decoder =  "PB_MOVIE"
  251.          \Frames  =  MovieLength(#ID_MOV)
  252.          \Fps     =  MovieInfo(#ID_MOV, 0)
  253.          \Width   =  MovieWidth(#ID_MOV)
  254.          \Height  =  MovieHeight(#ID_MOV)
  255.          \Length  =  PA\Length
  256.  
  257.       ElseIf   IsSound(#ID_SND)
  258.          \Decoder =  "PB_SOUND"
  259.          \Frames  =  SoundLength(#ID_SND, #PB_Sound_Frame)
  260.          \Herz    =  GetSoundFrequency(#ID_SND)
  261.          \Length  =  PA\Length
  262.  
  263.       ElseIf   IsImage(#ID_PIC)
  264.          \Decoder =  "PB_IMAGE"
  265.          Select   IMAGE_ENCODE
  266.             Case  #IMAGE_ENCODE_DDS :  \Encoder =  "DDS"
  267.             Case  #IMAGE_ENCODE_GDI :  \Encoder =  "GDI+"
  268.             Case  #IMAGE_ENCODE_GDP :  \Encoder =  "GDIplus"
  269.             Case  #IMAGE_ENCODE_IDX :  \Encoder =  "IDX"
  270.             Case  #IMAGE_ENCODE_IFF :  \Encoder =  "IFF"
  271.             Case  #IMAGE_ENCODE_PBI :  \Encoder =  "PB"
  272.          EndSelect
  273.          \Width   =  ImageWidth(#ID_PIC)
  274.          \Height  =  ImageHeight(#ID_PIC)
  275.          \Colors  =  IMG_CountColors(#ID_PIC)
  276.          If \Colors
  277.             For   i  =  1  To 32
  278.                If \Colors  <= (1<<i)
  279.                   \Depth   =  i  :  Break
  280.                EndIf
  281.             Next
  282.          Else
  283.             \Depth   =  ImageDepth(#ID_PIC, #PB_Image_OriginalDepth)
  284.          EndIf
  285.  
  286.       ElseIf   IsMusic(#ID_MOD)
  287.          \Decoder =  "PB_MUSIC"
  288.  
  289.       EndIf
  290.  
  291.       t$ =  PeekS(*file)   +  #LF$  +  #LF$
  292.  
  293.       If Len(\Decoder)
  294.  
  295.          t$ +  "Decoder:"  +  #TAB$ +  #TAB$ +  \Decoder +  #LF$
  296.  
  297.          t$ +  "Seekable:" +  #TAB$
  298.          If *In_Module\is_seekable
  299.             t$ +  "Yes"
  300.          Else
  301.             t$ +  "No"
  302.          EndIf
  303.          t$ +  #LF$  +  #LF$
  304.  
  305.          If \Encoder :  t$ +  "Decoded:"  +  #TAB$ +  \Encoder                +  #LF$  :  EndIf
  306.          If \Width   :  t$ +  "Width:"    +  #TAB$ +  #TAB$ +  Str(\Width)    +  #LF$  :  EndIf
  307.          If \Height  :  t$ +  "Height:"   +  #TAB$ +  #TAB$ +  Str(\Height)   +  #LF$  :  EndIf
  308.          If \Depth   :  t$ +  "Depth:"    +  #TAB$ +  #TAB$ +  Str(\Depth)    +  #LF$  :  EndIf
  309.          If \Colors  :  t$ +  "Colors:"   +  #TAB$ +  #TAB$ +  Str(\Colors)   +  #LF$  :  EndIf
  310.          If \Frames  :  t$ +  "Frames:"   +  #TAB$ +  #TAB$ +  Str(\Frames)   +  #LF$  :  EndIf
  311.          If \Fps     :  t$ +  "Fps:"      +  #TAB$ +  #TAB$ +  Str(\Fps)      +  #LF$  :  EndIf
  312.          If \Herz    :  t$ +  "Herz:"     +  #TAB$ +  #TAB$ +  Str(\Herz)     +  #LF$  :  EndIf
  313.          If \Speed   :  t$ +  "Speed:"    +  #TAB$ +  #TAB$ +  Str(\Speed)    +  #LF$  :  EndIf
  314.          If \Length  :  t$ +  "Length:"   +  #TAB$ +  #TAB$ +  Str(\Length)   +  "ms"  :  EndIf
  315.  
  316.       Else
  317.  
  318.          t$ +  "No info available."
  319.  
  320.       EndIf
  321.  
  322.       Trim(t$, #LF$) ;StrTrim_(t$, #LF$)
  323.  
  324.       MA_MsgBox(hwndParent, t$, "Fileinfo")
  325.  
  326.    EndWith
  327.  
  328.    ProcedureReturn   #Null
  329.  
  330. EndProcedure
  331.  
  332. ProcedureC  PureAmp_IsOurFile(*fn)
  333.    ProcedureReturn   #Null
  334. EndProcedure
  335.  
  336. ProcedureC  PureAmp_Play(*fn)
  337.  
  338.    ; return zero on success, -1 on file-not-found, some other value on other (stopping winamp) error
  339.  
  340.    PureAmp_Quit()
  341.  
  342.    If *fn   <= #Null :  ProcedureReturn   #True :  EndIf
  343.  
  344.    Protected   File$ =  PeekS(*fn)
  345.    Protected   ID$   =  ";"+GetExtensionPart(File$)+";"
  346.  
  347.    Protected   x, y, i
  348.  
  349.    With  PA
  350.  
  351.       OpenWindow(#W_Main, 16, 16, #PA_WinW, #PA_WinH, GetFilePart(File$), #PB_Window_Invisible|#PB_Window_NoActivate|#PB_Window_NoGadgets|#PB_Window_TitleBar|#PB_Window_SystemMenu)
  352.  
  353.       \IsPlay  =  #True ; *** Default: Play
  354.  
  355.       If StrStrI_(?l_MCI, ID$)   And   mciSendString_("OPEN " + #DQUOTE$ + File$ + #DQUOTE$ + " TYPE MPEGVIDEO ALIAS " + Str(#ID_MCI), 0, 0, 0) =  #S_OK
  356.  
  357.          ; *** PureMCI
  358.          \IsMCI   =  #True
  359.  
  360.          If StrStrI_(@ID$, "GIF")
  361.             \IsGIF   =  #True ; use default-time (remark for real gif-playtime)
  362.             *In_Module\is_seekable  =  #False   ; *** GIF is Not seekable
  363.             mciSendString_("PLAY " + Str(#ID_MCI) + " REPEAT", 0, 0, 0)
  364.          Else
  365.             mciSendString_("PLAY " + Str(#ID_MCI), 0, 0, 0)
  366.          EndIf
  367.  
  368.       ElseIf   StrStrI_(?l_SND, ID$)   And   LoadSound(#ID_SND, File$)
  369.  
  370.          ; *** PureSound
  371.          PlaySound(#ID_SND)
  372.  
  373.       ElseIf   StrStrI_(?l_AUD, ID$)   And   LoadMovie(#ID_AUD, File$)  And   PlayMovie(#ID_AUD, GetForegroundWindow_());WindowID(#W_Main))
  374.  
  375.          ; *** PureAudio (Movie)
  376.  
  377.       ElseIf   StrStrI_(?l_MOV, ID$)   And   LoadMovie(#ID_MOV, File$)  And   PlayMovie(#ID_MOV, WindowID(#W_Main))
  378.  
  379.          ; *** PureMovie
  380.          ResizeWindow(#W_Main,#PB_Ignore, #PB_Ignore, MovieWidth(#ID_MOV), MovieHeight(#ID_MOV))
  381.          ShowWindow_(WindowID(#W_Main), #SW_SHOWNORMAL)
  382.          UpdateWindow_(WindowID(#W_Main))
  383.          Sleep_(300)
  384.  
  385.       ElseIf   StrStrI_(?l_PIC, ID$)   And   IMG_LoadImage(File$) >  #Null
  386.  
  387.          ; *** PurePicture
  388.  
  389.       ElseIf   StrStrI_(?l_TXT, ID$)   And   TXT_LoadText(File$)  >  #Null
  390.  
  391.          ; *** PureText
  392.  
  393.       ElseIf   StrStrI_(?l_HTM, ID$)   And   HTM_LoadHTML(File$)  >  #Null
  394.  
  395.          ; *** PureHTML
  396.  
  397.       ElseIf   MUS_LoadMusic(File$)
  398.  
  399.          ; *** PureModule
  400.          *In_Module\is_seekable  =  #False   ; *** Not seekable
  401.  
  402.       ElseIf   mciSendString_("OPEN " + #DQUOTE$ + File$ + #DQUOTE$ + " ALIAS " + Str(#ID_MCI), 0, 0, 0) =  #S_OK
  403.  
  404.          ; *** PureMCI at least try again (unknown extension)
  405.          \IsMCI   =  #True
  406.          mciSendString_("PLAY " + Str(#ID_MCI), 0, 0, 0)
  407.  
  408.       Else
  409.  
  410.          \IsPlay  =  #False   ; *** Error!
  411.  
  412.       EndIf
  413.  
  414.       ; *******************************
  415.       ; Is file is playing or quit
  416.       ; *******************************
  417.       If \IsPlay
  418.          ProcedureReturn   #Null ; *** All OK!
  419.       Else
  420.          PureAmp_Quit()          ; *** Error!
  421.       EndIf
  422.  
  423.    EndWith
  424.  
  425.    ProcedureReturn   #True
  426.  
  427. EndProcedure
  428. ProcedureC  PureAmp_Pause()
  429.  
  430.    ; pause stream
  431.    With  PA
  432.  
  433.       If \IsPlay  And   \IsPause =  #False
  434.          If       \IsMCI            :  mciSendString_("PAUSE " + Str(#ID_MCI), 0, 0, 0)
  435.          ElseIf   IsMovie(#ID_AUD)  :  PauseMovie(#ID_AUD)
  436.          ElseIf   IsMovie(#ID_MOV)  :  PauseMovie(#ID_MOV)
  437.          ElseIf   IsSound(#ID_SND)  :  PauseSound(#ID_SND)
  438.          ElseIf   IsMusic(#ID_MOD)  :  StopMusic(#ID_MOD)   ; why not PauseMusic()?
  439.          EndIf
  440.       EndIf
  441.  
  442.       \IsPause =  #True
  443.  
  444.    EndWith
  445.  
  446. EndProcedure
  447. ProcedureC  PureAmp_UnPause()
  448.  
  449.    ; unpause stream
  450.    With  PA
  451.  
  452.       If \IsPlay  And   \IsPause
  453.          If       \IsMCI            :  mciSendString_("RESUME " + Str(#ID_MCI), 0, 0, 0)
  454.          ElseIf   IsMovie(#ID_AUD)  :  ResumeMovie(#ID_AUD)
  455.          ElseIf   IsMovie(#ID_MOV)  :  ResumeMovie(#ID_MOV)
  456.          ElseIf   IsSound(#ID_SND)  :  ResumeSound(#ID_SND)
  457.          ElseIf   IsMusic(#ID_MOD)  :  PlayMusic(#ID_MOD)   ; why not ResumeMusic()?
  458.          EndIf
  459.       EndIf
  460.  
  461.       \IsPause =  #False
  462.  
  463.    EndWith
  464.  
  465. EndProcedure
  466. ProcedureC  PureAmp_IsPaused()
  467.  
  468.    ; ispaused? return 1 if paused, 0 if not
  469.    ProcedureReturn   PA\IsPause
  470.  
  471. EndProcedure
  472. ProcedureC  PureAmp_Stop()
  473.  
  474.    ; stop (unload) stream
  475.    PureAmp_Quit()
  476.  
  477. EndProcedure
  478.  
  479. ProcedureC  PureAmp_GetLength()
  480.  
  481.    ; get length in ms
  482.    With  PA
  483.  
  484.       If \IsPlay
  485.  
  486.          \Length  =  #PA_DefaultLength
  487.  
  488.          If \IsMCI
  489.             If \IsGIF   =  #False   ; GIF? -> set default length (-1)
  490.                mciSendString_("STATUS " + Str(#ID_MCI) + " LENGTH", @\Buffer, #MAX_PATH, 0)
  491.                StrToInt64Ex_(\Buffer, #Null, @\Length)
  492.             EndIf
  493.          ElseIf   IsMovie(#ID_MOV)  :  \Length  =  (MovieLength(#ID_MOV) / MovieInfo(#ID_MOV, 0)) * 1000
  494.          ElseIf   IsSound(#ID_SND)  :  \Length  =  SoundLength(#ID_SND, #PB_Sound_Millisecond)
  495.          EndIf
  496.       EndIf
  497.  
  498.       ProcedureReturn   \Length
  499.  
  500.    EndWith
  501.  
  502. EndProcedure
  503. ProcedureC  PureAmp_GetOutputTime()
  504.  
  505.    ; get position in ms
  506.    With  PA
  507.  
  508.       If \IsPlay
  509.          If \IsMCI
  510.             mciSendString_("STATUS " + Str(#ID_MCI) + " POSITION", @\Buffer, #MAX_PATH, 0)
  511.             StrToInt64Ex_(\Buffer, #Null, @\Position)
  512.          ElseIf   IsMovie(#ID_MOV)  :  \Position   =  (MovieStatus(#ID_MOV) * 1000) / MovieInfo(#ID_MOV, 0)
  513.          ElseIf   IsSound(#ID_SND)  :  \Position   =  GetSoundPosition(#ID_SND, #PB_Sound_Millisecond)
  514.          EndIf
  515.       EndIf
  516.  
  517.       ProcedureReturn   \Position
  518.  
  519.    EndWith
  520.  
  521. EndProcedure
  522. ProcedureC  PureAmp_SetOutputTime(time_in_ms)
  523.  
  524.    ; set position in ms
  525.    With  PA
  526.       If \IsPlay
  527.          If \IsMCI
  528.             mciSendString_("SEEK " + Str(#ID_MCI) + " TO " + Str(time_in_ms), 0, 0, 0)
  529.             mciSendString_("PLAY " + Str(#ID_MCI), 0, 0, 0)
  530.          ElseIf   IsMovie(#ID_MOV)  :  MovieSeek(#ID_MOV, (time_in_ms * 0.001) * MovieInfo(#ID_MOV, 0))
  531.          ElseIf   IsSound(#ID_SND)  :  SetSoundPosition(#ID_SND, time_in_ms, #PB_Sound_Millisecond)
  532.          EndIf
  533.       EndIf
  534.    EndWith
  535.  
  536. EndProcedure
  537.  
  538. ProcedureC  PureAmp_SetVolume(volume)
  539.  
  540.    ; volume 0-255 -> 0-100%
  541.    With  PA
  542.  
  543.       Protected   pan
  544.  
  545.       volume   =  (100.0 / 255.0) * volume
  546.  
  547.       If \IsPlay  And   \Volume  <> volume
  548.  
  549.          \Volume  =  volume
  550.  
  551.          If \IsMCI
  552.             pan   =  Abs(\Volume * 0.1 * \Pan)
  553.             If \Pan  <  #Null ; left
  554.                mciSendString_("SETAUDIO " + Str(#ID_MCI) + " RIGHT VOLUME TO "+ Str(\Volume * 10 - pan), 0, 0, 0)
  555.                mciSendString_("SETAUDIO " + Str(#ID_MCI) + " LEFT VOLUME TO " + Str(\Volume * 10), 0, 0, 0)
  556.             ElseIf   \Pan  >  #Null ; right
  557.                mciSendString_("SETAUDIO " + Str(#ID_MCI) + " RIGHT VOLUME TO "+ Str(\Volume * 10), 0, 0, 0)
  558.                mciSendString_("SETAUDIO " + Str(#ID_MCI) + " LEFT VOLUME TO " + Str(\Volume * 10 - pan), 0, 0, 0)
  559.             Else
  560.                mciSendString_("SETAUDIO " + Str(#ID_MCI) + " VOLUME TO " + Str(\Volume * 10), 0, 0, 0)
  561.             EndIf
  562.          ElseIf   IsMovie(#ID_AUD)  :  MovieAudio(#ID_AUD,  \Volume, \Pan)
  563.          ElseIf   IsMovie(#ID_MOV)  :  MovieAudio(#ID_MOV,  \Volume, \Pan)
  564.          ElseIf   IsMusic(#ID_MOD)  :  MusicVolume(#ID_MOD, \Volume)
  565.          ElseIf   IsSound(#ID_SND)  :  SoundVolume(#ID_SND, \Volume)
  566.          EndIf
  567.  
  568.       EndIf
  569.  
  570.    EndWith
  571.  
  572. EndProcedure
  573. ProcedureC  PureAmp_SetPan(pan)
  574.  
  575.    ; set pan ± 127 -> ± 100%
  576.    With  PA
  577.  
  578.       pan   =  (100.0 / 127.0) * pan
  579.  
  580.       If \IsPlay  And   \Pan  <> pan
  581.  
  582.          \Pan  =  pan
  583.  
  584.          If \IsMCI
  585.             pan   =  Abs(\Volume * 0.1 * \Pan)
  586.             If \Pan  <  #Null ; left
  587.                mciSendString_("SETAUDIO " + Str(#ID_MCI) + " RIGHT VOLUME TO "+ Str(\Volume * 10 - pan), 0, 0, 0)
  588.                mciSendString_("SETAUDIO " + Str(#ID_MCI) + " LEFT VOLUME TO " + Str(\Volume * 10), 0, 0, 0)
  589.             ElseIf   \Pan  >  #Null ; right
  590.                mciSendString_("SETAUDIO " + Str(#ID_MCI) + " RIGHT VOLUME TO "+ Str(\Volume * 10), 0, 0, 0)
  591.                mciSendString_("SETAUDIO " + Str(#ID_MCI) + " LEFT VOLUME TO " + Str(\Volume * 10 - pan), 0, 0, 0)
  592.             Else
  593.                mciSendString_("SETAUDIO " + Str(#ID_MCI) + " VOLUME TO " + Str(\Volume * 10), 0, 0, 0)
  594.             EndIf
  595.          ElseIf   IsMovie(#ID_AUD)  :  MovieAudio(#ID_AUD,  \Volume, \Pan)
  596.          ElseIf   IsMovie(#ID_MOV)  :  MovieAudio(#ID_MOV,  \Volume, \Pan)
  597.          ElseIf   IsSound(#ID_SND)  :  SoundPan(#ID_SND,    \Pan)
  598.          EndIf
  599.  
  600.       EndIf
  601.  
  602.    EndWith
  603.  
  604. EndProcedure
  605.  
  606. ProcedureCDLL  winampGetInModule2()
  607.  
  608.    *In_Module  =  ?In_PureAmp ; globalize
  609.  
  610.    ProcedureReturn   *In_Module
  611.  
  612. EndProcedure
  613.  
  614. DataSection
  615.  
  616.    In_PureAmp:
  617.    Data.i   #IN_VER
  618.    Data.i   ?l_Description
  619.    Data.i   #Null    ; winamp's main window (filled in by winamp)
  620.    Data.i   #Null    ; DLL instance handle (also filled in by winamp)
  621.    Data.i   ?l_FileExtensions
  622.    Data.i   #True    ; is this stream seekable? (#ID_SND)
  623.    Data.i   #Null    ; does this plug-in use the output plug-ins?
  624.    Data.i   @PureAmp_Config()
  625.    Data.i   @PureAmp_About()
  626.    Data.i   @PureAmp_Init()
  627.    Data.i   @PureAmp_Quit()
  628.    Data.i   @PureAmp_GetFileInfo()
  629.    Data.i   @PureAmp_InfoBox()
  630.    Data.i   @PureAmp_IsOurFile()
  631.    Data.i   @PureAmp_Play()
  632.    Data.i   @PureAmp_Pause()
  633.    Data.i   @PureAmp_UnPause()
  634.    Data.i   @PureAmp_IsPaused()
  635.    Data.i   @PureAmp_Stop()
  636.    Data.i   @PureAmp_GetLength()
  637.    Data.i   @PureAmp_GetOutputTime()
  638.    Data.i   @PureAmp_SetOutputTime()
  639.    Data.i   @PureAmp_SetVolume()
  640.    Data.i   @PureAmp_SetPan()
  641.    Data.i   #Null,#Null,#Null,#Null,#Null,#Null,#Null,#Null,#Null,#Null,#Null,#Null,#Null,#Null
  642.  
  643.    l_Description:
  644.    Data.s   "PureAmp Media Input Plugin v1.06 (x86)"
  645.    Data.i   #Null
  646.  
  647.    l_FileExtensions:
  648.    ; #ID_MOD
  649.    Data.s   "669",   "669 Composer/Unis669 (*.669)",
  650.             "ABC",   "ABC Sample Module (*.abc)",
  651.             "AMF",   "Asylum Music Format (*.amf)",
  652.             "AMS",   "Extreme Tracker/Velvet Studio (*.ams)",
  653.             "DBM",   "DigiBooster Pro (*.dbm)",
  654.             "DMF",   "Delusion Digital Music Format (*.dmf)",
  655.             "DSK",   "DSIK Internal Format (*.dsk)",
  656.             "FAR",   "Farandole Composer (*.far)",
  657.             "FT",    "Fast Tracker 8CHN (*.ft)",
  658.             "IT",    "Impulse Tracker (*.it)",
  659.             "J2B",   "J2B Module (*.j2b)",
  660.             "MDL",   "DigiTrakker 1.0-3.0 (*.mdl)",
  661.             "MED",   "OctaMed Module (*.med)",
  662.             "MOD",   "Sound/Noise/ProTracker variants (*.mod)",
  663.             "MPTM",  "OpenMT 1.24-1.25 (*.mptm)",
  664.             "MT2",   "MadTracker 2.0 (*.mt2)",
  665.             "NST",   "NoiseTracker Module (*.nst)",
  666.             "PAT",   "PAT Sample Module (*.pat)",
  667.             "PSM",   "Epic MegaGames MASI (*.psm)",
  668.             "PTM",   "PolyTracker (*ptm)",
  669.             "S3M",   "ScreamTracker 3.0 (*.s3m)",
  670.             "STM",   "ScreamTracker 2.0 (*.stm)",
  671.             "ULT",   "UltraTracker (*.ult)",
  672.             "UMX",   "Epic Games Unreal Format (*.umx)",
  673.             "XM",    "FastTracker II (*.xm)",
  674.             "PP",    "Amiga PowerPacker Format (*.pp)",
  675.             "XPK",   "Amiga eXtended PacKer Format (*.xpk)",
  676.             "IM",    "Amiga FileImploder Format (*.im)",
  677.             "NPK",   "NoisePlug Packed Format (*.npk)"
  678.    ; #ID_AUD
  679.    Data.s   "MP3",   "MPEG Layer-1/2/3 Audio File (*.mp3)",
  680.             "WMA",   "Windows Media Audio (*.wma)"
  681.    ; #ID_SND
  682.    Data.s   "FLAC",  "Free Lossless Audio Codec (*.flac)",
  683.             "OGG",   "Ogg Audio File (*.ogg)",
  684.             "WAV",   "Windows Waveform (*.wav)"
  685.    ; #ID_MOV
  686.    Data.s   "ASF",   "Advanced Systems Format (*.asf)",
  687.             "AVI",   "Audio Video Interleave (*.avi)",
  688.             "MP4",   "MPEG Layer-4 Video File (*.mp4)",
  689.             "WMV",   "Windows Media Video (*.wmv)"
  690.    ; #ID_MCI
  691.    Data.s   "3GP",   "3 Generation Personal Digital Assistant (*.3gp)",
  692.             "AC3",   "Audio Codec 3 (*.ac3)",
  693.             "ADPCM", "Adaptive Differential Pulse Code Modulation (*.adpcm)",
  694.             "GIF",   "Graphics Interchange Format (*.gif)",
  695.             "MID",   "Musical Instrument Digital Interface (*.mid)",
  696.             "MKV",   "Matroska Video Container (*.mkv)"
  697.    ; #ID_PIC
  698.    Data.s   "BMP",   "Windows Bitmap (*.bmp)",
  699.             "CUR",   "Windows Cursor (*.cur)",
  700.             "ICO",   "Windows Icon (*.ico)",
  701.             "IFF",   "Interchange File Format (*.iff)",
  702.             "DDS",   "Direct Draw Surface (*.dds)",
  703.             "EMF",   "Windows Enhanced Metafile (*.emf)",
  704.             "JP2",   "JPEG2000 Format (*.jp2)",
  705.             "JPG",   "Joint Photographic Experts Group (*.jpg)",
  706.             "PNG",   "Portable Network Graphics (*.png)",
  707.             "TGA",   "Truevision Targa (*.tga)",
  708.             "TIF",   "Tagged Image File (*.tif)",
  709.             "WMF",   "Windows Meta File (*.wmf)"
  710.    ; #ID_TXT
  711.    Data.s   "RTF",   "Rich Text Format (*.rtf)",
  712.             "TXT",   "Text File (*.txt)"
  713.    ; #ID_HTM
  714.    Data.s   "HTML",  "Hypertext Markup Language (*.html)"
  715.  
  716.    Data.i   #Null, #Null
  717.  
  718.    ; Compare extensions
  719.    l_MCI:   :  Data.s   ";3G2;3GP;3GP2;3GPP" +
  720.                         ";4XM"   +
  721.                         ";AA;AAC;AC3;ACM;ACT;ADF;ADP;ADPCM;ADS;ADX;AEA;AFC;AIFF;AIX;ALAC;ALAW;AMR;APC;APE;APTX;AST;AU;AVR;AVS;AVS2" +
  722.                         ";BFI;BFSTM;BINK;BIT;BDMV;BMV;BOA;BRSTM"  +
  723.                         ";C93;CAF;CDG;CDXL;CINE"   +
  724.                         ";DAUD;DCSTR;DFA;DSF;DSICIN;DSS;DTS;DTSHD;DV;DVR-MS;DXA" +
  725.                         ";EA;EAC3;EPAF;EVO"  +
  726.                         ";F4V;FITS;FLIC;FLV;FRM;FSB"  +
  727.                         ";G726;G729;GIF;GDV;GXF"   +
  728.                         ";HDMOV;HLS;HNM"  +
  729.                         ";IDF;ILBC;IV8;IVF;IVR" +
  730.                         ";JV" +
  731.                         ";LOAS;LXF" +
  732.                         ";M2A;M2T;M2TS;M4A;M4V;MGSTS;MJPEG;MID;MIDI;MK3D;MKA;MKS;MKV;MLP;MLV;MM;MMF;MOV;MP1;MP2;MP2A;MP3;MP3A;MP4;MP4A;MP4V;MPA;MPA1;MPA2;MPA3;MPA4;MPC;MPC8;MPEG;MPEGA;MPEGTS;MPJPEG;MJPG;MPG;MPV4;MSF;MTAF;MTS;MTV;MUSX;MV;MVI;MXF;MXG"   +
  733.                         ";NC;NSP;NSV;NUT;NUV"   +
  734.                         ";OGA;OGG;OGM;OGV;OMA"  +
  735.                         ";PAF;PJS;PMP;PVA;PVF"  +
  736.                         ";QCP;QT"   +
  737.                         ";R3D;RA;RM;RMVB;ROQ;RPL;RSD;RSO;RTP;RTSP;S337M;SAP;SBC;SBG;SCC;SDP;SDR2;SDS;SDX;SHN;SIFF;SLN;SMJPEG;SMJPG;SMK;SMUSH;SOL;SOX;SUP;SVAG" +
  738.                         ";TAK;THP;TMV;TRUEHD;TTA;TP;TS;TXD;TY" +
  739.                         ";V210;V210X;VAG;VIVO;VMD;VOC;VPK;VQF" +
  740.                         ";W64;WAV;WAVE;WC3M;WEBM;WMA;WMV;WSAUD;WSD;WSVQA;WTV;WV;WVE"   +
  741.                         ";XA;XBIN;XMV;XVAG;XWMA"   +
  742.                         ";Y4M;YOP"  +
  743.                         ";"
  744.  
  745.    l_AUD:   :  Data.s   ";MP1;MP2;MP3;MPA"   +
  746.                         ";WAV;WAVE;WMA"   +
  747.                         ";"
  748.  
  749.    l_MOV:   :  Data.s   ";ASF;AVI"  +
  750.                         ";DIVX"  +
  751.                         ";MP4;MPEG;MPG"   +
  752.                         ";WMV"   +
  753.                         ";XVID"  +
  754.                         ";"
  755.  
  756.    l_PIC:   :  Data.s   ";ANBR;ANIM;ANM;APNG"   +
  757.                         ";BMP;BRU;BRUSH;BSH" +
  758.                         ";CUR"   +
  759.                         ";DDS;DIB"  +
  760.                         ";EMF;EMZ"  +
  761.                         ";GIF"   +
  762.                         ";HAM;HAM8" +
  763.                         ";ICO;IFF;ILBM;IM"   +
  764.                         ";J2K;JFIF;JNG;JP2;JPE;JPEG;JPF;JPG;JPG2;JPM;JPX"  +
  765.                         ";LACE;LBM;LORES" +
  766.                         ";MNG"   +
  767.                         ";PBM;PIC;PNG;PP" +
  768.                         ";RLE"   +
  769.                         ";TGA;TIF;TIFF"   +
  770.                         ";WMF;WMZ"  +
  771.                         ";XPK"   +
  772.                         ";"
  773.  
  774.    l_SND:   :  Data.s   ";FLA;FLAC" +
  775.                         ";OGA;OGG"  +
  776.                         ";WAV;WAVE" +
  777.                         ";"
  778.  
  779.    l_TXT:   :  Data.s   ";AM;ASC;ASM;ASP;ASS"   +
  780.                         ";BAS;BAT"  +
  781.                         ";C;CFG;CPP;CSS"  +
  782.                         ";DIZ;DOC;DOK" +
  783.                         ";GUIDE" +
  784.                         ";H;HVS" +
  785.                         ";I;IN;INC;INI"   +
  786.                         ";MD" +
  787.                         ";NFO"   +
  788.                         ";PB;PBF;PBI;PHP;PREF;PREFS"  +
  789.                         ";README;RTF"  +
  790.                         ";S;SRT;SSA"   +
  791.                         ";TEXI;TXT" +
  792.                         ";XML"   +
  793.                         ";"
  794.  
  795.    l_HTM:   :  Data.s   ";HTM;HTML" +
  796.                         ";"
  797.  
  798. EndDataSection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement