samplebrain/app/process_thread.h

73 lines
2.0 KiB
C
Raw Normal View History

2022-09-08 08:21:53 -03:00
// Copyright (C) 2022 Then Try This
2015-07-21 10:58:13 -03:00
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2022-09-04 07:38:20 -03:00
#include "spiralcore/OSC_server.h"
2015-07-11 15:03:05 -03:00
#include "brain.h"
#include "renderer.h"
2016-07-08 07:41:30 -03:00
#include "block_stream.h"
2016-09-24 06:41:10 -03:00
#define HAVE_STRUCT_TIMESPEC
2015-07-11 15:03:05 -03:00
#include <pthread.h>
#pragma once
namespace spiralcore {
class process_thread {
public:
process_thread(const string &port);
~process_thread();
2015-07-11 15:03:05 -03:00
pthread_mutex_t* m_brain_mutex;
2016-07-08 07:41:30 -03:00
void register_renderer(renderer *lr, renderer *rr, block_stream *bs) {
2016-02-03 13:45:09 -02:00
m_left_renderer=lr;
m_right_renderer=rr;
2016-07-08 07:41:30 -03:00
m_block_stream=bs;
m_block_stream->init(m_target_block_size, m_target_overlap, m_target_window_type);
2016-02-03 13:45:09 -02:00
}
2015-07-11 17:30:16 -03:00
void process();
2015-08-04 06:14:06 -03:00
void load_source(const std::string &filename);
void save_source(const std::string &filename);
2015-10-16 12:23:51 -03:00
void load_session(const std::string &filename);
void save_session(const std::string &filename);
2015-08-04 06:14:06 -03:00
bool ok() { return m_osc.ok(); }
// only for use in mutex
2016-02-03 13:45:09 -02:00
brain m_source, m_left_target, m_right_target;
private:
2015-07-11 15:03:05 -03:00
OSC_server m_osc;
2015-07-11 17:30:16 -03:00
u32 m_source_block_size;
float m_source_overlap;
u32 m_target_block_size;
float m_target_overlap;
2015-07-18 20:34:56 -03:00
window::type m_window_type;
window::type m_target_window_type;
pthread_t *m_thread;
// only use in mutex obvs...
2016-02-03 13:45:09 -02:00
renderer *m_left_renderer;
renderer *m_right_renderer;
2016-07-08 07:41:30 -03:00
block_stream *m_block_stream;
};
2015-07-11 15:03:05 -03:00
}