1. Уважаемые гости и пользователи форума.
    Администрация настоятельно рекомендует не регистрировать несколько аккаунтов для одного пользователя. При выявлении наличия мультиаккаунтов будут заблокированы все учетные записи данного пользователя.
    Аккаунты, зарегистрированные на временную почту будут также заблокированы.

[Module Bass]Не могу отрегулировать уровень звука.

Тема в разделе "Досуг", создана пользователем Rodney Hawk, 14 янв 2017.

  1. Новичок

    Регистрация:
    11 янв 2017
    Сообщения:
    12
    Симпатии:
    0
    При открытие инсталлера, музыка орет аж кровь из ушей течет. Как исправить?
    Пытался добавить это ↓ в скрипт и в модуль , ругается скрипт.
    Код (Inno):

    float BASS_GetVolume();
    BOOL BASS_SetVolume(
       float volume
    );
     
    Собстна код модуля:
    Код (Inno):

    [code]
    type
      HSTREAM = DWORD;
      TBASSWndProc = function (h:hWnd;Msg,wParam,lParam:Longint):Longint;
      TBASSTmrProc = procedure(HandleW, msg, idEvent, TimeSys: LongWord);
      TBASSTrackBar = record
        BarImg: Longint;
        BarDote: HWND;
        MinLeft: Integer;
        MaxLeft: Integer;
        BarWidth: Integer;
        OldProc: Longint;
        MouseDown: Boolean;
        CursorPos: Tpoint;
      end;
     
    const
      BASS_ACTIVE_STOPPED = 0;
      BASS_ACTIVE_PLAYING = 1;
      BASS_ACTIVE_STALLED = 2;
      BASS_ACTIVE_PAUSED  = 3;
     
    var
      BASS_Volume: Single; BASS_Mp3Handle: HSTREAM;
      BASS_OnOffBtn: HWND;
      BASS_VolBtnMax, BASS_VolBtnMin: HWND;
      BASS_TrackBar: TBASSTrackBar;
      Songs: TStringList; SongTimer: Longword;
      CurSong: Integer;
     
    function _BASS_SetWindowLong(hWnd: HWND; nIndex: Integer; dwNewLong: Longint): Longint; external 'SetWindowLongA@user32.dll stdcall delayload';
    function _BASS_CallWindowProc(lpPrevWndFunc: Longint; hWnd: HWND; Msg: UINT; wParam, lParam: Longint): Longint; external 'CallWindowProcA@user32.dll stdcall delayload';
    function _BASS_WrapWndProc(P: TBASSWndProc; ParamCount: Integer):LongWord; external 'wrapcallbackaddr@{tmp}\callbackctrl.dll stdcall delayload';

    function _BASS_WrapTimerProc(callback: TBASSTmrProc; paramcount: integer):longword; external 'wrapcallbackaddr@{tmp}\callbackctrl.dll stdcall delayload';
    function _BASS_SetTimer(hWnd: LongWord; nIDEvent, uElapse: LongWord; lpTimerFunc: LongWord): LongWord; external 'SetTimer@user32.dll stdcall delayload';
    function _BASS_KillTimer(hWnd: LongWord; nIDEvent: LongWord): LongWord; external 'KillTimer@user32.dll stdcall delayload';

    function _BASS_ScreenToClient(hWnd: HWND; var lpPoint: TPoint): BOOL; external 'ScreenToClient@user32.dll stdcall delayload';
    function _BASS_GetCursorPos(var lpPoint: TPoint): BOOL; external 'GetCursorPos@user32.dll stdcall delayload';
    function _BASS_GetAncestor(hwnd: HWND; gaFlags: UINT): HWND; external 'GetAncestor@user32.dll stdcall delayload';
    function _BASS_Init(device: LongInt; freq, flags: DWORD; win: hwnd; CLSID: Integer): Boolean; external 'BASS_Init@{tmp}\BASS.dll stdcall delayload';
    function _BASS_StreamCreateFile(mem: BOOL; f: PAnsiChar; offset1, offset2, length1, length2: DWORD; flags: DWORD): HSTREAM; external 'BASS_StreamCreateFile@{tmp}\BASS.dll stdcall delayload';
    function _BASS_StreamFree(handle: HSTREAM): BOOL; external 'BASS_StreamFree@{tmp}\BASS.dll stdcall delayload';
    function _BASS_ChannelPlay(handle: DWORD; restart: BOOL): Boolean; external 'BASS_ChannelPlay@{tmp}\BASS.dll stdcall delayload';
    function _BASS_ChannelIsActive(handle: DWORD): DWORD; external 'BASS_ChannelIsActive@{tmp}\BASS.dll stdcall delayload';
    function _BASS_ChannelPause(handle: DWORD): Boolean; external 'BASS_ChannelPause@{tmp}\BASS.dll stdcall delayload';
    function _BASS_ChannelSetAttribute(handle: DWORD; Flags: DWORD; Value: Single): Boolean; external 'BASS_ChannelSetAttribute@{tmp}\BASS.dll stdcall delayload';
    function _BASS_Stop(): Boolean; external 'BASS_Stop@{tmp}\BASS.dll stdcall delayload';
    function _BASS_Free(): Boolean; external 'BASS_Free@{tmp}\BASS.dll stdcall delayload';
    function _BASS_Start(): Boolean; external 'BASS_Start@{tmp}\BASS.dll stdcall delayload';
    function _BASS_Pause(): Boolean; external 'BASS_Pause@{tmp}\BASS.dll stdcall delayload';

    procedure BASSTimerProc(HandleW, msg, idEvent, TimeSys: LongWord);
    begin
      if (_BASS_ChannelIsActive(BASS_Mp3Handle) = BASS_ACTIVE_STOPPED)and(Songs.Count>1) then begin
        CurSong:= CurSong+1;
        if CurSong>=Songs.Count then CurSong:=0;
        _BASS_StreamFree(BASS_Mp3Handle);
        BASS_Mp3Handle:= _BASS_StreamCreateFile(FALSE, PAnsiChar(Songs.Strings[CurSong]), 0, 0, 0, 0, 0);
        _BASS_ChannelPlay(BASS_Mp3Handle, False);
      end;
    end;

    procedure BASS_Init(Mp3Name: String);
    var
      FSR: TFindRec; Flags: DWORD;
    begin
      if not FileExists(ExpandConstant('{tmp}\Bass.dll')) then ExtractTemporaryFile('Bass.dll');
      if not FileExists(ExpandConstant('{tmp}\callbackctrl.dll')) then ExtractTemporaryFile('callbackctrl.dll');
      Songs:= TStringList.Create;
      Songs.Clear;
      if FindFirst(Mp3name, FSR) then try
        repeat
          if FSR.Attributes and FILE_ATTRIBUTE_DIRECTORY = 0 then
            Songs.Add(AddBackslash(ExtractFilePath(Mp3Name))+FSR.Name);
        until not FindNext(FSR);
      finally
        FindClose(FSR);
      end;
      CurSong:= 0;
      _BASS_Init(-1, 44100, 0, 0, 0)
      _BASS_Start();
      if Songs.Count>1 then Flags:= 0 else Flags:= 4;
      BASS_Mp3Handle:= _BASS_StreamCreateFile(FALSE, PAnsiChar(Songs.Strings[CurSong]), 0, 0, 0, 0, Flags);
      _BASS_ChannelPlay(BASS_Mp3Handle, False);
      if Songs.Count>1 then
        SongTimer:= _BASS_SetTimer(0, 0, 100, _BASS_WrapTimerProc(@BASSTimerProc, 4));
      BASS_Volume:= 1;
      _BASS_ChannelSetAttribute(BASS_Mp3Handle, 2, BASS_Volume);
      BASS_TrackBar.MouseDown:= False;
    end;

    procedure BASS_DeInit();
    begin
      _BASS_Stop;
      _BASS_Free;
      if Songs.Count>1 then
        _BASS_KillTimer(0, SongTimer);
      Songs.Free;
    end;

    procedure BASS_ChangePos(Pos: Single);
    begin
      BASS_Volume:= Pos;
      if BASS_Volume=0 then
        _BASS_ChannelPause(BASS_Mp3Handle)
      else begin
        if (_BASS_ChannelIsActive(BASS_Mp3Handle)=BASS_ACTIVE_PAUSED) then _BASS_ChannelPlay(BASS_Mp3Handle, False);
        _BASS_ChannelSetAttribute(BASS_Mp3Handle, 2, BASS_Volume);
      end;
    end;

    procedure BASS_VolumeMaxClick(Handle: HWND);
    var nLeft, bLeft, bTop, bWidth, bHeight: Integer;
    begin
      BASS_Volume:= BASS_Volume+0.05;
      if BASS_Volume > 1 then BASS_Volume:= 1;
      nLeft:= BASS_TrackBar.MinLeft + round(BASS_TrackBar.BarWidth*BASS_Volume);
      if (nLeft<BASS_TrackBar.MinLeft) then nLeft:= BASS_TrackBar.MinLeft;
      if (nLeft>BASS_TrackBar.MaxLeft) then nleft:= BASS_TrackBar.MaxLeft;
      BtnGetPosition(BASS_TrackBar.BarDote, bLeft, bTop, bWidth, bHeight);
      BtnSetPosition(BASS_TrackBar.BarDote, nLeft, bTop, bWidth, bHeight)
      BASS_ChangePos(BASS_Volume);
    end;

    procedure BASS_VolumeMinClick(Handle: HWND);
    var nLeft, bLeft, bTop, bWidth, bHeight: Integer;
    begin
      BASS_Volume:= BASS_Volume-0.05;
      if BASS_Volume < 0 then BASS_Volume:= 0;
      nLeft:= BASS_TrackBar.MinLeft + round(BASS_TrackBar.BarWidth*BASS_Volume);
      if (nLeft<BASS_TrackBar.MinLeft) then nLeft:= BASS_TrackBar.MinLeft;
      if (nLeft>BASS_TrackBar.MaxLeft) then nleft:= BASS_TrackBar.MaxLeft;
      BtnGetPosition(BASS_TrackBar.BarDote, bLeft, bTop, bWidth, bHeight);
      BtnSetPosition(BASS_TrackBar.BarDote, nLeft, bTop, bWidth, bHeight);
      BASS_ChangePos(BASS_Volume);
    end;

    function BASS_TBGetPosition(): Single;
    var
      Left,Top,Width,Height:integer;
    begin
      BtnGetPosition(BASS_TrackBar.BarDote,Left,Top,Width,Height);
      Result:= (Left-BASS_TrackBar.MinLeft)*100/BASS_TrackBar.BarWidth/100;
    end;

    function GetCurPoint(Handle: HWND): TPoint;
    begin
      _BASS_GetCursorPos(Result);
      _BASS_ScreenToClient(Handle, Result);
    end;

    function BASSTBProc(h:hWnd;Msg,wParam,lParam:Longint):Longint;
    var Left,Top,Width,Height:integer; p: TPoint; Parent: HWND;
    begin
      if Msg=$2 then _BASS_SetWindowLong(h, -4, BASS_TrackBar.OldProc);
      Result:= _BASS_CallWindowProc(BASS_TrackBar.OldProc, h, Msg, wParam, lParam);
      case Msg of
        $47 : BASS_ChangePos(BASS_TBGetPosition());
        $200: if BASS_TrackBar.MouseDown then begin
          Parent:= _BASS_GetAncestor(h,1);
          p:= GetCurPoint(Parent);
          BtnGetPosition(h,Left,Top,Width,Height);
          Left:=p.X-BASS_TrackBar.CursorPos.X;
          if Left<BASS_TrackBar.MinLeft then Left:=BASS_TrackBar.MinLeft;
          if Left>BASS_TrackBar.MaxLeft then Left:=BASS_TrackBar.MaxLeft;
          BtnSetPosition(h,Left,Top,Width,Height);
          ImgSetVisibility(BASS_TrackBar.BarImg,not ImgGetVisibility(BASS_TrackBar.BarImg));
          ImgSetVisibility(BASS_TrackBar.BarImg,not ImgGetVisibility(BASS_TrackBar.BarImg));
          ImgApplyChanges(Parent);                                      
        end;
      end;
    end;

    procedure BASSTBMouseDown(h:HWND);
    begin
      BASS_TrackBar.CursorPos:= GetCurPoint(h);
      BASS_TrackBar.MouseDown:= True;
    end;

    procedure BASSTBMouseUp(h:HWND);
    begin
      BASS_TrackBar.MouseDown:= False;
    end;

    procedure BASS_CreateMediaPlayer(MaxBut, MinBut, VolPB, VolDote: String; ALeft, ATop: Integer);
    begin
      BASS_TrackBar.MinLeft:= ALeft+ScaleX(17);
      BASS_TrackBar.MaxLeft:= ALeft+ScaleX(95);
      BASS_TrackBar.BarWidth:= ScaleX(78);
     
      BASS_VolBtnMax:= BtnCreate(WizardForm.Handle, ScaleX(ALeft+110), ScaleY(ATop), ScaleX(22), ScaleY(19), MaxBut, 2, False)
      BtnSetEvent(BASS_VolBtnMax, 1, WrapBtnCallback(@BASS_VolumeMaxClick, 1))

      BASS_TrackBar.BarImg:= ImgLoad(WizardForm.Handle, VolPB, ScaleX(ALeft+17), ScaleY(ATop+7), ScaleX(84), ScaleY(6), True, False)
      BASS_TrackBar.BarDote:= BtnCreate(WizardForm.Handle, ScaleX(ALeft+95), ScaleY(ATop+4), ScaleX(11), ScaleY(11), VolDote, 1, False)
      BtnSetEvent(BASS_TrackBar.BarDote, 5, WrapBtnCallback(@BASSTBMouseDown,1));
      BtnSetEvent(BASS_TrackBar.BarDote, 6, WrapBtnCallback(@BASSTBMouseUp,1));
     
      BASS_VolBtnMin:= BtnCreate(WizardForm.Handle, ScaleX(ALeft), ScaleY(ATop+2), ScaleX(13), ScaleY(17), MinBut, 2, False)
      BtnSetEvent(BASS_VolBtnMin, 1, WrapBtnCallback(@BASS_VolumeMinClick, 1));
     
      BASS_TrackBar.OldProc:= _BASS_SetWindowLong(BASS_TrackBar.BarDote, -4, _BASS_WrapWndProc(@BASSTBProc,4));
     
      ImgApplyChanges(WizardForm.Handle)
    end;

    procedure BASS_OnOffClick(Handle: HWND);
    begin
      if (_BASS_ChannelIsActive(BASS_Mp3Handle) = 3) then _BASS_ChannelPlay(BASS_Mp3Handle, False) else
      _BASS_ChannelPause(BASS_Mp3Handle)
    end;

    procedure BASS_CreateOnOffButton(Image: String; Left, Top, Width, Height, ShadowWidth: Integer);
    begin
      BASS_OnOffBtn:= BtnCreate(WizardForm.Handle, ScaleX(Left), ScaleY(Top), ScaleX(Width), ScaleY(Height), Image, ShadowWidth, True)
      BtnSetEvent(BASS_OnOffBtn, 1, WrapBtnCallback(@BASS_OnOffClick, 1))
      BtnSetCursor(BASS_OnOffBtn,GetSysCursorHandle(32649));
    end;
     
    Код из скрипта:
    Код (Inno):

    #define Music

    #ifdef Music
      ExtractTemporaryFile('BASS.dll');
      ExtractTemporaryFile('MusicButton.png');
      ExtractTemporaryFile('Music.mp3');
      BASS_Init(ExpandConstant('{tmp}\Music.mp3'))
      BASS_Init(ExpandConstant('{tmp}\*.mp3'))     //Поиск по маске
      BASS_CreateOnOffButton(ExpandConstant('{tmp}\MusicButton.png'), 460, 390, 53, 44, 4)
    #endif

    #ifdef Music
    BASS_DeInit;
    #endif
     
    В коде модуля есть такие строчки:
    Код (Inno):

    BASS_Volume:= Pos;
      if BASS_Volume=0 then //как я понял 0 и 1 меняет режимы Min/Max

    procedure BASS_VolumeMinClick(Handle: HWND);
    var nLeft, bLeft, bTop, bWidth, bHeight: Integer;
    begin
      BASS_Volume:= BASS_Volume-0.05;          //меняя тут значение я нечего не добился
      if BASS_Volume < 0 then BASS_Volume:= 0;
     
    Последнее редактирование: 14 янв 2017

Поделиться этой страницей