atrooney-online-2/include/aomusicplayer.h
Crystalwarrior b9e9e02977
Fix an extremely rare issue where loop point goes outside track bounds if loop end is not defined (#748)
* Fix an incredibly edge-case loop end issue where the loop end is outside track boundaries somehow

* WIP-AB Cleanup and incorrect loop bugfix

Cleanup AB-Loop code
* Someone has to check if AB loop works properly still cause I have no idea how this shit works and the code prior was unreadable.
Don't blame me, blame whoever left this code undocumented like the hag they are.

* Increase max-sample we can accept in the AB loop

Also change conversion to UInt. If someone adds a bad value, it will just return 0, which I guess is fair.

Co-authored-by: Salanto <62221668+Salanto@users.noreply.github.com>
2022-07-27 00:27:01 +02:00

62 lines
1.3 KiB
C++

#ifndef AOMUSICPLAYER_H
#define AOMUSICPLAYER_H
#include "file_functions.h"
#include "bass.h"
#include "bassmidi.h"
#include "bassopus.h"
#include "aoapplication.h"
#include <QDebug>
#include <QWidget>
#include <string.h>
#include <QFuture>
#include <QFutureWatcher>
class AOMusicPlayer {
public:
AOMusicPlayer(QWidget *parent, 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);
const int m_channelmax = 4;
// These have to be public for the stupid sync thing
/**
* @brief The starting sample of the AB-Loop.
*/
unsigned int loop_start[4] = {0, 0, 0, 0};
/**
* @brief The end sample of the AB-Loop.
*/
unsigned int loop_end[4] = {0, 0, 0, 0};
QFutureWatcher<QString> music_watcher;
public slots:
QString play(QString p_song, int channel = 0, bool loop = false,
int effect_flags = 0);
void stop(int channel = 0);
private:
QWidget *m_parent;
AOApplication *ao_app;
bool m_looping = false;
bool m_muted = false;
int m_volume[4] = {0, 0, 0, 0};
// Channel 0 = music
// Channel 1 = ambience
// Channel 2 = extra
// Channel 3 = extra
HSTREAM m_stream_list[4];
HSYNC loop_sync[4];
};
#endif // AOMUSICPLAYER_H