(* (c) Copyright 2000 - Holger Dors
   =======================================

   This file is part of RazorLame,
   a front-end for the LAME MP3 Encoder.

   See license.txt for details.             *)

unit globals;

interface

uses Classes, ResStr, Windows;

const
  RL_VERSION = 'RazorLame 1.1.1';
  LOG_FILENAME = 'RazorLame.log';

  LAME_HOMEPAGE = 'http://www.mp3dev.org/';
  RAZORLAME_HOMEPAGE = 'http://www.dors.de/razorlame/';
  RAZORLAME_FORUM = 'http://pub22.ezboard.com/brazorlame';  

  TOOLBAR_SECTION = 'Toolbar';
  LAYOUT_ITEM = 'Layout';
  VISIBLE_ITEM = 'Visible';
  FILES_SECTION = 'Files';
  FORM_SECTION = 'Form';

  LAYOUT_ICONS = 1;
  LAYOUT_CAPTIONS = 2;
  LAYOUT_BOTH = 3;

type

  TMp3Flag = (mfCopy, mfCopyright);
  TMp3Flags = set of TMp3Flag;
  TLameMode = (lmStereo, lmJointStereo, lmForcedJointStereo, lmMono);
  TLameOptimization = (loNone, loSpeed, loQuality, loVoice);
  TResampleFreq = (rfDefault, rf16kHz, rf22kHz, rf24kHz, rf32kHz, rf44kHz, rf48kHz);
  TATHControl = (athDefault, athOnly, athDisabled);

  TMP3Settings = record
    Bitrate: Integer;
    LameMode: TLameMode;
    LameOptimization: TLameOptimization;
    VBREnabled: Boolean;
    VBRQuality: Integer;
    VBRMaxBitrate: Integer;
    VBRDisableTag: Boolean;
    VBRStrictMin: Boolean;
    VBRUseABR: Boolean;
    VBRABRTargetBitrate: Integer;
    ResampleFreq: TResampleFreq;
    HighpassFreq: Double;
    HighpassEnabled: Boolean;
    HighpassWidth: Double;
    HighWidthEnabled: Boolean;
    LowpassFreq: Double;
    LowpassEnabled: Boolean;
    LowpassWidth: Double;
    LowWidthEnabled: Boolean;
    IncludeCRC: Boolean;
    Flags: TMp3Flags;
    ATHControl: TATHControl;
    DifferentBlockTypes: Boolean;
    DisableFiltering: Boolean;
    NoRes: Boolean;
    NoShort: Boolean;
    ISO: Boolean;
    CustomOptions: string;
    OnlyCustomOptions: Boolean;
    OutDir: string;
    DeleteFileAfterProcessing: Boolean;
  end;

  TGlobalVars = record
    Encoder: string;
    FilesToEncode: Integer;
    FilesEncoded: Integer;
    FilesWithErrors: Integer;
    Log: TStringList;
    ErrorOccurred: Boolean;
    ErrorOccurredInBatch: Boolean;
    CurrentFileFullname: string;
    CurrentFile: string;
    FilePercent: Integer;
    BatchPercent: Integer;
    StopWhenDone: Boolean;
    LastOpenDir: string;
    StatusMessages: Boolean;
    VBRHistogram: Boolean;
    TotalSize: Int64;
    CurrentSize: Int64;
    LastSize: Int64;
    CurrentItemSize: Int64;
    BatchStart: TDateTime;
    FileStart: TDateTime;
    LastLine: string;
    InputFileTypes: TStringList;
    EncoderInfoStrings: TStringList;
    EncoderInfoStringsLength: array of Integer;
    DecodeInfoStrings: TStringList;
    DecodeInfoStringsLength: array of Integer;
    PercentPos: Integer;
  end;

  TFileItem = class(TObject)
    Filename: string;
    Path: string;
    Size: Int64;
    Date: TDateTime;
  end;

var
  Global: TGlobalVars;
  MP3Settings: TMP3Settings;

  gsaBitrates: array[1..18] of string
    = ('8', '16', '24', '32', '40', '48', '56', '64', '80', '96', '112', '128',
    '144', '160', '192', '224', '256', '320');

  gsaPriorities: array[0..5] of string;

implementation

procedure CreateGlobals;
begin
  Global.Log := TStringList.Create;
  Global.InputFileTypes := TStringList.Create;
  Global.EncoderInfoStrings := TStringList.Create;
  Global.DecodeInfoStrings := TStringList.Create;
end;

procedure FreeGlobals;
begin
  Global.Log.Free;
  Global.InputFileTypes.Free;
  Global.EncoderInfoStrings.Free;
  Global.DecodeInfoStrings.Free;
end;

initialization
  CreateGlobals;

finalization
  FreeGlobals;

end.

