From c8713e92312ef140ea8576031769cdad10b30946 Mon Sep 17 00:00:00 2001
From: David Robillard <d@drobilla.net>
Date: Wed, 16 Dec 2020 16:51:04 +0100
Subject: Fix implicit and narrowing conversions

---
 plugins/eg-metro.lv2/metro.c           | 4 ++--
 plugins/eg-params.lv2/params.c         | 2 +-
 plugins/eg-sampler.lv2/sampler.c       | 2 +-
 plugins/eg-sampler.lv2/sampler_ui.c    | 4 ++--
 plugins/eg-scope.lv2/examploscope.c    | 4 ++--
 plugins/eg-scope.lv2/examploscope_ui.c | 4 ++--
 6 files changed, 10 insertions(+), 10 deletions(-)

(limited to 'plugins')

diff --git a/plugins/eg-metro.lv2/metro.c b/plugins/eg-metro.lv2/metro.c
index 4531e1e..eebad3e 100644
--- a/plugins/eg-metro.lv2/metro.c
+++ b/plugins/eg-metro.lv2/metro.c
@@ -235,7 +235,7 @@ play(Metro* self, uint32_t begin, uint32_t end)
 			// Amplitude decreases from 1..0 until attack_len + decay_len
 			output[i] = 0.0f;
 			output[i] = self->wave[self->wave_offset] *
-				(1 - ((self->elapsed_len - self->attack_len) /
+				(1 - ((float)(self->elapsed_len - self->attack_len) /
 				      (float)self->decay_len));
 			if (self->elapsed_len >= self->attack_len + self->decay_len) {
 				self->state = STATE_OFF;
@@ -285,7 +285,7 @@ update_position(Metro* self, const LV2_Atom_Object* obj)
 	if (beat && beat->type == uris->atom_Float) {
 		// Received a beat position, synchronise
 		// This hard sync may cause clicks, a real plugin would be more graceful
-		const float frames_per_beat = 60.0f / self->bpm * self->rate;
+		const float frames_per_beat = (float)(60.0 / self->bpm * self->rate);
 		const float bar_beats       = ((LV2_Atom_Float*)beat)->body;
 		const float beat_beats      = bar_beats - floorf(bar_beats);
 		self->elapsed_len           = beat_beats * frames_per_beat;
diff --git a/plugins/eg-params.lv2/params.c b/plugins/eg-params.lv2/params.c
index cb09e83..a302acb 100644
--- a/plugins/eg-params.lv2/params.c
+++ b/plugins/eg-params.lv2/params.c
@@ -482,7 +482,7 @@ run(LV2_Handle instance, uint32_t sample_count)
 
 	if (self->state.spring.body > 0.0f) {
 		const float spring = self->state.spring.body;
-		self->state.spring.body = (spring >= 0.001) ? spring - 0.001 : 0.0;
+		self->state.spring.body = (spring >= 0.001) ? spring - 0.001f : 0.0f;
 		lv2_atom_forge_frame_time(&self->forge, 0);
 		LV2_Atom_Forge_Frame frame;
 		lv2_atom_forge_object(&self->forge, &frame, 0, uris->patch_Set);
diff --git a/plugins/eg-sampler.lv2/sampler.c b/plugins/eg-sampler.lv2/sampler.c
index a3b2e7d..341f412 100644
--- a/plugins/eg-sampler.lv2/sampler.c
+++ b/plugins/eg-sampler.lv2/sampler.c
@@ -281,7 +281,7 @@ instantiate(const LV2_Descriptor*     descriptor,
 	lv2_atom_forge_init(&self->forge, self->map);
 	peaks_sender_init(&self->psend, self->map);
 
-	self->gain = 1.0;
+	self->gain = 1.0f;
 
 	return (LV2_Handle)self;
 }
diff --git a/plugins/eg-sampler.lv2/sampler_ui.c b/plugins/eg-sampler.lv2/sampler_ui.c
index a6fa36f..2f4e435 100644
--- a/plugins/eg-sampler.lv2/sampler_ui.c
+++ b/plugins/eg-sampler.lv2/sampler_ui.c
@@ -168,7 +168,7 @@ on_canvas_expose(GtkWidget* widget, GdkEventExpose* event, gpointer data)
 	gtk_widget_get_allocation(widget, &size);
 
 	ui->width = size.width;
-	if ((uint32_t)ui->width > 2 * ui->requested_n_peaks) {
+	if (ui->width > 2 * ui->requested_n_peaks) {
 		request_peaks(ui, 2 * ui->requested_n_peaks);
 	}
 
@@ -177,7 +177,7 @@ on_canvas_expose(GtkWidget* widget, GdkEventExpose* event, gpointer data)
 	cairo_set_line_width(cr, 1.0);
 	cairo_translate(cr, 0.5, 0.5);
 
-	const int mid_y = size.height / 2;
+	const double mid_y = size.height / 2.0;
 
 	const float* const peaks   = ui->precv.peaks;
 	const int32_t      n_peaks = ui->precv.n_peaks;
diff --git a/plugins/eg-scope.lv2/examploscope.c b/plugins/eg-scope.lv2/examploscope.c
index e175804..af0e302 100644
--- a/plugins/eg-scope.lv2/examploscope.c
+++ b/plugins/eg-scope.lv2/examploscope.c
@@ -124,7 +124,7 @@ instantiate(const LV2_Descriptor*     descriptor,
 
 	// Set default UI settings
 	self->ui_spp = 50;
-	self->ui_amp = 1.0;
+	self->ui_amp = 1.0f;
 
 	// Map URIs and initialise forge/logger
 	map_sco_uris(self->map, &self->uris);
@@ -252,7 +252,7 @@ run(LV2_Handle handle, uint32_t n_samples)
 		lv2_atom_forge_key(&self->forge, self->uris.ui_amp);
 		lv2_atom_forge_float(&self->forge, self->ui_amp);
 		lv2_atom_forge_key(&self->forge, self->uris.param_sampleRate);
-		lv2_atom_forge_float(&self->forge, self->rate);
+		lv2_atom_forge_float(&self->forge, (float)self->rate);
 		lv2_atom_forge_pop(&self->forge, &frame);
 	}
 
diff --git a/plugins/eg-scope.lv2/examploscope_ui.c b/plugins/eg-scope.lv2/examploscope_ui.c
index 5e244af..48ffec4 100644
--- a/plugins/eg-scope.lv2/examploscope_ui.c
+++ b/plugins/eg-scope.lv2/examploscope_ui.c
@@ -353,8 +353,8 @@ process_channel(EgScopeUI*   ui,
 			if (chn->idx == 0) {
 				++overflow;
 			}
-			chn->data_min[chn->idx] = 1.0;
-			chn->data_max[chn->idx] = -1.0;
+			chn->data_min[chn->idx] = 1.0f;
+			chn->data_max[chn->idx] = -1.0f;
 		}
 	}
 	*idx_end = chn->idx;
-- 
cgit v1.2.1