Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit UnitPlay;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils,
- System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms,
- Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls, Vcl.ComCtrls, Bass, Inifiles,
- Vcl.Buttons,
- System.ImageList, Vcl.ImgList;
- type
- TDrawData = array [0 .. 512] of Single;
- TPlayerMode = (Stop, Play, Paused);
- TSoundCloud = class(TForm)
- IndicateGraph: TPaintBox;
- TimeFirstLabel: TLabel;
- TimeLastLabel: TLabel;
- SoundLabel: TLabel;
- BalanceLabel: TLabel;
- ScrollSongBar: TScrollBar;
- SongsList: TListBox;
- OpenDialog1: TOpenDialog;
- Timer1: TTimer;
- SoundBar: TTrackBar;
- BalanceBar: TTrackBar;
- SongNameLabel: TLabel;
- VolumeZeroButton: TBitBtn;
- PlayButton: TBitBtn;
- ImageList1: TImageList;
- PauseButton: TBitBtn;
- BackButton: TBitBtn;
- ForwardButton: TBitBtn;
- StopButton: TBitBtn;
- TrashCanButton: TBitBtn;
- FolderButton: TBitBtn;
- EqualizerButton: TBitBtn;
- MiniViewButton: TBitBtn;
- VolumeTenButton: TBitBtn;
- SettingsAndInfoButton: TBitBtn;
- procedure EqualizerButtonClick(Sender: TObject);
- procedure VolumeZeroButtonClick(Sender: TObject);
- procedure Player;
- procedure FormCreate(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure ScrollSongBarScroll(Sender: TObject; ScrollCode: TScrollCode;
- var ScrollPos: Integer);
- procedure Timer1Timer(Sender: TObject);
- procedure SongsListDblClick(Sender: TObject);
- procedure IndicateGraphPaint(Sender: TObject);
- procedure Draw(HWND: THandle; DrawData: TDrawData; X, Y: Integer);
- procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- procedure PlayButtonClick(Sender: TObject);
- procedure PauseButtonClick(Sender: TObject);
- procedure BackButtonClick(Sender: TObject);
- procedure ForwardButtonClick(Sender: TObject);
- procedure StopButtonClick(Sender: TObject);
- procedure TrashCanButtonClick(Sender: TObject);
- procedure FolderButtonClick(Sender: TObject);
- procedure MiniViewButtonClick(Sender: TObject);
- procedure ActivateMusicPlayer();
- procedure DeActivateMusicPlayer();
- procedure PlayOrNot();
- procedure VolumeTenButtonClick(Sender: TObject);
- procedure SettingsAndInfoButtonClick(Sender: TObject);
- procedure SondListDrawItem(Control: TWinControl; Index: Integer;
- Rect: TRect; State: TOwnerDrawState);
- procedure CreateCfg;
- procedure CloseCfg;
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- SoundCloud: TSoundCloud;
- I: Longint; // номер песни
- Filename: string; // имя файла
- Channel: Integer; // сюда сохраняем дескриптор
- Mode: TPlayerMode; // режим
- P: BASS_DX8_PARAMEQ;
- Fx: array [1 .. 10] of Longint;
- // переменные визуализации
- DrawPeaks: array [0 .. 164] of Longint;
- DrawFallOff: array [0 .. 164] of Longint;
- // переменная файла конфигурации
- IniFile: TIniFile;
- implementation
- {$R *.dfm}
- uses
- UnitMini, UnitMix, UnitInformation;
- procedure TSoundCloud.Draw(HWND: THandle; DrawData: TDrawData; X, Y: Integer);
- var
- I, YPos: Longint;
- YVal: Single;
- begin
- IndicateGraph.Canvas.Pen.Color := clBlack;
- IndicateGraph.Canvas.Brush.Color := clBlack;
- IndicateGraph.Canvas.Rectangle(0, 0, IndicateGraph.Width,
- IndicateGraph.Height);
- IndicateGraph.Canvas.Pen.Color := clRed;
- for I := 0 to 163 do
- begin
- YVal := Abs(DrawData[I]);
- YPos := Trunc((YVal) * 500);
- if YPos > IndicateGraph.Height then
- YPos := IndicateGraph.Height;
- if YPos >= DrawPeaks[I] then
- DrawPeaks[I] := YPos
- else
- DrawPeaks[I] := DrawPeaks[I] - 1;
- if YPos >= DrawFallOff[I] then
- DrawFallOff[I] := YPos
- else
- DrawFallOff[I] := DrawFallOff[I] - 3;
- IndicateGraph.Canvas.Pen.Color := clYellow;
- IndicateGraph.Canvas.MoveTo(X + I * (3 + 1), Y + IndicateGraph.Height -
- DrawPeaks[I]);
- IndicateGraph.Canvas.LineTo(X + I * (3 + 1) + 3, Y + IndicateGraph.Height -
- DrawPeaks[I]);
- IndicateGraph.Canvas.Pen.Color := clRed;
- IndicateGraph.Canvas.Brush.Color := clRed;
- IndicateGraph.Canvas.Rectangle(X + I * (3 + 1), Y + IndicateGraph.Height -
- DrawFallOff[I], X + I * (3 + 1) + 3, Y + IndicateGraph.Height);
- end;
- end;
- procedure TSoundCloud.PlayButtonClick(Sender: TObject);
- begin
- PlayOrNot();
- if Mode = Play then
- exit;
- Player;
- end;
- procedure TSoundCloud.Player;
- begin
- if Mode <> Paused then
- begin
- if not FileExists(Filename) then
- begin
- Application.MessageBox('Ошибка воспроизведения файла', 'Ошибка ',
- MB_ICONERROR);
- exit;
- end;
- BASS_ChannelStop(Channel);
- BASS_StreamFree(Channel);
- Channel := BASS_StreamCreateFile(FALSE, PChar(Filename), 0, 0, 0
- {$IFDEF UNICODE} or BASS_UNICODE {$ENDIF});
- if Channel = 0 then
- begin
- Application.MessageBox('Ошибка воспроизведения файла', 'Ошибка',
- MB_ICONERROR);
- exit;
- end;
- end;
- Fx[1] := BASS_ChannelSetFX(Channel, BASS_FX_DX8_PARAMEQ, 1);
- Fx[2] := BASS_ChannelSetFX(Channel, BASS_FX_DX8_PARAMEQ, 1);
- Fx[3] := BASS_ChannelSetFX(Channel, BASS_FX_DX8_PARAMEQ, 1);
- Fx[4] := BASS_ChannelSetFX(Channel, BASS_FX_DX8_PARAMEQ, 1);
- Fx[5] := BASS_ChannelSetFX(Channel, BASS_FX_DX8_PARAMEQ, 1);
- Fx[6] := BASS_ChannelSetFX(Channel, BASS_FX_DX8_PARAMEQ, 1);
- Fx[7] := BASS_ChannelSetFX(Channel, BASS_FX_DX8_PARAMEQ, 1);
- Fx[8] := BASS_ChannelSetFX(Channel, BASS_FX_DX8_PARAMEQ, 1);
- Fx[9] := BASS_ChannelSetFX(Channel, BASS_FX_DX8_PARAMEQ, 1);
- Fx[10] := BASS_ChannelSetFX(Channel, BASS_FX_DX8_PARAMEQ, 1);
- P.fGain := 15 - Mixtape.FirstBar.Position;
- P.fBandwidth := 3;
- P.fCenter := 80;
- BASS_FXSetParameters(Fx[1], @P);
- P.fGain := 15 - Mixtape.SecondBar.Position;
- P.fBandwidth := 3;
- P.fCenter := 170;
- BASS_FXSetParameters(Fx[2], @P);
- P.fGain := 15 - Mixtape.ThirdBar.Position;
- P.fBandwidth := 3;
- P.fCenter := 310;
- BASS_FXSetParameters(Fx[3], @P);
- P.fGain := 15 - Mixtape.FourthBar.Position;
- P.fBandwidth := 3;
- P.fCenter := 600;
- BASS_FXSetParameters(Fx[4], @P);
- P.fGain := 15 - Mixtape.FifthBar.Position;
- P.fBandwidth := 3;
- P.fCenter := 1000;
- BASS_FXSetParameters(Fx[5], @P);
- P.fGain := 15 - Mixtape.SixthBar.Position;
- P.fBandwidth := 3;
- P.fCenter := 3000;
- BASS_FXSetParameters(Fx[6], @P);
- P.fGain := 15 - Mixtape.SeventhBar.Position;
- P.fBandwidth := 3;
- P.fCenter := 6000;
- BASS_FXSetParameters(Fx[7], @P);
- P.fGain := 15 - Mixtape.EighthBar.Position;
- P.fBandwidth := 3;
- P.fCenter := 10000;
- BASS_FXSetParameters(Fx[8], @P);
- P.fGain := 15 - Mixtape.NinethBar.Position;
- P.fBandwidth := 3;
- P.fCenter := 12000;
- BASS_FXSetParameters(Fx[9], @P);
- P.fGain := 15 - Mixtape.TenthBar.Position;
- P.fBandwidth := 3;
- P.fCenter := 14000;
- BASS_FXSetParameters(Fx[10], @P);
- if not BASS_ChannelPlay(Channel, FALSE) then
- begin
- Application.MessageBox('Ошибка воспроизведения файла', 'Ошибка',
- MB_ICONERROR);
- exit;
- end;
- ScrollSongBar.Min := 0;
- ScrollSongBar.Max := bass_ChannelGetLength(Channel, 0) - 1;
- SongNameLabel.Caption := ExtractFileName(Filename);
- Mode := Play;
- if (Assigned(MiniLonely)) and (Mode = Play) then
- begin
- MiniLonely.ScrollBar1.Min := ScrollSongBar.Min;
- MiniLonely.ScrollBar1.Max := ScrollSongBar.Max;
- MiniLonely.TrackNameLabel.Caption := SongNameLabel.Caption;
- end;
- end;
- procedure TSoundCloud.ScrollSongBarScroll(Sender: TObject;
- ScrollCode: TScrollCode; var ScrollPos: Integer);
- begin
- bass_ChannelSetPosition(Channel, ScrollSongBar.Position, 0);
- if not GetKeyState(VK_LBUTTON) < 0 then
- PauseButton.Click;
- end;
- procedure TSoundCloud.SondListDrawItem(Control: TWinControl; Index: Integer;
- Rect: TRect; State: TOwnerDrawState);
- const
- W = 16;
- H = 16;
- begin
- with (Control as TListBox).Canvas do
- begin
- FillRect(Rect);
- end;
- with (Control as TListBox).Canvas do
- begin
- Font.Color := clWhite;
- Font.Size := 9;
- Brush.Style := bsClear;
- Brush.Color := clWhite;
- SetBkMode(SongsList.Canvas.Handle, TRANSPARENT);
- TextOut(Rect.Left, Rect.Top, IntToStr(Index + 1) + '. ' +
- ExtractFileName(SongsList.Items[index]));
- end;
- end;
- procedure TSoundCloud.StopButtonClick(Sender: TObject);
- begin
- if Mode = Play then
- begin
- BASS_ChannelStop(Channel);
- Mode := Stop;
- end;
- end;
- procedure TSoundCloud.Timer1Timer(Sender: TObject);
- var
- FFTFata: TDrawData;
- TrackLen, TrackPos: Double;
- ValPos: Double;
- ValLen: Double;
- begin
- if Mode <> Play then
- exit;
- if BASS_ChannelGetPosition(Channel, 0) = bass_ChannelGetLength(Channel, 0)
- then
- begin
- if I < SongsList.Items.Count - 1 then
- begin
- Inc(I);
- Filename := SongsList.Items.Strings[I];
- SongsList.ItemIndex := I;
- Mode := Stop;
- Player;
- end
- else
- exit;
- end;
- BASS_ChannelGetData(Channel, @FFTFata, BASS_DATA_FFT1024);
- Draw(IndicateGraph.Canvas.Handle, FFTFata, 0, -5);
- ScrollSongBar.Position := BASS_ChannelGetPosition(Channel, 0);
- MiniLonely.ScrollBar1.Position := ScrollSongBar.Position;
- TrackPos := BASS_ChannelBytes2Seconds(Channel,
- BASS_ChannelGetPosition(Channel, 0));
- TrackLen := BASS_ChannelBytes2Seconds(Channel,
- bass_ChannelGetLength(Channel, 0));
- ValPos := TrackPos / (24 * 3600);
- ValLen := TrackLen / (24 * 3600);
- TimeFirstLabel.Caption := FormatDateTime('hh:mm:ss', ValPos);
- TimeLastLabel.Caption := FormatDateTime('hh:mm:ss', ValLen);
- BASS_ChannelSetAttribute(Channel, BASS_ATTRIB_VOL, SoundBar.Position / 10);
- BASS_ChannelSetAttribute(Channel, BASS_ATTRIB_PAN, BalanceBar.Position / 5);
- end;
- procedure TSoundCloud.TrashCanButtonClick(Sender: TObject);
- begin
- case Application.MessageBox('Вы точно хотите удалить треки?',
- 'Предупреждение', MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2) of
- IDYES:
- begin
- SongsList.Clear;
- DeActivateMusicPlayer();
- BASS_ChannelStop(Channel);
- Mode := Stop;
- Application.MessageBox
- ('Вы очистили плейлист, воспользуйтесь добавлением новых мелодий',
- 'Предупреждение', MB_ICONINFORMATION);
- end;
- end;
- end;
- procedure TSoundCloud.BackButtonClick(Sender: TObject);
- begin
- PlayOrNot();
- if SongsList.ItemIndex > 0 then
- begin
- Dec(I);
- Filename := SongsList.Items.Strings[I];
- SongsList.ItemIndex := I;
- Mode := Stop;
- Player;
- end
- else
- begin
- BackButton.Enabled := FALSE;
- Application.MessageBox('Это первый трек в вашем плейлисте!', 'Ошибка',
- MB_ICONERROR);
- end;
- StopButton.Click;
- PlayButton.Click;
- end;
- procedure TSoundCloud.VolumeZeroButtonClick(Sender: TObject);
- begin
- if Mode = Play then
- SoundBar.Position := 0;
- end;
- procedure TSoundCloud.VolumeTenButtonClick(Sender: TObject);
- begin
- if Mode = Play then
- SoundBar.Position := 10;
- end;
- procedure TSoundCloud.SettingsAndInfoButtonClick(Sender: TObject);
- begin
- UnitInfo.show;
- end;
- procedure TSoundCloud.MiniViewButtonClick(Sender: TObject);
- begin
- if (Mode = Play) or (Mode = Paused) then
- begin
- MiniViewButton.Enabled := True;
- MiniLonely.show;
- SoundCloud.Hide;
- MiniLonely.WindowState := wsNormal;
- end;
- end;
- procedure TSoundCloud.EqualizerButtonClick(Sender: TObject);
- begin
- Mixtape.show;
- end;
- procedure TSoundCloud.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- begin
- case Application.MessageBox('Вы точно хотите выйти из программы?', 'Выход',
- MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2) of
- IDYES:
- CanClose := True;
- IDNO:
- CanClose := FALSE;
- end;
- end;
- procedure TSoundCloud.FolderButtonClick(Sender: TObject);
- var
- J: Integer;
- begin
- OpenDialog1.Title := 'Выбрать музыку';
- OpenDialog1.Filter := 'mp3|*.mp3';
- if SongsList.Count <> 0 then
- I := SongsList.ItemIndex
- else
- I := 0;
- if not OpenDialog1.Execute then
- exit;
- begin
- for J := 0 to OpenDialog1.Files.Count - 1 do
- begin
- SongsList.Items.Add(OpenDialog1.Files.Strings[J]);
- end;
- end;
- Filename := SongsList.Items.Strings[I];
- SongsList.ItemIndex := I;
- PlayOrNot();
- end;
- procedure TSoundCloud.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- CloseCfg;
- Bass_Stop();
- BASS_StreamFree(Channel);
- Bass_Free;
- end;
- procedure TSoundCloud.CloseCfg;
- var
- N: Integer;
- begin
- IniFile.WriteInteger('Информация о форме', 'Left', Left);
- IniFile.WriteInteger('Информация о форме', 'Top', Top);
- IniFile.WriteInteger('Информация о форме', 'Width', Width);
- IniFile.WriteInteger('Информация о форме', 'Height', Height);
- IniFile.WriteInteger('Громкость', 'SoundBar.position', SoundBar.Position);
- IniFile.WriteInteger('Эквалайзер', 'FirstBar.position',
- Mixtape.FirstBar.Position);
- IniFile.WriteInteger('Эквалайзер', 'SecondBar.position',
- Mixtape.SecondBar.Position);
- IniFile.WriteInteger('Эквалайзер', 'ThirdBar.position',
- Mixtape.ThirdBar.Position);
- IniFile.WriteInteger('Эквалайзер', 'FourthBar.position',
- Mixtape.FourthBar.Position);
- IniFile.WriteInteger('Эквалайзер', 'FifthBar.position',
- Mixtape.FifthBar.Position);
- IniFile.WriteInteger('Эквалайзер', 'SixthBar.position',
- Mixtape.SixthBar.Position);
- IniFile.WriteInteger('Эквалайзер', 'SeventhBar.position',
- Mixtape.SeventhBar.Position);
- IniFile.WriteInteger('Эквалайзер', 'EighthBar.position',
- Mixtape.EighthBar.Position);
- IniFile.WriteInteger('Эквалайзер', 'NinethBar.position',
- Mixtape.NinethBar.Position);
- IniFile.WriteInteger('Эквалайзер', 'TenthBar.position',
- Mixtape.TenthBar.Position);
- IniFile.WriteInteger('Количество треков', 'Треков:', SongsList.Items.Count);
- IniFile.EraseSection('Плейлист');
- for N := 0 to SongsList.Items.Count - 1 do
- begin
- IniFile.WriteString('Плейлист', 'Трек ' + IntToStr(N + 1),
- SongsList.Items.Strings[N]);
- end;
- IniFile.WriteTime('Время', 'Время запуска последней сессии', Time);
- IniFile.Free;
- end;
- procedure TSoundCloud.FormCreate(Sender: TObject);
- begin
- SoundBar.Min := 0;
- SoundBar.Max := 10;
- SoundBar.Position := 25;
- BalanceBar.Min := -5;
- BalanceBar.Max := 5;
- BalanceBar.Position := 0;
- if (HiWord(BASS_GetVersion) <> BASSVERSION) then
- begin
- Application.MessageBox('Не корректная версия BASS.DLL', 'Ошибка',
- MB_ICONERROR);
- exit;
- end;
- if not BASS_Init(-1, 44100, 0, Handle, nil) then
- begin
- Application.MessageBox('Ошибка инициализация аудио', 'Ошибка',
- MB_ICONERROR);
- exit;
- end;
- CreateCfg;
- end;
- procedure TSoundCloud.CreateCfg;
- var
- N, Count: Integer;
- begin
- IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) +
- 'Configuration.ini');
- SoundBar.Position := IniFile.ReadInteger('Громкость', 'SoundBar.position', 5);
- Count := IniFile.ReadInteger('Количество треков', 'Треков:', 0);
- if Count <> 0 then
- begin
- ActivateMusicPlayer();
- for N := 0 to Count - 1 do
- SongsList.Items.Add(IniFile.ReadString('Плейлист',
- 'Трек ' + IntToStr(N + 1), 'Ошибка чтения'));
- Filename := SongsList.Items.Strings[0];
- SongsList.ItemIndex := 0;
- end;
- end;
- procedure TSoundCloud.PlayOrNot();
- begin
- if SongsList.Items.Count = 0 then
- begin
- DeActivateMusicPlayer();
- Application.MessageBox
- ('Воспользуйтесь загрузкой треков для работы с плеером', 'Ошибка',
- MB_ICONERROR);
- end
- else
- ActivateMusicPlayer();
- end;
- procedure TSoundCloud.ActivateMusicPlayer();
- begin
- PauseButton.Enabled := True;
- ForwardButton.Enabled := True;
- BackButton.Enabled := True;
- EqualizerButton.Enabled := True;
- StopButton.Enabled := True;
- PlayButton.Enabled := True;
- MiniViewButton.Enabled := True;
- TrashCanButton.Enabled := True;
- end;
- procedure TSoundCloud.DeActivateMusicPlayer();
- begin
- PauseButton.Enabled := FALSE;
- PlayButton.Enabled := FALSE;;
- ForwardButton.Enabled := FALSE;
- BackButton.Enabled := FALSE;
- EqualizerButton.Enabled := FALSE;
- StopButton.Enabled := FALSE;
- MiniViewButton.Enabled := FALSE;
- TrashCanButton.Enabled := FALSE;
- end;
- procedure TSoundCloud.ForwardButtonClick(Sender: TObject);
- begin
- PlayOrNot();
- if SongsList.ItemIndex < SongsList.Count - 1 then
- begin
- Inc(I);
- Filename := SongsList.Items.Strings[I];
- SongsList.ItemIndex := I;
- Mode := Stop;
- Player;
- end;
- StopButton.Click;
- PlayButton.Click;
- end;
- procedure TSoundCloud.SongsListDblClick(Sender: TObject);
- begin
- I := SongsList.ItemIndex;
- Filename := SongsList.Items.Strings[I];
- UnitInfo.AddMemo(Sender);
- Mode := Stop;
- Player;
- end;
- procedure TSoundCloud.PauseButtonClick(Sender: TObject);
- begin
- PlayOrNot();
- if Mode = Play then
- begin
- BASS_ChannelPause(Channel);
- Mode := Paused;
- end;
- end;
- procedure TSoundCloud.IndicateGraphPaint(Sender: TObject);
- begin
- IndicateGraph.Canvas.Pen.Color := clBlack;
- IndicateGraph.Canvas.Brush.Color := clBlack;
- IndicateGraph.Canvas.Rectangle(0, 0, IndicateGraph.Width,
- IndicateGraph.Height);
- end;
- end.
- unit UnitMix;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ComCtrls, bass, Vcl.ExtCtrls;
- type
- TMixtape = class(TForm)
- NinethBar: TTrackBar;
- EighthBar: TTrackBar;
- SeventhBar: TTrackBar;
- SixthBar: TTrackBar;
- FifthBar: TTrackBar;
- FourthBar: TTrackBar;
- ThirdBar: TTrackBar;
- SecondBar: TTrackBar;
- FirstBar: TTrackBar;
- TenthBar: TTrackBar;
- Label14: TLabel;
- Label13: TLabel;
- Label12: TLabel;
- Label11: TLabel;
- Label10: TLabel;
- Label9: TLabel;
- Label8: TLabel;
- Label7: TLabel;
- Label6: TLabel;
- Label5: TLabel;
- PaintBox1: TPaintBox;
- PaintBox2: TPaintBox;
- Timer1: TTimer;
- procedure FirstBarChange(Sender: TObject);
- procedure SecondBarChange(Sender: TObject);
- procedure ThirdBarChange(Sender: TObject);
- procedure FourthBarChange(Sender: TObject);
- procedure FifthBarChange(Sender: TObject);
- procedure SixthBarChange(Sender: TObject);
- procedure SeventhBarChange(Sender: TObject);
- procedure EighthBarChange(Sender: TObject);
- procedure NinethBarChange(Sender: TObject);
- procedure TenthBarChange(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure Timer1Timer(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Mixtape: TMixtape;
- implementation
- {$R *.dfm}
- uses UnitPlay;
- procedure TMixtape.FormCreate(Sender: TObject);
- begin
- FirstBar.position := IniFile.ReadInteger('Эквалайзер', 'FirstBar.position', 15);
- SecondBar.position := IniFile.ReadInteger('Эквалайзер',
- 'SecondBar.position', 15);
- ThirdBar.position := IniFile.ReadInteger('Эквалайзер', 'ThirdBar.position', 15);
- FourthBar.position := IniFile.ReadInteger('Эквалайзер',
- 'FourthBar.position', 15);
- FifthBar.position := IniFile.ReadInteger('Эквалайзер', 'FifthBar.position', 15);
- SixthBar.position := IniFile.ReadInteger('Эквалайзер', 'SixthBar.position', 15);
- SeventhBar.position := IniFile.ReadInteger('Эквалайзер',
- 'SeventhBar.position', 15);
- EighthBar.position := IniFile.ReadInteger('Эквалайзер',
- 'EighthBar.position', 15);
- NinethBar.position := IniFile.ReadInteger('Эквалайзер',
- 'NinethBar.position', 15);
- TenthBar.position := IniFile.ReadInteger('Эквалайзер', 'TenthBar.position', 15);
- end;
- procedure TMixtape.EighthBarChange(Sender: TObject);
- begin
- BASS_FXGetParameters(fx[8], @p);
- p.fgain := 15 - EighthBar.position;
- BASS_FXSetParameters(fx[8], @p);
- end;
- procedure TMixtape.NinethBarChange(Sender: TObject);
- begin
- BASS_FXGetParameters(fx[9], @p);
- p.fgain := 15 - NinethBar.position;
- BASS_FXSetParameters(fx[9], @p);
- end;
- procedure TMixtape.TenthBarChange(Sender: TObject);
- begin
- BASS_FXGetParameters(fx[10], @p);
- p.fgain := 15 - TenthBar.position;
- BASS_FXSetParameters(fx[10], @p);
- end;
- procedure TMixtape.FirstBarChange(Sender: TObject);
- begin
- BASS_FXGetParameters(fx[1], @p);
- p.fgain := 15 - FirstBar.position;
- BASS_FXSetParameters(fx[1], @p);
- end;
- procedure TMixtape.SecondBarChange(Sender: TObject);
- begin
- BASS_FXGetParameters(fx[2], @p);
- p.fgain := 15 - SecondBar.position;
- BASS_FXSetParameters(fx[2], @p);
- end;
- procedure TMixtape.ThirdBarChange(Sender: TObject);
- begin
- BASS_FXGetParameters(fx[3], @p);
- p.fgain := 15 - ThirdBar.position;
- BASS_FXSetParameters(fx[3], @p);
- end;
- procedure TMixtape.Timer1Timer(Sender: TObject);
- var
- Left, Right, L1, R1: Integer;
- Level: DWORD;
- begin
- if BASS_ChannelIsActive(Channel) <> BASS_Active_Playing then
- exit;
- Level := BASS_ChannelGetLevel(Channel);
- Left := LoWord(Level);
- Right := HiWord(Level);
- PaintBox1.Canvas.Brush.Color := clWhite;
- PaintBox1.Canvas.FillRect(PaintBox1.Canvas.ClipRect);
- PaintBox2.Canvas.Brush.Color := clWhite;
- PaintBox2.Canvas.FillRect(PaintBox2.Canvas.ClipRect);
- PaintBox1.Canvas.Brush.Color := clBlack;
- PaintBox2.Canvas.Brush.Color := clBlack;
- PaintBox1.Canvas.Rectangle(0, PaintBox1.Height - L1, PaintBox1.Width,
- PaintBox1.Height);
- PaintBox2.Canvas.Rectangle(0, PaintBox2.Height - R1, PaintBox2.Width,
- PaintBox2.Height);
- end;
- procedure TMixtape.FourthBarChange(Sender: TObject);
- begin
- BASS_FXGetParameters(fx[4], @p);
- p.fgain := 15 - FourthBar.position;
- BASS_FXSetParameters(fx[4], @p);
- end;
- procedure TMixtape.FifthBarChange(Sender: TObject);
- begin
- BASS_FXGetParameters(fx[5], @p);
- p.fgain := 15 - FifthBar.position;
- BASS_FXSetParameters(fx[5], @p);
- end;
- procedure TMixtape.SixthBarChange(Sender: TObject);
- begin
- BASS_FXGetParameters(fx[6], @p);
- p.fgain := 15 - SixthBar.position;
- BASS_FXSetParameters(fx[6], @p);
- end;
- procedure TMixtape.SeventhBarChange(Sender: TObject);
- begin
- BASS_FXGetParameters(fx[7], @p);
- p.fgain := 15 - SeventhBar.position;
- BASS_FXSetParameters(fx[7], @p);
- end;
- end.
- unit UnitMini;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
- System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls, Vcl.Buttons,
- Bass;
- type
- TMiniLonely = class(TForm)
- Timer1: TTimer;
- MiniViewButton: TBitBtn;
- PlayButton: TBitBtn;
- NextSongButton: TBitBtn;
- StopButton: TBitBtn;
- PrevSongButton: TBitBtn;
- ScrollBar1: TScrollBar;
- TrackNameLabel: TLabel;
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure FormCreate(Sender: TObject);
- procedure TimerTimer(Sender: TObject);
- procedure MiniViewButtonClick(Sender: TObject);
- procedure StopButtonClick(Sender: TObject);
- procedure PlayButtonClick(Sender: TObject);
- procedure NextSongButtonClick(Sender: TObject);
- procedure PrevSongButtonClick(Sender: TObject);
- procedure FormKeyPress(Sender: TObject; var Key: Char);
- procedure ScrollSongBarScroll(Sender: TObject; ScrollCode: TScrollCode;
- var ScrollPos: Integer);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- MiniLonely: TMiniLonely;
- implementation
- {$R *.dfm}
- uses
- UnitPlay, UnitMix;
- procedure TMiniLonely.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- SoundCloud.Show;
- SoundCloud.Position := poDesktopCenter;
- end;
- procedure TMiniLonely.FormCreate(Sender: TObject);
- begin
- Top := Screen.WorkAreaRect.Top + 150;
- Left := Screen.WorkAreaRect.Right - Width;
- SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE + SWP_NOMOVE +
- SWP_NOSIZE);
- TrackNameLabel.Caption := SoundCloud.SongNameLabel.Caption;
- end;
- procedure TMiniLonely.TimerTimer(Sender: TObject);
- begin
- if MiniLonely.Visible and (Mode = Play) then
- begin
- TrackNameLabel.Caption := SoundCloud.SongNameLabel.Caption;
- PlayButton.Visible := SoundCloud.PlayButton.Visible;
- StopButton.Visible := SoundCloud.StopButton.Visible;
- TrackNameLabel.Caption := ExtractFileName(Filename);
- ScrollBar1.Position := SoundCloud.ScrollSongBar.Position;
- end;
- end;
- procedure TMiniLonely.FormKeyPress(Sender: TObject; var Key: Char);
- begin
- if (Key = #32) then
- begin
- if (Mode = Play) then
- SoundCloud.StopButton.Click
- else
- SoundCloud.PlayButton.Click;
- end;
- if Key = #27 then
- MiniLonely.Close;
- end;
- procedure TMiniLonely.MiniViewButtonClick(Sender: TObject);
- begin
- MiniLonely.Close;
- end;
- procedure TMiniLonely.ScrollSongBarScroll(Sender: TObject;
- ScrollCode: TScrollCode; var ScrollPos: Integer);
- begin
- ScrollBar1.Min := 0;
- ScrollBar1.Max := bass_ChannelGEtLength(UnitPlay.Channel, 0) - 1;
- bass_ChannelSetPosition(UnitPlay.Channel,
- SoundCloud.ScrollSongBar.Position, 0);
- end;
- procedure TMiniLonely.NextSongButtonClick(Sender: TObject);
- begin
- SoundCloud.ForwardButton.Click;
- end;
- procedure TMiniLonely.PlayButtonClick(Sender: TObject);
- begin
- SoundCloud.PlayButton.Click;
- end;
- procedure TMiniLonely.PrevSongButtonClick(Sender: TObject);
- begin
- SoundCloud.BackButton.Click;
- end;
- procedure TMiniLonely.StopButtonClick(Sender: TObject);
- begin
- SoundCloud.StopButton.Click;
- end;
- end.
- unit UnitInformation;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
- System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Imaging.pngimage, Vcl.ExtCtrls,
- ShellApi, Vcl.StdCtrls, Vcl.Buttons;
- type
- LastTrack = ^Tracks;
- Tracks = record
- FilePath: string;
- Next: LastTrack;
- end;
- TUnitInfo = class(TForm)
- Image1: TImage;
- Image2: TImage;
- Image3: TImage;
- Image4: TImage;
- Image5: TImage;
- LatestTracksButton: TBitBtn;
- Label1: TLabel;
- procedure Image3Click(Sender: TObject);
- procedure Image4Click(Sender: TObject);
- procedure Image5Click(Sender: TObject);
- procedure Image2Click(Sender: TObject);
- procedure Image1Click(Sender: TObject);
- procedure AddMemo(Sender: TObject);
- procedure WriteToMemo;
- procedure LatestTracksButtonClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- UnitInfo: TUnitInfo;
- Head: LastTrack;
- implementation
- {$R *.dfm}
- uses
- UnitPlay;
- procedure TUnitInfo.LatestTracksButtonClick(Sender: TObject);
- begin
- WriteToMemo();
- end;
- procedure TUnitInfo.Image1Click(Sender: TObject);
- begin
- ShellExecute(Handle, 'open', 'https://github.com/antitoxical', Nil,
- Nil, SW_SHOW);
- end;
- procedure TUnitInfo.Image2Click(Sender: TObject);
- begin
- ShellExecute(Handle, 'open',
- 'https://www.linkedin.com/in/%D0%B4%D0%B0%D0%BD%D0%B8%D0%BB%D0%B0-%D0%B0%D1%81%D0%B5%D0%BF%D0%BA%D0%BE%D0%B2-558147275',
- Nil, Nil, SW_SHOW);
- end;
- procedure TUnitInfo.Image3Click(Sender: TObject);
- begin
- ShellExecute(Handle, 'open', 'https://vk.com/antitoxical', Nil, Nil, SW_SHOW);
- end;
- procedure TUnitInfo.Image4Click(Sender: TObject);
- begin
- ShellExecute(Handle, 'open', 'https://www.instagram.com/antitoxical', Nil,
- Nil, SW_SHOW);
- end;
- procedure TUnitInfo.Image5Click(Sender: TObject);
- begin
- ShellExecute(Handle, 'open', 'https://t.me/altervisi0n', Nil, Nil, SW_SHOW);
- end;
- procedure TUnitInfo.AddMemo(Sender: TObject);
- var
- Curr: LastTrack;
- begin
- New(Curr);
- Curr^.FilePath := SoundCloud.SongsList.Items.Strings[I];
- Curr^.Next := Head;
- Head := Curr;
- end;
- procedure TUnitInfo.WriteToMemo;
- var
- Curr: LastTrack;
- St: string;
- begin
- St := '';
- SoundCloud.SongsList.ItemIndex :=0;
- Curr := Head;
- while Curr <> NIL do
- begin
- SoundCloud.SongsList.ItemIndex := SoundCloud.SongsList.ItemIndex + 1;
- St := St + Curr^.FilePath + #13;
- Curr := Curr^.Next;
- end;
- if (SoundCloud.SongsList.Count <> 0) and (SoundCloud.SongsList.Count > 1) then
- ShowMessage('Все треки,проигрываемые в этой сессии:' + #13 + St)
- else
- ShowMessage('Треки не проигрывались.');
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement