samplebrain/samplebrain/src/brain.h

51 lines
1.2 KiB
C
Raw Normal View History

2015-07-08 04:08:49 -03:00
#include <vector>
2015-07-08 06:24:02 -03:00
#include <string>
#include "jellyfish/core/types.h"
#include "jellyfish/fluxa/sample.h"
2015-07-09 17:48:59 -03:00
#include "block.h"
2015-07-08 06:24:02 -03:00
#ifndef BRAIN
#define BRAIN
namespace spiralcore {
2015-07-08 04:08:49 -03:00
class brain {
public:
brain();
// rewrites whole brain
2015-07-09 18:59:44 -03:00
void init(u32 block_size, u32 overlap, u32 env, bool ditchpcm=false);
2015-07-08 04:08:49 -03:00
2015-07-08 06:24:02 -03:00
// load, chop up and add to brain
// todo: add tags
sample load_sound(std::string filename);
2015-07-08 04:08:49 -03:00
// take another brain and rebuild this brain from bits of that one
// (presumably this one is made from a single sample)
2015-07-09 20:11:12 -03:00
void resynth(const std::string &filename, const brain &other, float ratio, u32 fftwack);
2015-07-08 06:24:02 -03:00
2015-07-08 11:06:08 -03:00
const sample &get_block_pcm(u32 index) const;
2015-07-09 17:48:59 -03:00
const block &get_block(u32 index) const;
2015-07-09 18:59:44 -03:00
const u32 get_num_blocks() const { return m_blocks.size(); }
2015-07-09 17:48:59 -03:00
const u32 get_block_size() const { return m_block_size; }
const u32 get_overlap() const { return m_overlap; }
2015-07-09 12:16:36 -03:00
2015-07-09 20:11:12 -03:00
u32 search(const block &target, float ratio, u32 fftwack) const;
2015-07-09 12:16:36 -03:00
2015-07-08 06:24:02 -03:00
static bool unit_test();
2015-07-08 04:08:49 -03:00
private:
2015-07-09 18:59:44 -03:00
void chop_and_add(const sample &s, u32 block_size, u32 overlap, u32 env, bool ditchpcm=false);
2015-07-08 04:08:49 -03:00
2015-07-09 17:48:59 -03:00
vector<block> m_blocks;
2015-07-08 06:24:02 -03:00
vector<sample> m_samples;
2015-07-08 04:08:49 -03:00
2015-07-08 06:52:30 -03:00
u32 m_block_size;
u32 m_overlap;
2015-07-09 12:16:36 -03:00
2015-07-08 04:08:49 -03:00
};
2015-07-08 06:24:02 -03:00
}
2015-07-09 17:48:59 -03:00
#endif