| 
				
				
					
				
				
				 | 
			
			 | 
			@@ -8,7 +8,10 @@ namespace rack { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			json_t *ParamWidget::toJson() { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				json_t *rootJ = json_object(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				json_object_set_new(rootJ, "paramId", json_integer(paramId)); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				json_object_set_new(rootJ, "value", json_real(value)); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				// Infinite params should serialize to 0 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				float v = (isfinite(minValue) && isfinite(maxValue)) ? value : 0.f; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				json_object_set_new(rootJ, "value", json_real(v)); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				return rootJ; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			} | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
	
		
			
				| 
				
				
				
					
				
				 | 
			
			 | 
			@@ -19,17 +22,22 @@ void ParamWidget::fromJson(json_t *rootJ) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			} | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			void ParamWidget::reset() { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				setValue(defaultValue); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				// Infinite params should not be reset | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				if (isfinite(minValue) && isfinite(maxValue)) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
					setValue(defaultValue); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				} | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			} | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			void ParamWidget::randomize() { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				if (randomizable && isfinite(minValue) && isfinite(maxValue)) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
					setValue(rescale(randomUniform(), 0.0, 1.0, minValue, maxValue)); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				// Infinite params should not be randomized | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				if (randomizable && isfinite(minValue) && isfinite(maxValue)) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
					setValue(rescale(randomUniform(), 0.f, 1.f, minValue, maxValue)); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				} | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			} | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			void ParamWidget::onMouseDown(EventMouseDown &e) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				if (e.button == 1) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
					setValue(defaultValue); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
					reset(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				} | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				e.consumed = true; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
				e.target = this; | 
		
		
	
	
		
			
				| 
				
					
				
				
				
				 | 
			
			 | 
			
  |