mirror of
				https://github.com/AquaMorph/Droplets.git
				synced 2025-10-31 16:23:19 +00:00 
			
		
		
		
	VCO droplet outline
This commit is contained in:
		| @@ -15,6 +15,7 @@ enum class DropletState {kFull, kLeft, kRight}; | ||||
|  | ||||
| class Droplet { | ||||
|  public: | ||||
|   DaisyPatch* patch; | ||||
|   DropletState state; | ||||
|   virtual ~Droplet() {}; | ||||
|   virtual void Control()=0; | ||||
|   | ||||
| @@ -11,7 +11,6 @@ | ||||
|  | ||||
| class NoiseDroplet: public Droplet { | ||||
|  private: | ||||
|   DaisyPatch* patch; | ||||
|   daisysp::WhiteNoise noise; | ||||
|   daisysp::NlFilt filter; | ||||
|  public: | ||||
|   | ||||
							
								
								
									
										48
									
								
								src/droplets/vco_droplet.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								src/droplets/vco_droplet.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | ||||
| #include "vco_droplet.h" | ||||
|  | ||||
| VCODroplet::VCODroplet(DaisyPatch* m_patch, | ||||
| 		       float sample_rate, | ||||
| 		       DropletState m_state) { | ||||
|   UpdateState(m_state); | ||||
|   int num_waves = Oscillator::WAVE_LAST - 1; | ||||
|   osc.Init(sample_rate); | ||||
|   freqctrl.Init(patch->controls[patch->CTRL_1], 10.0, | ||||
| 		110.0f, Parameter::LINEAR); | ||||
|   finectrl.Init(patch->controls[patch->CTRL_2], 0.f, | ||||
| 		7.f, Parameter::LINEAR); | ||||
|   wavectrl.Init(patch->controls[patch->CTRL_3], 0.0, | ||||
| 		num_waves, Parameter::LINEAR); | ||||
|   ampctrl.Init(patch->controls[patch->CTRL_4], 0.0, | ||||
| 	       0.5f, Parameter::LINEAR); | ||||
| } | ||||
|  | ||||
| void VCODroplet::Control() {} | ||||
|  | ||||
| void VCODroplet::Process(float** in, float** out, size_t size) { | ||||
|   float sig, freq, amp; | ||||
|   size_t wave; | ||||
|    | ||||
|   patch->UpdateAnalogControls(); | ||||
|    | ||||
|   for (size_t i = 0; i < size; i += 2) { | ||||
|     // Read Knobs | ||||
|     freq = mtof(freqctrl.Process() + finectrl.Process()); | ||||
|     wave = wavectrl.Process(); | ||||
|     amp = ampctrl.Process(); | ||||
|     // Set osc params | ||||
|      | ||||
|     osc.SetFreq(freq); | ||||
|     osc.SetWaveform(wave); | ||||
|     osc.SetAmp(amp); | ||||
|     // Process | ||||
|     sig = osc.Process(); | ||||
|     // Assign Synthesized Waveform to all four outputs. | ||||
|     for (size_t chn = 0; chn < 4; chn++) { | ||||
|       out[chn][i] = sig; | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| void VCODroplet::Draw() { | ||||
|   DrawName(patch, "VCO"); | ||||
| } | ||||
							
								
								
									
										26
									
								
								src/droplets/vco_droplet.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/droplets/vco_droplet.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | ||||
| #pragma once | ||||
|  | ||||
| #ifndef CASCADE_DROPLETS_VCO_DROPLET_H_ | ||||
| #define CASCADE_DROPLETS_VCO_DROPLET_H_ | ||||
|  | ||||
| #include "daisysp.h" | ||||
| #include "daisy_patch.h" | ||||
|  | ||||
| #include "droplet.h" | ||||
| #include "../util.h" | ||||
|  | ||||
| using namespace daisy; | ||||
| using namespace daisysp; | ||||
|  | ||||
| class VCODroplet: public Droplet { | ||||
|  private: | ||||
|   Oscillator osc; | ||||
|   Parameter freqctrl, wavectrl, ampctrl, finectrl; | ||||
|  public: | ||||
|   VCODroplet(DaisyPatch*, float, DropletState); | ||||
|   void Control(); | ||||
|   void Process(float**, float**, size_t); | ||||
|   void Draw(); | ||||
| }; | ||||
|  | ||||
| #endif // CASCADE_DROPLETS_VCO_DROPLET_H_ | ||||
		Reference in New Issue
	
	Block a user