Skip to content
Harrison edited this page Aug 2, 2022 · 2 revisions

enum class audiogc::type

Audio types used by an audiogc::player.

Values

  • detect
    • Automatically detect the audio type.
  • flac
    • FLAC type.
  • mp3
    • MP3 type.
  • vorbis
    • (Ogg) Vorbis type.
  • wav
    • WAV type.

enum class audiogc::mode

File modes used by an audiogc::player reading from a file.

Values

  • stream
    • Read from file as needed (recommended for music files).
  • store
    • Store file into memory (recommended for sound effects).

class audiogc::player

Handles playback of an audio file or data.

Constructors

  • audiogc::player(type audio_type, const std::string &file_name, mode file_mode = mode::stream)
    • New player from a file name.
  • audiogc::player(type audio_type, const void *audio_data, unsigned int audio_size)
    • New player from audio data.
  • audiogc::player(const player &other)
    • New player from an existing player.

Playback

  • void pause()
    • Pauses playback.
  • bool play()
    • Starts playback. If already playing, nothing happens.
    • Returns whether playback has successfully started.
      • If playback has not started, it is likely because 10 LWP threads are currently in use (each player uses 1).
  • void stop()
    • Stops playback and resets position to 0.

Playback state

  • unsigned char get_channel_count()
    • Returns the number of channels, 1 for mono, 2 for stereo.
  • double get_pitch()
    • Returns the current pitch.
  • unsigned char get_volume()
    • Returns the current volume.
  • bool is_looping()
    • Returns whether the audio is looping.
  • bool is_playing()
    • Returns true if the audio is playing or paused.
  • void seek(int offset = 0)
    • Seeks to the specified offset in milliseconds.
  • void set_looping(bool looping = false)
    • Sets whether the audio should loop.
  • double set_pitch(double pitch = 1.0)
    • Sets the pitch of the audio (1 = 1x, 1.5 = 1.5x, 2 = 2x, etc.).
    • Returns the actual pitch set, should it translate to higher than the max frequency (144 kHz).
  • void set_volume(unsigned char volume = 255)
    • Sets the volume to the specified value (0-255).
  • double tell()
    • Returns the current position in seconds.

Special

  • void change_settings(unsigned int buffer_size = 2304, unsigned int thread_stack_size = 0x8000, unsigned char thread_priority = 64)
    • Changes internal player settings.
    • Only use if necessary! You shouldn't need to change any of these settings.