Skip to content
This repository has been archived by the owner on Oct 8, 2022. It is now read-only.

Commit

Permalink
example of how audio could be implemented (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladdeSV authored Nov 10, 2020
1 parent eb1092b commit f7d861d
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions source/scone/audio/audio.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
module scone.audio.audio;

interface StandardAudio
{

}

class DummyAudio : StandardAudio
{

}

alias AudioId = size_t;

class Audio
{
this(StandardAudio standardAudio)
{

}

AudioId register(string path)
{
this.tempAudioIdCounter++;
return tempAudioIdCounter;
}

AudioHandle play(AudioId id)
{
return new AudioHandle(id);
}

void stop(ref AudioHandle handle)
{
handle = null;
}

private uint tempAudioIdCounter;
}

class AudioHandle
{
this(AudioId id)
{
this.id = id;
}

private AudioId id;
}

unittest
{
auto standardAudio = new DummyAudio();
auto audio = new Audio(standardAudio);

auto audioId1 = audio.register("audio/snd1");
auto audioId2 = audio.register("audio/snd1");

assert(audioId1 != audioId2);

auto audioHandle1 = audio.play(audioId1);
assert(audioHandle1 !is null);

audio.stop(audioHandle1);
assert(audioHandle1 is null);
}

0 comments on commit f7d861d

Please sign in to comment.