浏览代码

visu with fixed output - release

Philippe G 5 年之前
父节点
当前提交
a094b0d61f

+ 1 - 1
components/squeezelite/decode_external.c

@@ -207,7 +207,7 @@ static bool raop_sink_cmd_handler(raop_event_t event, va_list args)
 			// first must make sure we started on time
 			if (raop_sync.win == SYNC_WIN_START) {
 				// how many ms have we really played
-				ms = now - output.updated + ((u64_t) (output.frames_played_dmp - output.device_frames) * 1000) / RAOP_SAMPLE_RATE;
+				ms = now - output.updated + ((output.frames_played_dmp - output.device_frames) * 10) / (RAOP_SAMPLE_RATE / 100);
 				error = ms - (now - raop_sync.start_time);
 				
 				LOG_INFO("backend played %u, desired %u, (delta:%d)", ms, now - raop_sync.start_time, ms - (now - raop_sync.start_time));

+ 2 - 2
components/squeezelite/display.c

@@ -864,7 +864,7 @@ static void visu_update(void) {
 		
 			// convert to dB (1 bit remaining for getting X²/N, 60dB dynamic starting from 0dBFS = 3 bits back-off)
 			for (int i = visu.n; --i >= 0;) {	 
-				visu.bars[i].current = visu.max * (0.01667f*10*log10f(0.0000001f + (visu.bars[i].current >> 1)) - 0.2543f);
+				visu.bars[i].current = visu.max * (0.01667f*10*log10f(0.0000001f + (visu.bars[i].current >> (visu_export.gain == FIXED_ONE ? 7 : 1))) - 0.2543f);
 				if (visu.bars[i].current > visu.max) visu.bars[i].current = visu.max;
 				else if (visu.bars[i].current < 0) visu.bars[i].current = 0;
 			}
@@ -906,7 +906,7 @@ static void visu_update(void) {
 				}	
 			
 				// convert to dB and bars, same back-off
-				if (power) visu.bars[i].current = visu.max * (0.01667f*10*(log10f(power) - log10f(FFT_LEN/2*2)) - 0.2543f);
+				if (power) visu.bars[i].current = visu.max * (0.01667f*10*(log10f(power) - log10f(FFT_LEN/(visu_export.gain == FIXED_ONE ? 128 : 2)*2)) - 0.2543f);
 				if (visu.bars[i].current > visu.max) visu.bars[i].current = visu.max;
 				else if (visu.bars[i].current < 0) visu.bars[i].current = 0;
 			}	

+ 2 - 2
components/squeezelite/embedded.h

@@ -62,11 +62,11 @@ void 		decode_restore(int external);
 // to be defined to nothing if you don't want to support these
 extern struct visu_export_s {
 	pthread_mutex_t mutex;
-	u32_t level, size, rate;
+	u32_t level, size, rate, gain;
 	s16_t *buffer;
 	bool running;
 } visu_export;
-void 		output_visu_export(s16_t *frames, frames_t out_frames, u32_t rate, bool silence);
+void 		output_visu_export(s16_t *frames, frames_t out_frames, u32_t rate, bool silence, u32_t gain);
 void 		output_visu_init(log_level level);
 void 		output_visu_close(void);
 

+ 1 - 1
components/squeezelite/output_bt.c

@@ -121,7 +121,7 @@ static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t g
 		memcpy(btout + oframes * BYTES_PER_FRAME, buf, out_frames * BYTES_PER_FRAME);
 	}
 	
-	output_visu_export((s16_t*) (btout + oframes * BYTES_PER_FRAME), out_frames, output.current_sample_rate, silence);
+	output_visu_export((s16_t*) (btout + oframes * BYTES_PER_FRAME), out_frames, output.current_sample_rate, silence, (gainL + gainR) / 2);
 
 	return (int)out_frames;
 }

+ 1 - 1
components/squeezelite/output_i2s.c

@@ -367,7 +367,7 @@ static int _i2s_write_frames(frames_t out_frames, bool silence, s32_t gainL, s32
 	_scale_and_pack_frames(obuf + oframes * bytes_per_frame, optr, out_frames, gainL, gainR, output.format);
 #endif	
 
-	output_visu_export((s16_t*) (obuf + oframes * bytes_per_frame), out_frames, output.current_sample_rate, silence);
+	output_visu_export((s16_t*) (obuf + oframes * bytes_per_frame), out_frames, output.current_sample_rate, silence, (gainL + gainR) / 2);
 
 	oframes += out_frames;
 	

+ 2 - 1
components/squeezelite/output_visu.c

@@ -29,7 +29,7 @@ static struct visu_export_s *visu = &visu_export;
 
 static log_level loglevel = lINFO;
 
-void output_visu_export(s16_t *frames, frames_t out_frames, u32_t rate, bool silence) {
+void output_visu_export(s16_t *frames, frames_t out_frames, u32_t rate, bool silence, u32_t gain) {
 	
 	// no data to process
 	if (silence) {
@@ -50,6 +50,7 @@ void output_visu_export(s16_t *frames, frames_t out_frames, u32_t rate, bool sil
 			visu->level += space / 2;
 			visu->running = true;
 			visu->rate = rate ? rate : 44100;
+			visu->gain = gain;
 		}
 		
 		// mutex must be released