Advertisement
Testaware

in_PureAmp.dll v1.03 (x86)

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