Skip to content

Commit cbfe3f2

Browse files
authored
Merge pull request #40 from neogeek/feature/switch-to-headers-only-library
[feat] Switched to a header only library.
2 parents c824804 + 9d148c3 commit cbfe3f2

File tree

13 files changed

+310
-380
lines changed

13 files changed

+310
-380
lines changed

bin/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ COLOROFF=$(tput sgr0)
1818

1919
printf " - Running %s " "${FILE}"
2020

21-
if ! g++ -std=c++17 -o test "${FILE}" ./includes/RhythmGameUtilities/RhythmGameUtilities.cpp -Iincludes; then
21+
if ! g++ -std=c++17 -o test "${FILE}" -Iincludes; then
2222
printf "%sCOMPILATION FAILED%s\n" "${REDON}" "${COLOROFF}"
2323
exit 1
2424
fi

includes/RhythmGameUtilities/Audio.cpp

Lines changed: 0 additions & 53 deletions
This file was deleted.

includes/RhythmGameUtilities/Audio.h

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#pragma once
2+
3+
#include <cmath>
4+
5+
#ifdef _WIN32
6+
#define PACKAGE_API __declspec(dllexport)
7+
#else
8+
#define PACKAGE_API
9+
#endif
10+
11+
namespace RhythmGameUtilities
12+
{
13+
14+
extern "C"
15+
{
16+
PACKAGE_API int **ConvertSamplesToWaveform(float *samples, int size,
17+
int width, int height)
18+
{
19+
auto waveform = new int *[width];
20+
21+
auto step = floor(size / width);
22+
auto amp = height / 2;
23+
24+
for (auto x = 0; x < width; x += 1)
25+
{
26+
waveform[x] = new int[height];
27+
28+
auto min = 1.0f;
29+
auto max = -1.0f;
30+
31+
for (auto j = 0; j < step; j += 1)
32+
{
33+
auto index = (int)(x * step + j);
34+
35+
auto datum = samples[index];
36+
37+
if (datum < min)
38+
{
39+
min = datum;
40+
}
41+
42+
if (datum > max)
43+
{
44+
max = datum;
45+
}
46+
}
47+
48+
auto minY = (int)((1 + min) * amp);
49+
auto maxY = (int)((1 + max) * amp);
50+
51+
for (auto y = 0; y < height; y += 1)
52+
{
53+
waveform[x][y] = y >= minY && y <= maxY ? 1 : 0;
54+
}
55+
}
56+
57+
return waveform;
58+
}
59+
}
60+
61+
} // namespace RhythmGameUtilities

includes/RhythmGameUtilities/Parsers.cpp

Lines changed: 0 additions & 114 deletions
This file was deleted.

includes/RhythmGameUtilities/Parsers.h

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)