add .opus support
This commit is contained in:
parent
963e321095
commit
a49c4a503b
@ -13,7 +13,6 @@ MOC_DIR = $$PWD/build
|
|||||||
SOURCES += $$files($$PWD/src/*.cpp)
|
SOURCES += $$files($$PWD/src/*.cpp)
|
||||||
HEADERS += $$files($$PWD/include/*.h)
|
HEADERS += $$files($$PWD/include/*.h)
|
||||||
|
|
||||||
|
|
||||||
LIBS += -L$$PWD/lib
|
LIBS += -L$$PWD/lib
|
||||||
|
|
||||||
DEFINES += DISCORD
|
DEFINES += DISCORD
|
||||||
@ -26,6 +25,7 @@ DEFINES += BASSAUDIO
|
|||||||
|
|
||||||
contains(DEFINES, BASSAUDIO) {
|
contains(DEFINES, BASSAUDIO) {
|
||||||
LIBS += -lbass
|
LIBS += -lbass
|
||||||
|
LIBS += -lbassopus
|
||||||
}
|
}
|
||||||
|
|
||||||
#DEFINES += QTAUDIO
|
#DEFINES += QTAUDIO
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#if defined(BASSAUDIO)
|
#if defined(BASSAUDIO)
|
||||||
#include "bass.h"
|
#include "bass.h"
|
||||||
|
#include "bassopus.h"
|
||||||
#elif defined(QTAUDIO)
|
#elif defined(QTAUDIO)
|
||||||
#include <QSoundEffect>
|
#include <QSoundEffect>
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#if defined(BASSAUDIO)
|
#if defined(BASSAUDIO)
|
||||||
#include "bass.h"
|
#include "bass.h"
|
||||||
|
#include "bassopus.h"
|
||||||
#elif defined(QTAUDIO)
|
#elif defined(QTAUDIO)
|
||||||
#include <QMediaPlayer>
|
#include <QMediaPlayer>
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#if defined(BASSAUDIO)
|
#if defined(BASSAUDIO)
|
||||||
#include "bass.h"
|
#include "bass.h"
|
||||||
|
#include "bassopus.h"
|
||||||
#elif defined(QTAUDIO)
|
#elif defined(QTAUDIO)
|
||||||
#include <QSoundEffect>
|
#include <QSoundEffect>
|
||||||
#endif
|
#endif
|
||||||
|
52
include/bassopus.h
Normal file
52
include/bassopus.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
BASSOPUS 2.4 C/C++ header file
|
||||||
|
Copyright (c) 2012-2015 Un4seen Developments Ltd.
|
||||||
|
|
||||||
|
See the BASSOPUS.CHM file for more detailed documentation
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BASSOPUS_H
|
||||||
|
#define BASSOPUS_H
|
||||||
|
|
||||||
|
#include "bass.h"
|
||||||
|
|
||||||
|
#if BASSVERSION!=0x204
|
||||||
|
#error conflicting BASS and BASSOPUS versions
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BASSOPUSDEF
|
||||||
|
#define BASSOPUSDEF(f) WINAPI f
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// BASS_CHANNELINFO type
|
||||||
|
#define BASS_CTYPE_STREAM_OPUS 0x11200
|
||||||
|
|
||||||
|
// Additional attributes
|
||||||
|
#define BASS_ATTRIB_OPUS_ORIGFREQ 0x13000
|
||||||
|
#define BASS_ATTRIB_OPUS_GAIN 0x13001
|
||||||
|
|
||||||
|
HSTREAM BASSOPUSDEF(BASS_OPUS_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags);
|
||||||
|
HSTREAM BASSOPUSDEF(BASS_OPUS_StreamCreateURL)(const char *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user);
|
||||||
|
HSTREAM BASSOPUSDEF(BASS_OPUS_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(_WIN32) && !defined(NOBASSOVERLOADS)
|
||||||
|
static inline HSTREAM BASS_OPUS_StreamCreateFile(BOOL mem, const WCHAR *file, QWORD offset, QWORD length, DWORD flags)
|
||||||
|
{
|
||||||
|
return BASS_OPUS_StreamCreateFile(mem, (const void*)file, offset, length, flags|BASS_UNICODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline HSTREAM BASS_OPUS_StreamCreateURL(const WCHAR *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user)
|
||||||
|
{
|
||||||
|
return BASS_OPUS_StreamCreateURL((const char*)url, offset, flags|BASS_UNICODE, proc, user);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -15,6 +15,9 @@ void AOBlipPlayer::set_blips(QString p_sfx)
|
|||||||
{
|
{
|
||||||
BASS_StreamFree(m_stream_list[n_stream]);
|
BASS_StreamFree(m_stream_list[n_stream]);
|
||||||
|
|
||||||
|
if (f_path.endsWith(".opus"))
|
||||||
|
m_stream_list[n_stream] = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
|
||||||
|
else
|
||||||
m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
|
m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +49,7 @@ void AOBlipPlayer::set_volume(qreal p_value)
|
|||||||
|
|
||||||
void AOBlipPlayer::set_volume_internal(qreal p_value)
|
void AOBlipPlayer::set_volume_internal(qreal p_value)
|
||||||
{
|
{
|
||||||
float volume = p_value;
|
float volume = static_cast<float>(p_value);
|
||||||
|
|
||||||
for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
|
for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,11 @@ void AOMusicPlayer::play(QString p_song, int channel, bool loop, int effect_flag
|
|||||||
if (loop)
|
if (loop)
|
||||||
flags |= BASS_SAMPLE_LOOP;
|
flags |= BASS_SAMPLE_LOOP;
|
||||||
|
|
||||||
DWORD newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags);
|
DWORD newstream;
|
||||||
|
if (f_path.endsWith(".opus"))
|
||||||
|
newstream = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags);
|
||||||
|
else
|
||||||
|
newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags);
|
||||||
|
|
||||||
if (ao_app->get_audio_output_device() != "default")
|
if (ao_app->get_audio_output_device() != "default")
|
||||||
BASS_ChannelSetDevice(m_stream_list[channel], BASS_GetDevice());
|
BASS_ChannelSetDevice(m_stream_list[channel], BASS_GetDevice());
|
||||||
|
@ -59,6 +59,9 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout, int channel
|
|||||||
if (!file_exists(f_path))
|
if (!file_exists(f_path))
|
||||||
f_path = ao_app->get_sfx_suffix(f_path); //If we're not given a sound file with .wav/.ogg/.opus already there, let's do this thing
|
f_path = ao_app->get_sfx_suffix(f_path); //If we're not given a sound file with .wav/.ogg/.opus already there, let's do this thing
|
||||||
|
|
||||||
|
if (f_path.endsWith(".opus"))
|
||||||
|
m_stream_list[channel] = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE);
|
||||||
|
else
|
||||||
m_stream_list[channel] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE);
|
m_stream_list[channel] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE);
|
||||||
|
|
||||||
set_volume_internal(m_volume);
|
set_volume_internal(m_volume);
|
||||||
|
Loading…
Reference in New Issue
Block a user