aboutsummaryrefslogtreecommitdiff
path: root/src/aomusicplayer.h
blob: 248a45e3a9daba1fb5eb09c994feff22b301fbdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once

#include "aoapplication.h"

#include <QFutureWatcher>

class AOMusicPlayer
{
public:
  // Channel 0 = music
  // Channel 1 = ambience
  static constexpr int CHANNEL_COUNT = 2;

  AOMusicPlayer(AOApplication *p_ao_app);
  virtual ~AOMusicPlayer();

  void set_volume(int p_value, int channel = -1);
  void set_looping(bool loop_song, int channel = 0);
  void set_muted(bool toggle);

  QFutureWatcher<QString> music_watcher;

public Q_SLOTS:
  QString play(QString p_song, int channel = 0, bool loop = false, int effect_flags = 0);
  void stop(int channel = 0);

private:
  AOApplication *ao_app;

  bool m_muted = false;
  int m_volume[CHANNEL_COUNT] = {0, 0};
  HSTREAM m_stream_list[CHANNEL_COUNT];
  HSYNC m_loop_sync[CHANNEL_COUNT];

  /**
   * @brief The starting sample of the AB-Loop.
   */
  unsigned int m_loop_start[CHANNEL_COUNT] = {0, 0};

  /**
   * @brief The end sample of the AB-Loop.
   */
  unsigned int m_loop_end[CHANNEL_COUNT] = {0, 0};
};