Last change
on this file since 1687 was
686,
checked in by sam, 10 years ago
|
Put everything in the "lol" namespace. Better late than never.
|
-
Property svn:keywords set to
Id
|
File size:
1.2 KB
|
Line | |
---|
1 | // |
---|
2 | // Lol Engine |
---|
3 | // |
---|
4 | // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> |
---|
5 | // This program is free software; you can redistribute it and/or |
---|
6 | // modify it under the terms of the Do What The Fuck You Want To |
---|
7 | // Public License, Version 2, as published by Sam Hocevar. See |
---|
8 | // http://sam.zoy.org/projects/COPYING.WTFPL for more details. |
---|
9 | // |
---|
10 | |
---|
11 | #if defined HAVE_CONFIG_H |
---|
12 | # include "config.h" |
---|
13 | #endif |
---|
14 | |
---|
15 | #include "core.h" |
---|
16 | |
---|
17 | namespace lol |
---|
18 | { |
---|
19 | |
---|
20 | /* |
---|
21 | * Sampler implementation class |
---|
22 | */ |
---|
23 | |
---|
24 | static class SamplerData |
---|
25 | { |
---|
26 | friend class Sampler; |
---|
27 | |
---|
28 | public: |
---|
29 | Dict samples; |
---|
30 | } |
---|
31 | samplerdata; |
---|
32 | |
---|
33 | static SamplerData * const data = &samplerdata; |
---|
34 | |
---|
35 | /* |
---|
36 | * Public Sampler class |
---|
37 | */ |
---|
38 | |
---|
39 | int Sampler::Register(char const *path) |
---|
40 | { |
---|
41 | int id = data->samples.MakeSlot(path); |
---|
42 | |
---|
43 | if (!data->samples.GetEntity(id)) |
---|
44 | { |
---|
45 | Sample *sample = new Sample(path); |
---|
46 | data->samples.SetEntity(id, sample); |
---|
47 | } |
---|
48 | |
---|
49 | return id + 1; /* ID 0 is for the empty sample */ |
---|
50 | } |
---|
51 | |
---|
52 | void Sampler::Deregister(int id) |
---|
53 | { |
---|
54 | data->samples.RemoveSlot(id - 1); /* ID 0 is for the empty sample */ |
---|
55 | } |
---|
56 | |
---|
57 | void Sampler::PlaySample(int id) |
---|
58 | { |
---|
59 | Sample *sample = (Sample *)data->samples.GetEntity(id - 1); |
---|
60 | sample->Play(); |
---|
61 | } |
---|
62 | |
---|
63 | } /* namespace lol */ |
---|
64 | |
---|
Note: See
TracBrowser
for help on using the repository browser.