From 820a9209a9d7cb84c058127dc2584833621011ce Mon Sep 17 00:00:00 2001 From: sigonasr2 <sigonasr2@gmail.com> Date: Sat, 10 Aug 2024 19:24:55 -0500 Subject: [PATCH 1/2] Fix GetCursorMilliseconds(). Add a display line in the demo that shows cursor position in milliseconds. --- demo/demo.cpp | 9 +++++++++ olcPGEX_MiniAudio.h | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/demo/demo.cpp b/demo/demo.cpp index b9269b3..5d82311 100644 --- a/demo/demo.cpp +++ b/demo/demo.cpp @@ -110,6 +110,10 @@ class Demo : public olc::PixelGameEngine // returns float 0.0 to 1.0, nearer 1.0 is near the end seek = ma.GetCursorFloat(song1); + // Gets the current playback position in the provided sample ID (int), + // returns unsigned long long in milliseconds + cursor=ma.GetCursorMilliseconds(song1); + // Draw Instructions and Indicators Clear(olc::BLACK); @@ -137,6 +141,10 @@ class Demo : public olc::PixelGameEngine DrawStringDecal((center - olc::vi2d{0, 24}) - (olc::vf2d(GetTextSize(ma.name + " Demo")) * scale / 2.0f), ma.name + " Demo", olc::WHITE, {scale, scale}); DrawStringDecal(center - (GetTextSize("Hit <SPACE> To Toggle Playback") / 2), "Hit <SPACE> To Toggle Playback", olc::WHITE); DrawStringDecal((center + olc::vi2d{0, 16}) - (GetTextSize("Hit <R> TO Reset Pan/Pitch/Volume") / 2), "Hit <R> TO Reset Pan/Pitch/Volume", olc::WHITE); + + DrawStringDecal({5, 144}, \ + "Cursor (ms): " + std::to_string(cursor), + olc::WHITE, {0.5f, 0.5f}); DrawStringDecal({5, 160}, \ "Music: Joy Ride [Full version] by MusicLFiles\n" @@ -167,6 +175,7 @@ class Demo : public olc::PixelGameEngine float volume = 1.0f; float distance = 0.0f; bool backgroundPlay = false; + unsigned long long cursor = 0ull; }; diff --git a/olcPGEX_MiniAudio.h b/olcPGEX_MiniAudio.h index 8e1e95c..aeceb48 100644 --- a/olcPGEX_MiniAudio.h +++ b/olcPGEX_MiniAudio.h @@ -429,9 +429,9 @@ namespace olc { unsigned long long cursor; ma_sound_get_cursor_in_pcm_frames(vecSounds.at(id), &cursor); - + + cursor *= 1000; cursor /= sampleRate; - cursor /= 1000; return cursor; } From aba647f5504856ac79028f1a1751aae39c35768f Mon Sep 17 00:00:00 2001 From: Moros Smith <moros1138@gmail.com> Date: Sat, 10 Aug 2024 20:43:03 -0400 Subject: [PATCH 2/2] bump version --- olcPGEX_MiniAudio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/olcPGEX_MiniAudio.h b/olcPGEX_MiniAudio.h index aeceb48..7f71a39 100644 --- a/olcPGEX_MiniAudio.h +++ b/olcPGEX_MiniAudio.h @@ -4,7 +4,7 @@ +-------------------------------------------------------------+ | OneLoneCoder Pixel Game Engine Extension | - | MiniAudio v1.5 | + | MiniAudio v1.6 | +-------------------------------------------------------------+ NOTE: UNDER ACTIVE DEVELOPMENT - THERE MAY BE BUGS/GLITCHES @@ -68,7 +68,7 @@ namespace olc class MiniAudio : public olc::PGEX { public: - std::string name = "olcPGEX_MiniAudio v1.5"; + std::string name = "olcPGEX_MiniAudio v1.6"; public: MiniAudio();