diff --git a/src/chain.c b/src/chain.c new file mode 100644 index 0000000..b4233ae --- /dev/null +++ b/src/chain.c @@ -0,0 +1,21 @@ +/////////////////////////////////////////////////////////////////////////////// +// Tyler Perkins +// 9-29-21 +// Markov chain implementation +// + +#include "chain.h" + +m_node* m_next(const m_node* rhs){ + uint16_t total = 0; + int i = 0; + + uint16_t v = rand() % (sizeof(uint16_t) * 8); + + while(v > total){ + total += rhs->_conns[i]._probability; + ++i; + } + + return rhs->_conns[i]._node; +} diff --git a/src/chain.h b/src/chain.h new file mode 100644 index 0000000..eb2f196 --- /dev/null +++ b/src/chain.h @@ -0,0 +1,39 @@ +/////////////////////////////////////////////////////////////////////////////// +// Tyler Perkins +// 9-29-21 +// Markov chain def +// + +#ifndef _MARKOV_H_ +#define _MARKOV_H_ + +#include +#include +#include + +enum chord { + one = 0x01, + two = 0x02, + three = 0x04, + four = 0x08, + five = 0x10, + six = 0x20, + seven = 0x40, +}; + +// probability out of the size of a short +struct m_conn { + uint16_t _probability; + struct m_conn* _node; +}; + +struct m_node { + enum chord _chord; + struct m_conn* _conns; +}; +typedef struct m_node m_node; + +// get next node, respecting probability +m_node* m_next(const m_node*); + +#endif //!_MARKOV_H_ diff --git a/src/main.c b/src/main.c index 2469c2c..6d23371 100644 --- a/src/main.c +++ b/src/main.c @@ -6,6 +6,18 @@ #include -int main(int argc, char** argv){ - printf("Hello World!\n"); +#include "chain.h" + +#define NOTE_COUNT 7 + +// sample version of how to progress +m_node* init(){ + m_node* nodes = (m_node*)malloc(sizeof(m_node) * NOTE_COUNT); + + + +} + +int main(int argc, char** argv){ + }