mirror of
				https://github.com/AquaMorph/Droplets.git
				synced 2025-10-29 23:53:19 +00:00 
			
		
		
		
	Created droplet system with noise droplet
This commit is contained in:
		
							
								
								
									
										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); | ||||
|   | ||||
| @@ -16,7 +16,7 @@ const std::string MENU_ITEMS[] = {"VCO", | ||||
| const int MENU_SIZE = sizeof(MENU_ITEMS)/sizeof(*MENU_ITEMS); | ||||
| const int MAX_CHAR_LENGTH = 15; | ||||
| const int MENU_X[] = {0,  5,  10,  5,  0}; | ||||
| const int MENU_Y[] = {0, 11, 22, 41, 52}; | ||||
| const int MENU_Y[] = {0, 11,  22, 41, 52}; | ||||
| int selectedMenuItem = 0; | ||||
| bool inMenu = false; | ||||
|  | ||||
| @@ -57,7 +57,7 @@ void Menu::CreateMenuItem(std::string text, int position, bool highlighted) { | ||||
| void Menu::ProcessMenuOled() { | ||||
|   CreateMenuItem(FilterMenuText(selectedMenuItem-2), 1, false); | ||||
|   CreateMenuItem(FilterMenuText(selectedMenuItem-1), 2, false); | ||||
|   CreateMenuItem(FilterMenuText(selectedMenuItem), 3, true); | ||||
|   CreateMenuItem(FilterMenuText(selectedMenuItem),   3, true); | ||||
|   CreateMenuItem(FilterMenuText(selectedMenuItem+1), 4, false); | ||||
|   CreateMenuItem(FilterMenuText(selectedMenuItem+2), 5, false); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user