Download Now

    Reference TAudio

    Declared in Codebot.Hardware.pas on line 290

    TAudio owns the audio sources and banks and mixes the banks which are playing. Use the Audio function to get the one instance. Audio is paused until Paused is set to False.
      TAudio = class
      public
        constructor Create;
        destructor Destroy; override;
        { Banks are created when first used. Return True if one has been. }
        function BankExists(Index: Integer): Boolean;
        { Return True if audio is not paused and any bank is playing }
        function IsPlaying: Boolean;
        { Add a source from a file with a name which is not in use }
        function Add(const Name: string; const FileName: string): TAudioSource; overload;
        { Add a source from a stream, which is read from its start }
        function Add(const Name: string; Stream: TStream): TAudioSource; overload;
        { Remove and destroy a source, unloading it from any bank }
        procedure Remove(Source: TAudioSource);
        { Find a source by name or return nil }
        function Source(const Name: string): TAudioSource; overload;
        { Find a source by id or return nil }
        function Source(Id: Integer): TAudioSource; overload;
        { Return a bank which is not reserved, preferring a completed bank, then an
          unused one, then the bank loaded or reset the longest ago }
        function Next: TAudioBank;
        { Load a source in a bank chosen as by Next and play it. LoopCount is the
          number of times it is played, where a value less than 1 plays until it is
          stopped. With FadeIn above 0 it is raised from silence over that many
          seconds. Use FadeOut on the bank returned to end it the same way. }
        function Play(Source: TAudioSource; LoopCount: Integer = 1; FadeIn: Single = 0): TAudioBank; overload;
        { Play a source by name }
        function Play(const Name: string; LoopCount: Integer = 1; FadeIn: Single = 0): TAudioBank; overload;
        { Play a source by id }
        function Play(Id: Integer; LoopCount: Integer = 1; FadeIn: Single = 0): TAudioBank; overload;
        { Available is False if no audio device could be opened }
        property Available: Boolean read GetAvailable;
        { Paused stops all mixing. The default is True. }
        property Paused: Boolean read FPaused write SetPaused;
        { Volume of all banks from 0 for silence to 1. The default is 1. }
        property Volume: Single read FVolume write SetVolume;
        { The audio sources by index }
        property Sources[Index: Integer]: TAudioSource read GetSource;
        { The number of audio sources }
        property SourceCount: Integer read GetSourceCount;
        { The banks by index }
        property Banks[Index: Integer]: TAudioBank read GetBank;
        { The number of banks }
        property BankCount: Integer read GetBankCount;
        { OnMix lets a program generate sound itself. It is called for every block
          which is mixed while audio is not paused, and what it writes is mixed with
          the banks and follows Volume. Assign nil to stop. }
        property OnMix: TAudioMixEvent read FOnMix write SetOnMix;
      end;

    See also