mirror of
				https://github.com/AquaMorph/Droplets.git
				synced 2025-10-31 08:23:18 +00:00 
			
		
		
		
	Basic VCA
This commit is contained in:
		
							
								
								
									
										50
									
								
								src/droplets/vca_droplet.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								src/droplets/vca_droplet.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| #include "vca_droplet.h" | ||||
|  | ||||
| VCADroplet::VCADroplet(DaisyPatch* m_patch, | ||||
| 		       DropletState m_state) : | ||||
|   Droplet(m_patch, | ||||
| 	  m_state) { | ||||
|   switch (GetState()) { | ||||
|   default: | ||||
|   case DropletState::kFull: | ||||
|     vca[0].Init(Patch()->controls[Patch()->CTRL_1], | ||||
| 		0.0, 1.0f, Parameter::LINEAR); | ||||
|     vca[1].Init(Patch()->controls[Patch()->CTRL_2], | ||||
| 		0.0, 1.0f, Parameter::LINEAR); | ||||
|     vca[2].Init(Patch()->controls[Patch()->CTRL_3], | ||||
| 		0.0, 1.0f, Parameter::LINEAR); | ||||
|     vca[3].Init(Patch()->controls[Patch()->CTRL_4], | ||||
| 		0.0, 1.0f, Parameter::LINEAR); | ||||
|     break; | ||||
|   case DropletState::kLeft: | ||||
|     vca[0].Init(Patch()->controls[Patch()->CTRL_1], | ||||
| 		0.0, 1.0f, Parameter::LINEAR); | ||||
|     vca[1].Init(Patch()->controls[Patch()->CTRL_2], | ||||
| 		0.0, 1.0f, Parameter::LINEAR); | ||||
|     break; | ||||
|   case DropletState::kRight: | ||||
|     vca[2].Init(Patch()->controls[Patch()->CTRL_3], | ||||
| 		0.0, 1.0f, Parameter::LINEAR); | ||||
|     vca[3].Init(Patch()->controls[Patch()->CTRL_3], | ||||
| 		0.0, 1.0f, Parameter::LINEAR); | ||||
|     break; | ||||
|   } | ||||
| } | ||||
|  | ||||
| VCADroplet::~VCADroplet() {} | ||||
|  | ||||
| void VCADroplet::Control() {} | ||||
|  | ||||
| void VCADroplet::Process(AudioHandle::InputBuffer in, AudioHandle::OutputBuffer out, size_t size) { | ||||
|   Patch()->ProcessAnalogControls(); | ||||
|    | ||||
|   for (size_t i = 0; i < size; i++) { | ||||
|     for (size_t chn = GetChannelMin(); chn < GetChannelMax(); chn++) { | ||||
|       out[chn][i] = in[chn][i] * vca[chn].Process(); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| void VCADroplet::Draw() { | ||||
|   DrawName("VCA"); | ||||
| } | ||||
							
								
								
									
										56
									
								
								src/droplets/vca_droplet.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								src/droplets/vca_droplet.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| #pragma once | ||||
|  | ||||
| #ifndef CASCADE_DROPLETS_VCA_DROPLET_H_ | ||||
| #define CASCADE_DROPLETS_VCA_DROPLET_H_ | ||||
|  | ||||
| #include "daisysp.h" | ||||
| #include "daisy_patch.h" | ||||
|  | ||||
| #include "droplet.h" | ||||
| #include "../util.h" | ||||
|  | ||||
| using namespace daisy; | ||||
| using namespace daisysp; | ||||
|  | ||||
| class VCADroplet: public Droplet { | ||||
| private: | ||||
|   Parameter vca[4]; | ||||
|  | ||||
| public: | ||||
|   /* | ||||
|    * Constructor for voltage amplifier droplet. | ||||
|    * | ||||
|    * @param m_patch pointer to patch | ||||
|    * @param m_state droplet position | ||||
|    */ | ||||
|   VCADroplet(DaisyPatch* m_patch, | ||||
| 	     DropletState m_state); | ||||
|    | ||||
|   /* | ||||
|    * Destructor for vco droplet. | ||||
|    */ | ||||
|   ~VCADroplet(); | ||||
|  | ||||
|   /* | ||||
|    * Processes user controls and inputs. | ||||
|    */ | ||||
|   void Control(); | ||||
|  | ||||
|   /* | ||||
|    * Processes audio input and outputs. | ||||
|    * | ||||
|    * @param in the audio inputs for the patch | ||||
|    * @param out the audio outputs for the patch | ||||
|    * @param size the number of inputs and outputs | ||||
|    */ | ||||
|   void Process(AudioHandle::InputBuffer in, | ||||
| 	       AudioHandle::OutputBuffer out, | ||||
| 	       size_t size); | ||||
|  | ||||
|   /* | ||||
|    * Processes information to be shown on the display.  | ||||
|    */ | ||||
|   void Draw(); | ||||
| }; | ||||
|  | ||||
| #endif // CASCADE_DROPLETS_VCA_DROPLET_H_ | ||||
		Reference in New Issue
	
	Block a user