Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
SirBob01 committed Sep 23, 2024
1 parent 7a6fe33 commit 55f81f9
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
43 changes: 43 additions & 0 deletions src/Sound/Filters/FilterGraph.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#pragma once

#include <functional>

#include "../Filter.hpp"
#include "../Listener.hpp"
#include "../Sound.hpp"

namespace Dynamo::Sound {
/**
* @brief Audio filter graph.
*
* Multiple sources, single sink.
*
* TODO: Implement this
*
*/
class FilterGraph : public Filter {
std::vector<FilterRef> _nodes;
std::unordered_map<unsigned, std::vector<unsigned>> _adjacency;

public:
Sound &apply(Sound &src,
const unsigned src_offset,
const unsigned length,
const Material &material,
const ListenerProperties &listener) override;

/**
* @brief Add an edge to the filter graph.
*
* @param from
* @param to
*/
void add_edge(Filter &from, Filter &to);
};

/**
* @brief Filter graph reference.
*
*/
using FilterGraphRef = std::reference_wrapper<FilterGraph>;
} // namespace Dynamo::Sound
11 changes: 9 additions & 2 deletions src/Sound/Filters/FilterGraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,25 @@ namespace Dynamo::Sound {
*
* Multiple sources, single sink.
*
* TODO: Implement this
*
*/
class FilterGraph : public Filter {
std::vector<FilterRef> _nodes;
std::unordered_map<unsigned, std::vector<unsigned>> _adjacency;

public:
Sound &apply(Sound &src,
const unsigned src_offset,
const unsigned length,
const Material &material,
const ListenerProperties &listener) override;

/**
* @brief Add an edge to the filter graph.
*
* @param from
* @param to
*/
void add_edge(Filter &from, Filter &to);
};

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Sound/Jukebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ namespace Dynamo::Sound {
const PaStreamCallbackTimeInfo *time_info,
PaStreamCallbackFlags status_flags,
void *data) {
State &state = *static_cast<State *>(data);
state.buffer.write(static_cast<const WaveSample *>(input),
frame_count * state.channels);
State *state = static_cast<State *>(data);
state->buffer.write(static_cast<const WaveSample *>(input),
frame_count * state->channels);
return 0;
}

Expand All @@ -87,9 +87,9 @@ namespace Dynamo::Sound {
const PaStreamCallbackTimeInfo *time_info,
PaStreamCallbackFlags status_flags,
void *data) {
State &state = *static_cast<State *>(data);
state.buffer.read(static_cast<WaveSample *>(output),
frame_count * state.channels);
State *state = static_cast<State *>(data);
state->buffer.read(static_cast<WaveSample *>(output),
frame_count * state->channels);
return 0;
}

Expand Down

0 comments on commit 55f81f9

Please sign in to comment.