mirror of
				https://github.com/AquaMorph/Droplets.git
				synced 2025-10-30 16:13:20 +00:00 
			
		
		
		
	VCO droplet outline
This commit is contained in:
		
							
								
								
									
										3
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								Makefile
									
									
									
									
									
								
							| @@ -4,7 +4,8 @@ CPP_SOURCES = src/main.cpp \ | |||||||
|               src/util.cpp \ |               src/util.cpp \ | ||||||
|               src/menu.cpp \ |               src/menu.cpp \ | ||||||
|               src/droplets/droplet.cpp \ |               src/droplets/droplet.cpp \ | ||||||
|               src/droplets/noise_droplet.cpp |               src/droplets/noise_droplet.cpp \ | ||||||
|  |               src/droplets/vco_droplet.cpp | ||||||
|  |  | ||||||
| LIBDAISY_DIR = ./lib/libDaisy | LIBDAISY_DIR = ./lib/libDaisy | ||||||
| DAISYSP_DIR = ./lib/daisySP | DAISYSP_DIR = ./lib/daisySP | ||||||
|   | |||||||
| @@ -15,6 +15,7 @@ enum class DropletState {kFull, kLeft, kRight}; | |||||||
|  |  | ||||||
| class Droplet { | class Droplet { | ||||||
|  public: |  public: | ||||||
|  |   DaisyPatch* patch; | ||||||
|   DropletState state; |   DropletState state; | ||||||
|   virtual ~Droplet() {}; |   virtual ~Droplet() {}; | ||||||
|   virtual void Control()=0; |   virtual void Control()=0; | ||||||
|   | |||||||
| @@ -11,7 +11,6 @@ | |||||||
|  |  | ||||||
| class NoiseDroplet: public Droplet { | class NoiseDroplet: public Droplet { | ||||||
|  private: |  private: | ||||||
|   DaisyPatch* patch; |  | ||||||
|   daisysp::WhiteNoise noise; |   daisysp::WhiteNoise noise; | ||||||
|   daisysp::NlFilt filter; |   daisysp::NlFilt filter; | ||||||
|  public: |  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_ | ||||||
| @@ -8,6 +8,7 @@ | |||||||
| #include "menu.h" | #include "menu.h" | ||||||
| #include "droplets/droplet.h" | #include "droplets/droplet.h" | ||||||
| #include "droplets/noise_droplet.h" | #include "droplets/noise_droplet.h" | ||||||
|  | #include "droplets/vco_droplet.h" | ||||||
|  |  | ||||||
| using namespace daisy; | using namespace daisy; | ||||||
|  |  | ||||||
| @@ -18,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(&patch, |   droplet = new VCODroplet(&patch, | ||||||
| 			   samplerate, | 			   samplerate, | ||||||
| 			   DropletState::kFull); | 			   DropletState::kFull); | ||||||
|   patch.StartAdc(); |   patch.StartAdc(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user