diff --git a/include/ReMixer/sound.h b/include/ReMixer/sound.h index 1bc5a01..48e84f0 100644 --- a/include/ReMixer/sound.h +++ b/include/ReMixer/sound.h @@ -81,6 +81,7 @@ namespace ReMixer { /// Returns the samples-per-second of this sound. uint SampleRate() const { return sample_rate;} + /// Returns a pointer to the beginning of the audio data char* ptr() { return audio_data.data();} [[nodiscard]] const char* ptr() const { return audio_data.data();} diff --git a/main.cpp b/main.cpp index a025e33..05808d1 100644 --- a/main.cpp +++ b/main.cpp @@ -21,6 +21,8 @@ [[noreturn]] int main() { + + using namespace ReMixer; using namespace std::chrono_literals; @@ -31,17 +33,21 @@ PulseStream test_stream = test.CreateStream("Test Stream"); PulseStream test_stream2 = test.CreateStream("Another Test Stream"); - Sound test_sound = Sound::FromPCMFile("output.raw"); - Sound ogg_test_sound = Sound::FromOGGVorbisFile("song.ogg"); + Sound test_sound = Sound::FromPCMFile("wind.raw"); + Sound ogg_test_sound = Sound::FromOGGVorbisFile("wind.ogg"); + + std::thread playback_thread([](PulseAudioSubsystem system, PulseStream stream, Sound sound){ + system.Play(stream, sound); + }, test, test_stream, ogg_test_sound); + + playback_thread.join(); + + playback_thread.detach(); + - test.Play(test_stream, test_sound); //test.Play(test_stream2, ogg_test_sound); - std::cout << "This text will print after the sound plays>" << std::endl; - while(true) - { - //std::this_thread::sleep_for(25ms); - } + std::cout << "This text will print after the sound plays." << std::endl; return 0; }