load audio files
haldean
1 year, 10 months ago
1 | 1 |
src/ana.cpp \
|
2 | 2 |
src/font.gen.cpp \
|
3 | 3 |
src/node.cpp \
|
|
4 |
src/nodeui.cpp \
|
4 | 5 |
src/reallocarray.cpp \
|
5 | 6 |
src/ui.cpp \
|
6 | 7 |
src/viewport.cpp \
|
|
22 | 23 |
CXXFLAGS += -I lib/glew-2.1.0/include
|
23 | 24 |
CXXFLAGS += -I lib/glfw-3.2.1.bin.WIN64/include
|
24 | 25 |
CXXFLAGS += -I lib/glm
|
|
26 |
CXXFLAGS += -I lib/AudioFile
|
25 | 27 |
CXXFLAGS += -MD
|
26 | 28 |
CXXFLAGS += -ggdb
|
27 | 29 |
|
|
0 |
namespace ana {
|
|
1 |
struct audio_file {
|
|
2 |
|
|
3 |
};
|
|
4 |
}
|
0 | 0 |
#include "node.hpp"
|
|
1 |
#include "AudioFile.h"
|
1 | 2 |
|
2 | 3 |
namespace ana {
|
3 | 4 |
|
4 | 5 |
node::node(const std::string &n, node_type t) : _name(n), _type(t) {}
|
5 | 6 |
|
|
7 |
|
|
8 |
class audio_file : public AudioFile<float> {
|
|
9 |
using AudioFile::AudioFile;
|
|
10 |
};
|
|
11 |
|
6 | 12 |
audio_node::audio_node(const fs::path &path)
|
7 | 13 |
: node(path.filename(), ana::node_type::audio)
|
8 | 14 |
, _path(path)
|
9 | 15 |
{
|
|
16 |
_data.reset(new audio_file());
|
|
17 |
_loaded = _data->load(path.string());
|
10 | 18 |
}
|
11 | 19 |
|
|
20 |
audio_node::~audio_node() = default;
|
|
21 |
|
12 | 22 |
}
|
37 | 37 |
};
|
38 | 38 |
using node_ptr = std::shared_ptr<node>;
|
39 | 39 |
|
|
40 |
class audio_file;
|
40 | 41 |
struct audio_node : public node {
|
41 | 42 |
explicit audio_node(const fs::path &path);
|
42 | |
~audio_node() override = default;
|
|
43 |
~audio_node() override;
|
43 | 44 |
|
44 | 45 |
const fs::path &path() const {
|
45 | 46 |
return _path;
|
46 | 47 |
}
|
47 | 48 |
|
|
49 |
bool loaded() const {
|
|
50 |
return _loaded;
|
|
51 |
}
|
|
52 |
|
48 | 53 |
private:
|
49 | 54 |
const fs::path _path;
|
|
55 |
std::unique_ptr<audio_file> _data;
|
|
56 |
bool _loaded;
|
50 | 57 |
};
|
51 | 58 |
|
52 | 59 |
}
|
|
0 |
#include "nodeui.hpp"
|
|
1 |
|
|
2 |
#include "imgui.h"
|
|
3 |
|
|
4 |
namespace ana {
|
|
5 |
namespace nodeui {
|
|
6 |
|
|
7 |
void draw(const std::shared_ptr<ana::audio_node> &node)
|
|
8 |
{
|
|
9 |
if (not node->loaded()) {
|
|
10 |
ImGui::Text("failed to load file %s", node->path().c_str());
|
|
11 |
return;
|
|
12 |
}
|
|
13 |
ImGui::Text(node->path().c_str());
|
|
14 |
}
|
|
15 |
|
|
16 |
template <class To, class From>
|
|
17 |
std::shared_ptr<To> checked_cast(const std::shared_ptr<From> &p) {
|
|
18 |
const auto res = std::dynamic_pointer_cast<To>(p);
|
|
19 |
if (not res) {
|
|
20 |
throw ("bad cast to " + std::string(typeid(To).name()));
|
|
21 |
}
|
|
22 |
return res;
|
|
23 |
}
|
|
24 |
|
|
25 |
void draw(const ana::node_ptr &node)
|
|
26 |
{
|
|
27 |
switch (node->type()) {
|
|
28 |
case ana::node_type::audio:
|
|
29 |
draw(checked_cast<ana::audio_node>(node));
|
|
30 |
return;
|
|
31 |
case ana::node_type::midi:
|
|
32 |
ImGui::Text("no drawing for midi nodes yet");
|
|
33 |
break;
|
|
34 |
case ana::node_type::osc:
|
|
35 |
ImGui::Text("no drawing for osc nodes yet");
|
|
36 |
break;
|
|
37 |
}
|
|
38 |
}
|
|
39 |
|
|
40 |
} // nodeui
|
|
41 |
} // ana
|
|
0 |
#include "node.hpp"
|
|
1 |
|
|
2 |
namespace ana {
|
|
3 |
namespace nodeui {
|
|
4 |
void draw(const ana::node_ptr &node);
|
|
5 |
}
|
|
6 |
}
|