Refactor the way resources are loaded (#191)

* WIP

* WIP

* Font works

* WIP: Only Music remains

* Looks like it's working

* Fix oopsie

* Core/ObjectRef: Add cast functions

* Update ChangeLog.md

* Audio/SoundStream: Make sound stream thread-safe
This commit is contained in:
Jérôme Leclercq
2018-10-28 01:53:11 +02:00
committed by GitHub
parent fa7cbc21e5
commit ed46c87781
64 changed files with 1058 additions and 1071 deletions

View File

@@ -16,22 +16,22 @@ SCENARIO("Music", "[AUDIO][MUSIC]")
THEN("We can ask the informations of the file")
{
REQUIRE(music.GetDuration() <= 64000); // 1 min 03 = 63s = 63000ms
REQUIRE(music.GetDuration() >= 63000);
REQUIRE(music.GetFormat() == Nz::AudioFormat_Stereo);
REQUIRE(music.GetPlayingOffset() == 0);
REQUIRE(music.GetSampleCount() <= 5644800); // 64s * 44100 Hz * 2 (stereo)
REQUIRE(music.GetSampleCount() >= 5556600); // 63s * 44100 Hz * 2 (stereo)
REQUIRE(music.GetSampleRate() == 44100 /* Hz */);
REQUIRE(music.GetStatus() == Nz::SoundStatus_Stopped);
REQUIRE(music.IsLooping() == false);
CHECK(music.GetDuration() <= 64000); // 1 min 03 = 63s = 63000ms
CHECK(music.GetDuration() >= 63000);
CHECK(music.GetFormat() == Nz::AudioFormat_Stereo);
CHECK(music.GetPlayingOffset() == 0);
CHECK(music.GetSampleCount() <= 5644800); // 64s * 44100 Hz * 2 (stereo)
CHECK(music.GetSampleCount() >= 5556600); // 63s * 44100 Hz * 2 (stereo)
CHECK(music.GetSampleRate() == 44100 /* Hz */);
CHECK(music.GetStatus() == Nz::SoundStatus_Stopped);
CHECK(music.IsLooping() == false);
}
THEN("We can play it and get the time offset")
{
Nz::Audio::SetGlobalVolume(0.f);
music.Play();
music.Play();
Nz::Thread::Sleep(1000);
REQUIRE(music.GetPlayingOffset() >= 950);
Nz::Thread::Sleep(200);

View File

@@ -5,16 +5,15 @@ SCENARIO("SoundBuffer", "[AUDIO][SOUNDBUFFER]")
{
GIVEN("A sound buffer")
{
Nz::SoundBuffer soundBuffer;
WHEN("We load our sound")
{
REQUIRE(soundBuffer.LoadFromFile("resources/Engine/Audio/Cat.flac"));
Nz::SoundBufferRef soundBuffer = Nz::SoundBuffer::LoadFromFile("resources/Engine/Audio/Cat.flac");
REQUIRE(soundBuffer.IsValid());
THEN("We can ask the informations of the file")
{
REQUIRE(soundBuffer.GetDuration() <= 8500); // 8s = 8000ms
REQUIRE(soundBuffer.GetDuration() >= 8000);
REQUIRE(soundBuffer->GetDuration() <= 8500); // 8s = 8000ms
REQUIRE(soundBuffer->GetDuration() >= 8000);
}
}
}