mirror of
				https://github.com/AquaMorph/Droplets.git
				synced 2025-10-31 16:23:19 +00:00 
			
		
		
		
	Ladder filter title animation
This commit is contained in:
		| @@ -21,6 +21,10 @@ int Droplet::GetTitleHeight() { | ||||
|   return kTitleHeight; | ||||
| } | ||||
|  | ||||
| int Droplet::GetScreenWidth() { | ||||
|   return screen_max - screen_min; | ||||
| } | ||||
|  | ||||
| int Droplet::GetScreenMin() { | ||||
|   return screen_min; | ||||
| } | ||||
|   | ||||
| @@ -99,6 +99,13 @@ public: | ||||
|    */ | ||||
|   int GetTitleHeight(); | ||||
|  | ||||
|   /* | ||||
|    * Returns the width of the droplet. | ||||
|    * | ||||
|    * @return screen width of the droplet | ||||
|    */ | ||||
|   int GetScreenWidth(); | ||||
|  | ||||
|   /* | ||||
|    * Returns the minimum screen position based on droplet size. | ||||
|    * | ||||
|   | ||||
| @@ -26,12 +26,45 @@ void LadderFilterDroplet::Process(AudioHandle::InputBuffer in, | ||||
|       filter[chn].SetFreq(freq); | ||||
|       filter[chn].SetRes(res); | ||||
|       out[chn][i] = filter[chn].Process(in[chn][i]) * (1.0f+res*4); | ||||
|       //out[chn][i] = in[chn][i] * res; | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| void LadderFilterDroplet::Draw() { | ||||
|   int filter_cutoff_line = GetScreenMin()+(GetScreenWidth()*(freq/FILTER_MAX)); | ||||
|   DrawSolidRect(Patch(), | ||||
| 		GetScreenMin(), | ||||
| 		3, | ||||
| 		filter_cutoff_line, | ||||
| 		GetTitleHeight()-1, | ||||
| 		true); | ||||
|  | ||||
|   // Draw filter roll off | ||||
|   Patch()->display.DrawLine(filter_cutoff_line+1, 5, | ||||
|   			    filter_cutoff_line+1, GetTitleHeight()-1, true); | ||||
|  | ||||
|   // Draw Res | ||||
|   res_points[0] = filter_cutoff_line-7*(res/RES_MAX); | ||||
|   res_points[1] = filter_cutoff_line-3; | ||||
|   res_points[2] = filter_cutoff_line-11*(res/RES_MAX); | ||||
|   res_points[3] = filter_cutoff_line-2; | ||||
|   res_points[4] = filter_cutoff_line-14*(res/RES_MAX); | ||||
|   res_points[5] = filter_cutoff_line-1; | ||||
|  | ||||
|   for (int i = 0; i < 6; i++) { | ||||
|     res_points[i] = std::max(GetScreenMin(), res_points[i]); | ||||
|   } | ||||
|    | ||||
|   if (res > 0.6*RES_MAX) { | ||||
|     Patch()->display.DrawLine(res_points[0], 0, res_points[1], 0, true); | ||||
|   } | ||||
|   if (res > 0.3*RES_MAX) { | ||||
|     Patch()->display.DrawLine(res_points[2], 1, res_points[3], 1, true); | ||||
|   } | ||||
|   if (res > 0.1*RES_MAX) { | ||||
|     Patch()->display.DrawLine(res_points[4], 2, res_points[5], 2, true); | ||||
|   } | ||||
|    | ||||
|   DrawName("Ladder"); | ||||
| } | ||||
|  | ||||
| @@ -46,6 +79,6 @@ void LadderFilterDroplet::SetControls() { | ||||
|     filter_knob = Patch()->controls[Patch()->CTRL_1]; | ||||
|     res_knob = Patch()->controls[Patch()->CTRL_2]; | ||||
|   } | ||||
|   freq_ctrl.Init(filter_knob, 5.0f, 10000.0f, Parameter::LOGARITHMIC); | ||||
|   res_ctrl.Init(res_knob, 0.0f, 0.95f, Parameter::LINEAR); | ||||
|   freq_ctrl.Init(filter_knob, 5.0f, FILTER_MAX, Parameter::LOGARITHMIC); | ||||
|   res_ctrl.Init(res_knob, 0.0f, RES_MAX, Parameter::LINEAR); | ||||
| } | ||||
|   | ||||
| @@ -14,6 +14,9 @@ private: | ||||
|   MoogLadder filter[4]; | ||||
|   Parameter freq_ctrl, res_ctrl; | ||||
|   float freq, res; | ||||
|   float FILTER_MAX = 10000.0f; | ||||
|   float RES_MAX = 0.95f; | ||||
|   int res_points[6]; | ||||
| public: | ||||
|   /* | ||||
|    * Constructor for a droplet. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user