From 3c0cedbe922c9fcacd0d171423f83e375f66e178 Mon Sep 17 00:00:00 2001 From: iamgoofball Date: Fri, 18 Jan 2019 19:08:56 -0800 Subject: Add screenshake, frame-specific effects, looping SFX, and clientside music looping Committed by patch since Goof is currently banned on GitHub for no good reason. --- src/aomusicplayer.cpp | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'src/aomusicplayer.cpp') diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp index 997d82d..a52603c 100644 --- a/src/aomusicplayer.cpp +++ b/src/aomusicplayer.cpp @@ -1,21 +1,25 @@ #include "aomusicplayer.h" -AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app) + +AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app): QObject() { m_parent = parent; ao_app = p_ao_app; + music_loop_timer = new QTimer(this); + music_loop_timer->setSingleShot(true); + connect(music_loop_timer, SIGNAL(timeout()), this, SLOT(restart_loop())); } AOMusicPlayer::~AOMusicPlayer() { - BASS_ChannelStop(m_stream); + kill_loop(); } void AOMusicPlayer::play(QString p_song) { BASS_ChannelStop(m_stream); - QString f_path = ao_app->get_music_path(p_song); + f_path = ao_app->get_music_path(p_song); m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE); @@ -24,6 +28,15 @@ void AOMusicPlayer::play(QString p_song) if (ao_app->get_audio_output_device() != "default") BASS_ChannelSetDevice(m_stream, BASS_GetDevice()); BASS_ChannelPlay(m_stream, false); + music_loop_timer->stop(); + QWORD len=BASS_ChannelGetLength(m_stream, BASS_POS_BYTE); // the length in bytes + double time=BASS_ChannelBytes2Seconds(m_stream, len); // the length in seconds + if(time > 0) + { + qDebug() << "Will loop in " << time << " seconds."; + music_loop_timer->start(time*1000); + } + } void AOMusicPlayer::set_volume(int p_value) @@ -32,3 +45,28 @@ void AOMusicPlayer::set_volume(int p_value) float volume = m_volume / 100.0f; BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume); } + +QString AOMusicPlayer::get_path() +{ + return f_path; +} + +void AOMusicPlayer::restart_loop() +{ + qDebug() << "Restarting Music"; + /* + m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE); + if (ao_app->get_audio_output_device() != "default") + BASS_ChannelSetDevice(m_stream, BASS_GetDevice());*/ + QWORD len=BASS_ChannelGetLength(m_stream, BASS_POS_BYTE); // the length in bytes + double time=BASS_ChannelBytes2Seconds(m_stream, len); // the length in seconds + music_loop_timer->start(time*1000); + BASS_ChannelPlay(m_stream, true); +} + +void AOMusicPlayer::kill_loop() +{ + music_loop_timer->stop(); + BASS_ChannelStop(m_stream); +} + -- cgit From 10436992148e2342e6bd563d1acfb684f225aa30 Mon Sep 17 00:00:00 2001 From: iamgoofball Date: Sat, 19 Jan 2019 21:01:19 -0800 Subject: Suffix-independent Music, Mod Music List, looping bugfixes, easter eggs, etc. --- src/aomusicplayer.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/aomusicplayer.cpp') diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp index a52603c..2a35f0b 100644 --- a/src/aomusicplayer.cpp +++ b/src/aomusicplayer.cpp @@ -29,14 +29,18 @@ void AOMusicPlayer::play(QString p_song) BASS_ChannelSetDevice(m_stream, BASS_GetDevice()); BASS_ChannelPlay(m_stream, false); music_loop_timer->stop(); - QWORD len=BASS_ChannelGetLength(m_stream, BASS_POS_BYTE); // the length in bytes - double time=BASS_ChannelBytes2Seconds(m_stream, len); // the length in seconds - if(time > 0) + if(enable_looping) { - qDebug() << "Will loop in " << time << " seconds."; - music_loop_timer->start(time*1000); + QWORD len=BASS_ChannelGetLength(m_stream, BASS_POS_BYTE); // the length in bytes + double time=BASS_ChannelBytes2Seconds(m_stream, len); // the length in seconds + if(time > 0) + { + qDebug() << "Will loop in " << time << " seconds."; + music_loop_timer->start(time*1000); + } } + } void AOMusicPlayer::set_volume(int p_value) -- cgit From 0649e7b28e16a054072d8656a5046c7cc3cfefb6 Mon Sep 17 00:00:00 2001 From: iamgoofball Date: Wed, 23 Jan 2019 07:35:29 -0800 Subject: Case Announcer: Witness Support also some other shit --- src/aomusicplayer.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/aomusicplayer.cpp') diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp index 2a35f0b..fca3c16 100644 --- a/src/aomusicplayer.cpp +++ b/src/aomusicplayer.cpp @@ -35,7 +35,6 @@ void AOMusicPlayer::play(QString p_song) double time=BASS_ChannelBytes2Seconds(m_stream, len); // the length in seconds if(time > 0) { - qDebug() << "Will loop in " << time << " seconds."; music_loop_timer->start(time*1000); } } @@ -57,7 +56,6 @@ QString AOMusicPlayer::get_path() void AOMusicPlayer::restart_loop() { - qDebug() << "Restarting Music"; /* m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE); if (ao_app->get_audio_output_device() != "default") -- cgit From fc984fcfe2a4416274810de81a8f36fe77b0dba9 Mon Sep 17 00:00:00 2001 From: iamgoofball Date: Fri, 1 Feb 2019 16:28:14 -0800 Subject: bugfixes and shit --- src/aomusicplayer.cpp | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'src/aomusicplayer.cpp') diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp index fca3c16..7fcb277 100644 --- a/src/aomusicplayer.cpp +++ b/src/aomusicplayer.cpp @@ -5,9 +5,6 @@ AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app): QObject( { m_parent = parent; ao_app = p_ao_app; - music_loop_timer = new QTimer(this); - music_loop_timer->setSingleShot(true); - connect(music_loop_timer, SIGNAL(timeout()), this, SLOT(restart_loop())); } AOMusicPlayer::~AOMusicPlayer() @@ -27,17 +24,16 @@ void AOMusicPlayer::play(QString p_song) if (ao_app->get_audio_output_device() != "default") BASS_ChannelSetDevice(m_stream, BASS_GetDevice()); - BASS_ChannelPlay(m_stream, false); - music_loop_timer->stop(); if(enable_looping) { - QWORD len=BASS_ChannelGetLength(m_stream, BASS_POS_BYTE); // the length in bytes - double time=BASS_ChannelBytes2Seconds(m_stream, len); // the length in seconds - if(time > 0) - { - music_loop_timer->start(time*1000); - } + BASS_ChannelFlags(m_stream, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP); + } + else + { + BASS_ChannelFlags(m_stream, 0, BASS_SAMPLE_LOOP); } + BASS_ChannelPlay(m_stream, false); + } @@ -54,21 +50,8 @@ QString AOMusicPlayer::get_path() return f_path; } -void AOMusicPlayer::restart_loop() -{ - /* - m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE); - if (ao_app->get_audio_output_device() != "default") - BASS_ChannelSetDevice(m_stream, BASS_GetDevice());*/ - QWORD len=BASS_ChannelGetLength(m_stream, BASS_POS_BYTE); // the length in bytes - double time=BASS_ChannelBytes2Seconds(m_stream, len); // the length in seconds - music_loop_timer->start(time*1000); - BASS_ChannelPlay(m_stream, true); -} - void AOMusicPlayer::kill_loop() { - music_loop_timer->stop(); BASS_ChannelStop(m_stream); } -- cgit