basic-oscillators.c

Header.

/*
==============================================================================
basic-oscillators.h
Created: 5 Mar 2020 2:56:24pm
Author: Matthew Wang
==============================================================================
*/
#include "../leaf/leaf.h"
char mempool[1000];
tCycle cycle;
void exampleInit(void);
void exampleFrame(void);
float exampleTick(float sampleIn);
float exampleRandom(void);

An example.

/*
==============================================================================
basic-oscillators.c
Created: 5 Mar 2020 2:56:24pm
Author: Matthew Wang
==============================================================================
*/
#include "basic-oscillators.h"
void exampleInit()
{
LEAF leaf;
LEAF_init(&leaf, 44100, 128, mempool, 1000, &exampleRandom);
tCycle_init(&cycle, &leaf);
tCycle_setFreq(&cycle, 220);
}
void exampleFrame()
{
}
float exampleTick(float sampleIn)
{
float sampleOut = tCycle_tick(&cycle);
return sampleOut;
}
float exampleRandom()
{
return ((float)rand()/(float)(RAND_MAX));
}
tCycle_init
void tCycle_init(tCycle *const osc, LEAF *const leaf)
Initialize a tCycle to the default mempool of a LEAF instance.
Definition: leaf-oscillators.c:391
tCycle_setFreq
void tCycle_setFreq(tCycle *const osc, float freq)
Set the frequency of a tCycle oscillator.
Definition: leaf-oscillators.c:413
tCycle_tick
float tCycle_tick(tCycle *const osc)
Tick a tCycle oscillator.
Definition: leaf-oscillators.c:427
LEAF_init
void LEAF_init(LEAF *const leaf, float sampleRate, int blockSize, char *memory, size_t memorySize, float(*random)(void))
Initialize the LEAF instance.
Definition: leaf.c:21
LEAF
Struct for an instance of LEAF.
Definition: leaf-global.h:31