mirror of
https://github.com/AquaMorph/Droplets.git
synced 2025-04-30 01:35:34 +00:00
Created droplet system with noise droplet
This commit is contained in:
parent
91a31ecd9d
commit
3198556e00
4
Makefile
4
Makefile
@ -1,6 +1,6 @@
|
||||
TARGET = main
|
||||
TARGET = cascade
|
||||
|
||||
CPP_SOURCES = src/main.cpp src/util.cpp src/menu.cpp
|
||||
CPP_SOURCES = src/main.cpp src/util.cpp src/menu.cpp src/droplets/noise_droplet.cpp
|
||||
|
||||
LIBDAISY_DIR = ./lib/libDaisy
|
||||
DAISYSP_DIR = ./lib/daisySP
|
||||
|
14
src/droplets/droplet.h
Normal file
14
src/droplets/droplet.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef CASCADE_DROPLETS_DROPLET_H_
|
||||
#define CASCADE_DROPLETS_DROPLET_H_
|
||||
|
||||
class Droplet {
|
||||
public:
|
||||
virtual ~Droplet() {};
|
||||
virtual void Control(float, float, float, float)=0;
|
||||
virtual void Process(float**, float**, size_t)=0;
|
||||
virtual void Draw(int*, int, int)=0;
|
||||
};
|
||||
|
||||
#endif // CASCADE_DROPLETS_DROPLET_H_
|
16
src/droplets/noise_droplet.cpp
Normal file
16
src/droplets/noise_droplet.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "noise_droplet.h"
|
||||
|
||||
NoiseDroplet::NoiseDroplet(float sample_rate) {
|
||||
noise.Init();
|
||||
}
|
||||
|
||||
void NoiseDroplet::Control(float ctr_1, float ctr_2, float ctr_3, float ctr_4) {}
|
||||
void NoiseDroplet::Process(float** in, float** out, size_t size) {
|
||||
for (size_t i = 0; i < size; i += 2) {
|
||||
float sig = noise.Process();
|
||||
for (size_t chn = 0; chn < 4; chn++) {
|
||||
out[chn][i] = sig;
|
||||
}
|
||||
}
|
||||
}
|
||||
void NoiseDroplet::Draw(int* d, int width, int height) {}
|
21
src/droplets/noise_droplet.h
Normal file
21
src/droplets/noise_droplet.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef CASCADE_DROPLETS_NOISE_DROPLET_H_
|
||||
#define CASCADE_DROPLETS_NOISE_DROPLET_H_
|
||||
|
||||
#include "daisysp.h"
|
||||
#include "daisy_patch.h"
|
||||
|
||||
#include "droplet.h"
|
||||
|
||||
class NoiseDroplet: public Droplet {
|
||||
private:
|
||||
daisysp::WhiteNoise noise;
|
||||
public:
|
||||
NoiseDroplet(float);
|
||||
void Control(float, float, float, float);
|
||||
void Process(float**, float**, size_t);
|
||||
void Draw(int*, int, int);
|
||||
};
|
||||
|
||||
#endif // CASCADE_DROPLETS_NOISE_DROPLET_H_
|
13
src/main.cpp
13
src/main.cpp
@ -6,16 +6,23 @@
|
||||
#include "main.h"
|
||||
#include "util.h"
|
||||
#include "menu.h"
|
||||
#include "droplets/droplet.h"
|
||||
#include "droplets/noise_droplet.h"
|
||||
|
||||
using namespace daisy;
|
||||
using namespace daisysp;
|
||||
|
||||
DaisyPatch patch;
|
||||
Menu menu(&patch);
|
||||
Droplet* droplet;
|
||||
|
||||
int main(void) {
|
||||
patch.Init();
|
||||
float samplerate = patch.AudioSampleRate();
|
||||
droplet = new NoiseDroplet(samplerate);
|
||||
patch.StartAdc();
|
||||
patch.StartAudio(AudioThrough);
|
||||
|
||||
while(true) {
|
||||
ProcessControls();
|
||||
ProcessOled();
|
||||
@ -51,3 +58,9 @@ void ProcessOled() {
|
||||
}
|
||||
patch.display.Update();
|
||||
}
|
||||
|
||||
static void AudioThrough(float **in, float **out, size_t size) {
|
||||
patch.UpdateAnalogControls();
|
||||
droplet->Process(in, out, size);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
void ProcessControls();
|
||||
void ProcessOled();
|
||||
void ProcessOutputs();
|
||||
static void AudioThrough(float **, float **, size_t);
|
||||
|
Loading…
x
Reference in New Issue
Block a user