1 //-----------------------------------------------------------------------------
2 // Copyright (c) 2015-2018 Marcelo Fernandez
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to
6 // deal in the Software without restriction, including without limitation the
7 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 // sell copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 // IN THE SOFTWARE.
21 //-----------------------------------------------------------------------------
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26
27 #include "oamlCommon.h"
28
oamlApi()29 oamlApi::oamlApi() {
30 oaml = new oamlBase();
31 oamlStudio = NULL;
32 }
33
~oamlApi()34 oamlApi::~oamlApi() {
35 delete oaml;
36
37 if (oamlStudio) {
38 delete oamlStudio;
39 oamlStudio = NULL;
40 }
41 }
42
GetVersion()43 const char* oamlApi::GetVersion() {
44 return oaml->GetVersion();
45 }
46
InitAudioDevice(int sampleRate,int channels)47 oamlRC oamlApi::InitAudioDevice(int sampleRate, int channels) {
48 return oaml->InitAudioDevice(sampleRate, channels);
49 }
50
Init(const char * defsFilename)51 oamlRC oamlApi::Init(const char *defsFilename) {
52 return oaml->Init(defsFilename);
53 }
54
ReadDefsFile(const char * defsFilename)55 oamlRC oamlApi::ReadDefsFile(const char *defsFilename) {
56 return oaml->ReadDefsFile(defsFilename);
57 }
58
InitString(const char * defs)59 oamlRC oamlApi::InitString(const char *defs) {
60 return oaml->InitString(defs);
61 }
62
SetAudioFormat(int sampleRate,int channels,int bytesPerSample,bool floatBuffer)63 void oamlApi::SetAudioFormat(int sampleRate, int channels, int bytesPerSample, bool floatBuffer) {
64 oaml->SetAudioFormat(sampleRate, channels, bytesPerSample, floatBuffer);
65 }
66
PlayTrack(const char * name)67 oamlRC oamlApi::PlayTrack(const char *name) {
68 return oaml->PlayTrack(name);
69 }
70
PlayTrackWithStringRandom(const char * str)71 oamlRC oamlApi::PlayTrackWithStringRandom(const char *str) {
72 return oaml->PlayTrackWithStringRandom(str);
73 }
74
PlayTrackByGroupRandom(const char * group)75 oamlRC oamlApi::PlayTrackByGroupRandom(const char *group) {
76 return oaml->PlayTrackByGroupRandom(group);
77 }
78
PlayTrackByGroupAndSubgroupRandom(const char * group,const char * subgroup)79 oamlRC oamlApi::PlayTrackByGroupAndSubgroupRandom(const char *group, const char *subgroup) {
80 return oaml->PlayTrackByGroupAndSubgroupRandom(group, subgroup);
81 }
82
PlaySfx(const char * name)83 oamlRC oamlApi::PlaySfx(const char *name) {
84 return oaml->PlaySfx(name);
85 }
86
PlaySfxEx(const char * name,float vol,float pan)87 oamlRC oamlApi::PlaySfxEx(const char *name, float vol, float pan) {
88 return oaml->PlaySfxEx(name, vol, pan);
89 }
90
PlaySfx2d(const char * name,int x,int y,int width,int height)91 oamlRC oamlApi::PlaySfx2d(const char *name, int x, int y, int width, int height) {
92 return oaml->PlaySfx2d(name, x, y, width, height);
93 }
94
LoadTrack(const char * name)95 oamlRC oamlApi::LoadTrack(const char *name) {
96 return oaml->LoadTrack(name);
97 }
98
LoadTrackProgress(const char * name)99 float oamlApi::LoadTrackProgress(const char *name) {
100 return oaml->LoadTrackProgress(name);
101 }
102
IsTrackPlaying(const char * name)103 bool oamlApi::IsTrackPlaying(const char *name) {
104 return oaml->IsTrackPlaying(name);
105 }
106
IsPlaying()107 bool oamlApi::IsPlaying() {
108 return oaml->IsPlaying();
109 }
110
StopPlaying()111 void oamlApi::StopPlaying() {
112 oaml->StopPlaying();
113 }
114
Pause()115 void oamlApi::Pause() {
116 oaml->Pause();
117 }
118
Resume()119 void oamlApi::Resume() {
120 oaml->Resume();
121 }
122
PauseToggle()123 void oamlApi::PauseToggle() {
124 oaml->PauseToggle();
125 }
126
IsPaused()127 bool oamlApi::IsPaused() {
128 return oaml->IsPaused();
129 }
130
MixToBuffer(void * buffer,int size)131 void oamlApi::MixToBuffer(void *buffer, int size) {
132 oaml->MixToBuffer(buffer, size);
133 }
134
SetCondition(int id,int value)135 void oamlApi::SetCondition(int id, int value) {
136 oaml->SetCondition(id, value);
137 }
138
ClearConditions()139 void oamlApi::ClearConditions() {
140 oaml->ClearConditions();
141 }
142
SetVolume(float vol)143 void oamlApi::SetVolume(float vol) {
144 oaml->SetVolume(vol);
145 }
146
GetVolume()147 float oamlApi::GetVolume() {
148 return oaml->GetVolume();
149 }
150
AddTension(int value)151 void oamlApi::AddTension(int value) {
152 oaml->AddTension(value);
153 }
154
SetTension(int value)155 void oamlApi::SetTension(int value) {
156 oaml->SetTension(value);
157 }
158
GetTension()159 int oamlApi::GetTension() {
160 return oaml->GetTension();
161 }
162
SetMainLoopCondition(int value)163 void oamlApi::SetMainLoopCondition(int value) {
164 oaml->SetMainLoopCondition(value);
165 }
166
SetLayerGain(const char * layer,float gain)167 void oamlApi::SetLayerGain(const char *layer, float gain) {
168 oaml->SetLayerGain(layer, gain);
169 }
170
GetLayerGain(const char * layer)171 float oamlApi::GetLayerGain(const char *layer) {
172 return oaml->GetLayerGain(layer);
173 }
174
SetLayerRandomChance(const char * layer,int randomChance)175 void oamlApi::SetLayerRandomChance(const char *layer, int randomChance) {
176 oaml->SetLayerRandomChance(layer, randomChance);
177 }
178
GetLayerRandomChance(const char * layer)179 int oamlApi::GetLayerRandomChance(const char *layer) {
180 return oaml->GetLayerRandomChance(layer);
181 }
182
Update()183 void oamlApi::Update() {
184 oaml->Update();
185 }
186
SetDebugClipping(bool option)187 void oamlApi::SetDebugClipping(bool option) {
188 oaml->SetDebugClipping(option);
189 }
190
SetWriteAudioAtShutdown(bool option)191 void oamlApi::SetWriteAudioAtShutdown(bool option) {
192 oaml->SetWriteAudioAtShutdown(option);
193 }
194
SetFileCallbacks(oamlFileCallbacks * cbs)195 void oamlApi::SetFileCallbacks(oamlFileCallbacks *cbs) {
196 oaml->SetFileCallbacks(cbs);
197 }
198
EnableDynamicCompressor(bool enable,double threshold,double ratio)199 void oamlApi::EnableDynamicCompressor(bool enable, double threshold, double ratio) {
200 oaml->EnableDynamicCompressor(enable, threshold, ratio);
201 }
202
GetTracksInfo()203 oamlTracksInfo* oamlApi::GetTracksInfo() {
204 return oaml->GetTracksInfo();
205 }
206
GetDefsFile()207 const char* oamlApi::GetDefsFile() {
208 return oaml->GetDefsFile();
209 }
210
GetPlayingInfo()211 const char* oamlApi::GetPlayingInfo() {
212 return oaml->GetPlayingInfo();
213 }
214
SaveState()215 std::string oamlApi::SaveState() {
216 return oaml->SaveState();
217 }
218
LoadState(std::string state)219 void oamlApi::LoadState(std::string state) {
220 oaml->LoadState(state);
221 }
222
Shutdown()223 void oamlApi::Shutdown() {
224 oaml->Shutdown();
225 }
226
GetStudioApi()227 oamlStudioApi* oamlApi::GetStudioApi() {
228 if (oamlStudio == NULL) {
229 oamlStudio = new oamlStudioApi(oaml);
230 }
231
232 return oamlStudio;
233 }
234