mirror of
				https://github.com/AquaMorph/Droplets.git
				synced 2025-10-30 16:13:20 +00:00 
			
		
		
		
	Refactored droplet design
This commit is contained in:
		| @@ -3,12 +3,16 @@ | |||||||
| #ifndef CASCADE_DROPLETS_DROPLET_H_ | #ifndef CASCADE_DROPLETS_DROPLET_H_ | ||||||
| #define CASCADE_DROPLETS_DROPLET_H_ | #define CASCADE_DROPLETS_DROPLET_H_ | ||||||
|  |  | ||||||
|  | #include "daisy_patch.h" | ||||||
|  |  | ||||||
|  | using namespace daisy; | ||||||
|  |  | ||||||
| class Droplet { | class Droplet { | ||||||
|  public: |  public: | ||||||
|   virtual ~Droplet() {}; |   virtual ~Droplet() {}; | ||||||
|   virtual void Control(float, float, float, float)=0; |   virtual void Control()=0; | ||||||
|   virtual void Process(float**, float**, size_t)=0; |   virtual void Process(float**, float**, size_t)=0; | ||||||
|   virtual void Draw(int*, int, int)=0; |   virtual void Draw()=0; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #endif // CASCADE_DROPLETS_DROPLET_H_ | #endif // CASCADE_DROPLETS_DROPLET_H_ | ||||||
|   | |||||||
| @@ -1,10 +1,11 @@ | |||||||
| #include "noise_droplet.h" | #include "noise_droplet.h" | ||||||
|  |  | ||||||
| NoiseDroplet::NoiseDroplet(float sample_rate) { | NoiseDroplet::NoiseDroplet(DaisyPatch* m_patch, float sample_rate) { | ||||||
|   noise.Init(); |   noise.Init(); | ||||||
|  |   patch = m_patch; | ||||||
| } | } | ||||||
|  |  | ||||||
| void NoiseDroplet::Control(float ctr_1, float ctr_2, float ctr_3, float ctr_4) {} | void NoiseDroplet::Control() {} | ||||||
| void NoiseDroplet::Process(float** in, float** out, size_t size) { | void NoiseDroplet::Process(float** in, float** out, size_t size) { | ||||||
|   for (size_t i = 0; i < size; i += 2) { |   for (size_t i = 0; i < size; i += 2) { | ||||||
|     float sig = noise.Process(); |     float sig = noise.Process(); | ||||||
| @@ -13,4 +14,6 @@ void NoiseDroplet::Process(float** in, float** out, size_t size) { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
| void NoiseDroplet::Draw(int* d, int width, int height) {} | void NoiseDroplet::Draw() { | ||||||
|  |   WriteString(*patch, 0, 30, Font_6x8, "Test"); | ||||||
|  | } | ||||||
|   | |||||||
| @@ -7,15 +7,17 @@ | |||||||
| #include "daisy_patch.h" | #include "daisy_patch.h" | ||||||
|  |  | ||||||
| #include "droplet.h" | #include "droplet.h" | ||||||
|  | #include "../util.h" | ||||||
|  |  | ||||||
| class NoiseDroplet: public Droplet { | class NoiseDroplet: public Droplet { | ||||||
|  private: |  private: | ||||||
|  |   DaisyPatch* patch; | ||||||
|   daisysp::WhiteNoise noise; |   daisysp::WhiteNoise noise; | ||||||
|  public: |  public: | ||||||
|   NoiseDroplet(float); |   NoiseDroplet(DaisyPatch*, float); | ||||||
|   void Control(float, float, float, float); |   void Control(); | ||||||
|   void Process(float**, float**, size_t); |   void Process(float**, float**, size_t); | ||||||
|   void Draw(int*, int, int); |   void Draw(); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #endif // CASCADE_DROPLETS_NOISE_DROPLET_H_ | #endif // CASCADE_DROPLETS_NOISE_DROPLET_H_ | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ Droplet* droplet; | |||||||
| int main(void) { | int main(void) { | ||||||
|   patch.Init(); |   patch.Init(); | ||||||
|   float samplerate = patch.AudioSampleRate(); |   float samplerate = patch.AudioSampleRate(); | ||||||
|   droplet = new NoiseDroplet(samplerate); |   droplet = new NoiseDroplet(&patch, samplerate); | ||||||
|   patch.StartAdc(); |   patch.StartAdc(); | ||||||
|   patch.StartAudio(AudioThrough); |   patch.StartAudio(AudioThrough); | ||||||
|    |    | ||||||
| @@ -56,6 +56,7 @@ void ProcessOled() { | |||||||
|   } else { |   } else { | ||||||
|     WriteString(patch, 0, 0, Font_6x8, menu.SelectedName()); |     WriteString(patch, 0, 0, Font_6x8, menu.SelectedName()); | ||||||
|   } |   } | ||||||
|  |   droplet->Draw(); | ||||||
|   patch.display.Update(); |   patch.display.Update(); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user